python - Identify wx.BitmapButton created by wxformbuilder -
i have little python question. created gui using wxformbuilder
. in gui, there multiple bitmap buttons. binded same function.
in main program, want separate them depending on name. geteventobject()
doesn't work here.
i manually edit automated gui code, prefer not that. there function use in order retrieve lets btn_forwardleft
name gui file?
in automatic generated gui.py
self.btn_forwardleft = wx.bitmapbutton( self, wx.id_any, wx.bitmap( u"button_upleft.png", wx.bitmap_type_any ), wx.defaultposition, wx.defaultsize, wx.bu_autodraw ) self.btn_forwardleft.setbitmapselected( wx.bitmap( u"button_upleft_p.png", wx.bitmap_type_any ) ) self.btn_forwardright = wx.bitmapbutton( self, wx.id_any, wx.bitmap( u"button_upright.png", wx.bitmap_type_any ), wx.defaultposition, wx.defaultsize, wx.bu_autodraw ) self.btn_forwardright.setbitmapselected( wx.bitmap( u"button_upright_p.png", wx.bitmap_type_any ) ) self.btn_forwardleft.bind( wx.evt_button, self.onarrowbuttonpress ) self.btn_forwardright.bind( wx.evt_button, self.onarrowbuttonpress )
and in main.py program
def onarrowbuttonpress(self,event): keyname = event.geteventobject() # print keyname timeoutflag = false if(keyname=='btn_forwardleft'): command = 10 elif(keyname=='btn_forwardright'): command = 20
geteventobject()
returns pointer, can compared self.anything
that
def onarrowbuttonpress(self,event): keyname = event.geteventobject() # print keyname timeoutflag = false if(keyname==self.btn_forwardleft): command = 10 elif(keyname==self.btn_forwardright): command = 20
Comments
Post a Comment