Hi,
schick, die bunte Statusbar, kann ich gut gebrauchen! Hab ein bischen was dazu gebastelt, um den Text zur Laufzeit bequem ändern zu können.
Code: Alles auswählen
import wx
class CustomStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self, parent, -1)
self.SetFieldsCount(4)
self.SetStatusWidths([-2, -2, -2,-2])
self.SetBackgroundColour(wx.Colour(255,215,50))
def status_text(self, txt, field):
self.Reposition(wx.StaticText(self, -1, txt), field)
def Reposition(self, cb, field):
rect = self.GetFieldRect(field)
cb.SetPosition((rect.x, rect.y))
cb.SetSize((rect.width, rect.height))
class TestCustomStatusBar(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, 'Test Custom StatusBar')
self.sb = CustomStatusBar(self)
self.SetStatusBar(self.sb)
self.SetSize((640, 480))
tc = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY|wx.TE_MULTILINE)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def OnCloseWindow(self, event):
self.Destroy()
if __name__ == '__main__':
app = wx.PySimpleApp()
win = TestCustomStatusBar(None)
win.Show()
#--------------- Statusbartext aendern --------------
win.sb.status_text(' och',0)
win.sb.status_text(' nee!',1)
win.sb.status_text(' der schon',2)
win.sb.status_text(' wieder',3)
win.sb.Update()
app.MainLoop()
Gruß,
Seven