Edit: (little change -> 2nd problem) I created a BitmapButton & a TextCtrl. The picture in this button shall change when a certain text is entered in TextCtrl. This works:
def create(self,event):
self.textinput = wx.TextCtrl(self.panel, pos=(100,20))
self.picture = wx.Image("pics\\default.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
self.picturebutton = wx.BitmapButton(self.panel,-1,self.picture,pos=(100,50))
self.textinput.Bind(wx.EVT_CHAR, self.changepic)
def changepic(self,event):
if self.textinput.GetValue = 'test':
self.picturebutton.Destroy()
self.picture = wx.Image("pics\\new.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
self.picturebutton = wx.BitmapButton(self.panel,-1,self.picture,pos=(100,50))
event.Skip()
1.) I hope there is another way instead of destroying & rebuilding this button. I tried
self.picturebutton.Refresh()
and
self.picturebutton.Update()
instead of
self.picturebutton.Destroy()
self.picturebutton=wx.BitmapButton(self.panel,-1,self.picture,pos=(100,50))
but nothing happened. What can I do?
2.) It looks like "changepic" is called at first and then my TextCtrl receives the char. Because when I enter "test", nothing happens until i press another key. So the picture changes when I enter e.g. "testa". But it shall change when "test" is in the TextCtrl. How can I solve this? Is there a TextCtrl-Event which first puts the char in the TextCtrl and then call a function?