我有两个wxpython单选按钮组:
self.red = wx.RadioButton(panel, -1, 'Red', (10, q2y), style=wx.RB_GROUP)
self.orange = wx.RadioButton(panel, -1, 'Orange', (50, q2y))
self.yellow = wx.RadioButton(panel, -1, 'Yellow', (100, q2y))
self.dot = wx.RadioButton(panel, -1, 'Dot', (10, q3y), style=wx.RB_GROUP)
self.triangle = wx.RadioButton(panel, -1, 'Triangle', (50, q3y))
self.rectange = wx.RadioButton(panel, -1, 'Rectangle', (100, q3y))
是否有一种简单的方法可以从每个组中获取所选单选按钮而无需遍历所有按钮?
答案 0 :(得分:1)
使用wx.EVT_RADIOBUTTON绑定并在事件处理程序中使用event.GetEventObject来获取所选按钮。有关代码示例,请参阅RadioButton的wxPython演示。