hello..
Am having troubles binding the wx.EVT_BUTTON event of a wx.BitmapButton..
I've tried the Bind(wx.EVT_BUTTON, FUNCT, BUTTON) and button.Bind(wx.EVT_BUTTON, FUNCT) and neither of them works..
I dont know if the problems is that the button is in a third level panel (I think this is how you call when you have a panel that is a child of a window that is a child of another panel, but you get the idea) but I put a normal button in that panel and the normal button works fine..
heres the code:
import wx
class MainFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(800, 800))
self.mainPanel = self.panel()
self.leftWindow = self.scrolledWindow(self.mainPanel)
self.rightWindow = self.bareWindow(self.mainPanel)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.leftWindow, 1, wx.EXPAND)
box.Add(self.rightWindow, 0)
self.mainPanel.SetSizer(box)
self.Centre()
def panel(self):
self.panel = wx.Panel(self, id=-1)
return self.panel
def scrolledWindow(self, parent):
self.window = wx.ScrolledWindow(parent, -1)
self.window.SetVirtualSize((2000, 2000))
self.window.SetScrollRate(10, 10)
return self.window
def bareWindow(self, parent):
self.window = wx.Window(parent, -1, style=wx.RAISED_BORDER)
self.panel = wx.Panel(self.window, -1)
sizer = wx.GridSizer(rows=0, cols=2, hgap=1, vgap=1)
botonprueba = wx.BitmapButton(self.panel, wx.NewId(), wx.Bitmap("img/180bendS.png"))
botonprueba.Bind = (wx.EVT_BUTTON, self.On180BendS)
boton = wx.Button(self.panel, label="test", size=(38, 33))
boton.Bind(wx.EVT_BUTTON, self.OnTest)
sizer.Add(botonprueba, 0, 0)
sizer.Add(boton, 0, 0)
self.panel.SetSizer(sizer)
self.panel.Fit()
return self.window
def OnTest(self, evt): print "Test"
def On180BendS(self, evt): print "On 180 bendS"
def rightButtonsData(self):
return (("180bendS.png", self.On180BendS))
class App(wx.App):
def OnInit(self):
frame = MainFrame(None, -1, 'Application')
frame.Show(True)
return True
if __name__ == "__main__":
app = App()
app.MainLoop()
to test the script you need to copy this image [1] in the same folder of the script
[1] http://dl.dropbox.com/u/391810/180bendS.png