wx.Button EVT_PAINT does not work on Linux?

Hi all,

I’m trying to create some custom buttons. In order to do this, I’ve overridden the wx.EVT_PAINT method and do my drawing manually. This works great on OS X and Windows. However it completely fails on Linux as it seems that the wx.EVT_PAINT is ignored. Any thoughts on why that is? The only solution I can think of is to instead use a wx.Panel and use wx.EVT_LEFT_DOWN to simulate wx.EVT_BUTTON.

Here is sample code:

import wx

class MainWindow(wx.Frame):

def init(self, parent, title, size=wx.DefaultSize):

wx.Frame.init(self, parent, wx.ID_ANY, title, wx.DefaultPosition, size)

button = MainButton(self, wx.ID_ANY, "A Custom Button")

sizer = wx.BoxSizer(wx.HORIZONTAL)

sizer.Add(button, 0, wx.ALL, 0)

sizer.Fit(self)

self.SetSizer(sizer)

self.SetSize(size)

self.Layout()

self.Center()

class MainButton(wx.Button):

def init(self, *args, **kwargs):

wx.Button.init(self, *args, **kwargs)

self.Bind(wx.EVT_PAINT, self.OnPaint)

def OnPaint(self, e):

print “OnPaint called”

def main():

app = wx.App()

win = MainWindow(None, “Custom Button Example”, size=(620,460))

win.Show()

app.MainLoop()

if name == “main”:

main()