Can't override OnCreateStatusBar for wxFrame
Larry Bates
larry.bates at websafe.com
Sat Oct 20 12:44:07 PDT 2007
I wanted to create a custom status for my frame but I couldn't get it to work.
I've stripped it down to the code below. Docs say if you override
OnCreateStatusBar method of wx.Frame it will get called and you can return your
custom status bar instance. Am I doing something wrong, or is this a bug?
Thanks in advance.
Larry
import wx
import time
class CustomStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self, parent, -1)
self.SetFieldsCount(2)
print "CustomStatusBar, setting StatusWidths"
self.SetStatusWidths([570, 70])
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1)
self.SetSize((640, 480))
self.CreateStatusBar(1)
b = wx.Button(self, -1, "Start demo", (50,50))
self.Bind(wx.EVT_BUTTON, self.demo, b)
def demo(self, event):
CSB=self.GetStatusBar()
for i in xrange(20):
print "setting value=%i" % (i+1)
CSB.SetStatusText("%i" % (i+1), 1)
time.sleep(.2)
def OnCreateStatusBar(self, *args, **kwds):
print "OnCreateStatusBar-Entering"
return CustomStatusBar(self)
if __name__ == "__main__":
app = wx.App(0)
f = TestFrame()
f.Show()
app.MainLoop()
More information about the wxpython-users
mailing list