Text in statusbar is disapearing at menuclick

Hi,
in the following example the statustext in field 0 is disapearing as soon as
I
click the Menu. How comes? And what can I do?

Thanks,
marcus

from wxPython.wx import *

···

#----------------------------------------------------------------------
class MainFrame(wxFrame):
    def __init__(self):
        wxFrame.__init__(self, None, -1, "stattest", size=(800,600))
        self.sb = MyStatusBar(self)
        self.SetStatusBar(self.sb)
        self.sb.SetStandard()
        sourcemenu=wxMenu()
        self.menubar = wxMenuBar()
        self.menubar.Append(sourcemenu,'&Source')
        self.SetMenuBar(self.menubar)
#----------------------------------------------------------------------
class MyStatusBar(wxStatusBar):
    def __init__(self, parent):
      self.parent=parent
        wxStatusBar.__init__(self, self.parent, -1)
        self.SetFieldsCount(2)
        self.sizeChanged = false
        self.isind = false
        EVT_SIZE(self, self.OnSize)
        EVT_IDLE(self, self.OnIdle)
#-------------------------------------------
    def OnSize(self, evt):
      if self.isind:
            self.Reposition()
        self.sizeChanged = true
#-------------------------------------------
    def OnIdle(self, evt):
        if self.sizeChanged and self.isind:
            self.Reposition()
#-------------------------------------------
    def Reposition(self):
        rect = self.GetFieldRect(1)
        self.g.SetPosition(wxPoint(rect.x+2, rect.y+2))
        self.g.SetSize(wxSize(rect.width-4, rect.height-4))
        self.sizeChanged = false
#-------------------------------------------
    def SetInd(self,value):
        self.g.SetValue(value)
        self.parent.Refresh()
        self.parent.Update()
#-------------------------------------------
    def MakeInd(self,s):
        self.SetStatusText('blahblah %s'%(s),0)
        if not self.isind:
            self.isind = true
            self.g = wxGauge(self, -1, 50, wxPoint(110, 95), wxSize(250,
25),
                              wxGA_HORIZONTAL|wxGA_SMOOTH)
            self.g.SetBezelFace(5)
            self.g.SetShadowWidth(5)
            self.g.SetRange(100)
            self.g.SetValue(0)
            # set the initial position of the checkbox
            self.Reposition()
#-------------------------------------------
    def SetStandard(self):
        self.SetStatusText('blohbloh',0)
        if self.isind:
            self.g.Destroy()
            self.isind=false
        self.SetStatusText('bluhbluh',1)
#-------------------------------------------
#----------------------------------------------------------------------
class MyApp(wxApp):
    def OnInit(self):
        frame = MainFrame()
        frame.Show(true)
        self.SetTopWindow(frame)
        return true
#--------------------------------------------
app = MyApp(0)
app.MainLoop()

Marcus Stojek wrote:

Hi,
in the following example the statustext in field 0 is disapearing as soon as
I
click the Menu. How comes? And what can I do?

The default behaviour of menus is to place the menu item's help text into the status bar. A side effect is that if there is no help text the status bar still gets cleared. To get aroudn it you could catch the EVT_MENU_HIGHLIGHT event from the frame and put the text back there.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!