status bar question

Scott Frankel:

  I suggest you call frame.CreateStatusBar() in frame.__init__() and associate the statusbar to your frame with frame.SetStatusBar(), call GetStatusBar when you need it instead of creating a new one.

======= 2005-03-11 08:08:42 Scott Frankel wrote: =======

Still fooling around with sample code to see how wx works.

I've created a panel by subclassing wx.Panel. The panel is populated
with various controls that trigger events. The events are handled in
methods that are members of my panel subclass.

Then I instantiate a new app. I create a frame and call the frame's
CreateStatusBar() method.

Question: how do I pass text info from the panel's event handler methods
to the frame's status bar?

Thanks in advance!
Scott

Here's some code:

class Form1(wx.Panel):
def __init__(self, parent, id):
  wx.Panel.__init__(self, parent, id)

  # button
  self.button = wx.Button(self, 10, "Save", wx.Point(200, 325))
  wx.EVT_BUTTON(self, 10, self.OnClick)

def OnClick(self,event):
  self.logger.AppendText(" Click on object with Id %d\n" %event.GetId())
  
  # --> this doesn't work <--
  sbar = wx.StatusBar(None)
  sbar.SetStatusText('EvtRadioBox: %d\n' % event.GetInt())

app = wx.PySimpleApp()

# set frame parent, id, title, pos, size
frame = wx.Frame(None, -1, "Our first control", wx.Point(200, 100),
wx.Size(600, 400))
frame.CreateStatusBar()

# add panel, Form1, to frame
Form1(frame, -1)

# show frame & run main loop
frame.Show(1)
app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

.

= = = = = = = = = = = = = = = = = = = =
      
Bruce Who
HuXuZhao@hotmail.com
2005-03-11

Thanks for the suggestions! I'm still having trouble connecting the event handler
method in my pane subclass with the status bar in the frame subclass. i.e.:

class MainWindow(wx.Frame):
  def __init__(self, parent, id, title):

    # frame specs
    wx.Frame.__init__(self, parent, &c.)
    
    # status bar
    sbar = self.CreateStatusBar()
    self.SetStatusBar(sbar)
    
class Form1(wx.Panel):
  def __init__(self, parent, id):
    wx.Panel.__init__(self, parent, id)

    # button
    self.button = wx.Button(self, 10, "Save", wx.Point(200, 325))
    wx.EVT_BUTTON(self, 10, self.OnClick)

  def EvtRadioBox(self, event):
    # --> still no go <--
    sbar = MainWindow.GetStatusBar(MainWindow)
    sbar.SetStatusText('EvtRadioBox: %d\n' % event.GetInt())

app = wx.PySimpleApp()
frame = MainWindow(None, -1, "Bunch'a controls")
Form1(frame, -1)
frame.Show(1)
app.MainLoop()

Thanks again!
Scott

···

On Mar 10, 2005, at 5:24 PM, Bruce Who wrote:

Scott Frankel:

  I suggest you call frame.CreateStatusBar() in frame.__init__() and associate the statusbar to your frame with frame.SetStatusBar(), call GetStatusBar when you need it instead of creating a new one.

======= 2005-03-11 08:08:42 Scott Frankel wrote: =======

Still fooling around with sample code to see how wx works.

I've created a panel by subclassing wx.Panel. The panel is populated
with various controls that trigger events. The events are handled in
methods that are members of my panel subclass.

Then I instantiate a new app. I create a frame and call the frame's
CreateStatusBar() method.

Question: how do I pass text info from the panel's event handler methods
to the frame's status bar?

Thanks in advance!
Scott