代码演示
import wx
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, title="单选框和多选框事件绑定")
panel = wx.Panel(frame, -1)
self.radio1 = wx.RadioButton(panel, -1, "男", pos=(10, 10))
self.radio2 = wx.RadioButton(panel, -1, "女", pos=(10, 30))
self.Bind(wx.EVT_RADIOBUTTON, self.radio_click)
self.check1 = wx.CheckBox(panel, -1, "youxi", pos=(10, 50))
self.check2 = wx.CheckBox(panel, -1, "lanqiu", pos=(10, 70))
frame.Show()
return True
def radio_click(self, event):
print(event.GetEventObject().GetLabel())
print(self.radio1.GetValue())
print(self.radio2.GetValue())
app = MyApp()
app.MainLoop()