简体   繁体   中英

binding a button wxPython

I need a name of button to bind it, for example: buttonname.Bind etc. But in my code I don't have any names of buttons, only ID's, because I work with AddMany .

panel = wx.Panel(self)

vbox = wx.BoxSizer(wx.VERTICAL)


gbox = wx.GridSizer(8, 2, 8, 8)
gbox.AddMany([(wx.StaticText(panel, label="test"), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel, label = a), wx.EXPAND),
              (wx.TextCtrl(panel), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel, label = result), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel, label="test"), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel), wx.EXPAND),
              (wx.TextCtrl(panel), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel, label="test"), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel), wx.EXPAND),
              (wx.TextCtrl(panel), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel, label="test"), wx.ID_ANY, wx.EXPAND),
              (wx.StaticText(panel), wx.EXPAND),
              (wx.TextCtrl(panel), wx.ID_ANY, wx.EXPAND),
              (wx.Button(panel, label = "rtfhd"), wx.ID_ANY, wx.EXPAND)
              ]
              )
vbox.Add(gbox, proportion = 1,  flag=wx.EXPAND | wx.ALL, border = 20)

panel.SetSizer(vbox)

every window can be given a name='name' and by using 'FindWindowByName' the window can be determined for the Bind

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM