wxStatusBar - why expand the frame ?

Hi !

When I put a statusbar into frame, it was expand the frame, and I
cannot descrease it's width !

Why ?

class MainFrame(wxFrame):
    def __init__(self, parent, id):
        ''' Local '''
        selfcolor="LIGHT GRAY"
        self.ProcThread=None
        wxFrame.__init__(self,parent,id,'GNeurolotto')
        ''' Idle '''
        EVT_IDLE(self,self.OnIdle)
        EVT_IDLE(self,self.OnIdle)
        EVT_CLOSE(self, self.CloseIt)
        self.SetBackgroundColour(selfcolor)
        ''' Options '''
        txt1=wxStaticText(self,-1,'Week count')
        txt1.SetBackgroundColour(selfcolor)
        txt2=wxStaticText(self,-1,'Succ count')
        txt2.SetBackgroundColour(selfcolor)
        txt3=wxStaticText(self,-1,'Break count')
        txt3.SetBackgroundColour(selfcolor)
        self.spin_w=wxSpinCtrl(self,-1,"1")
        self.spin_w.SetRange(1, 100);
        self.spin_w.SetValue(1)
        self.spin_s=wxSpinCtrl(self,-1,"1")
        self.spin_s.SetRange(1,5);
        self.spin_s.SetValue(1)
        self.spin_b=wxSpinCtrl(self,-1,"1000000")
        self.spin_b.SetRange(1, 1000000);
        self.spin_b.SetValue(1)
        box_opts=wxGridSizer(3,2)
        box_opts.AddMany([
         (txt1,0,wxEXPAND|wxALL,4),
         (self.spin_w,0,wxEXPAND|wxALL,4),
         (txt2,0,wxEXPAND|wxALL,4),
         (self.spin_s,0,wxEXPAND|wxALL,4),
         (txt3,0,wxEXPAND|wxALL,4),
         (self.spin_b,0,wxEXPAND|wxALL,4)])
        # Buttons
        self.btn_start = wxButton(self, ID_START, 'Start')
        EVT_BUTTON(self, ID_START, self.onStartClick)
        self.btn_stop = wxButton(self, ID_STOP, 'Stop')
        self.btn_stop.Enable(False)
        EVT_BUTTON(self, ID_STOP, self.onStopClick)
        self.btn_close = wxButton(self, ID_CLOSE, 'Close')
        EVT_BUTTON(self, ID_CLOSE, self.onCloseClick)
        box_btns=wxBoxSizer(wxHORIZONTAL)
        box_btns.Add(self.btn_start,1,wxEXPAND|wxALL,8)
        box_btns.Add(self.btn_stop,1,wxEXPAND|wxALL,8)
        box_btns.Add(self.btn_close,1,wxEXPAND|wxALL,8)
        # Client
        self.memo=wxTextCtrl(self,-1,size=(200, 100),
style=wxTE_MULTILINE|wxTE_READONLY)
        box_clts=wxBoxSizer(wxVERTICAL)
        box_clts.Add(self.memo,1,wxEXPAND|wxALL,8)
        # Layout
        panelbox = wxBoxSizer(wxVERTICAL)
        panelbox.Add(box_opts, 0, wxEXPAND)
        panelbox.Add(box_btns, 0, wxEXPAND)
        panelbox.Add(box_clts, 1, wxEXPAND|wxBOTTOM)
        self.sb=wxStatusBar(self)
        self.sb.SetFieldsCount(3)
        self.sb.SetStatusWidths([10, 10, 10])
        panelbox.Add(self.sb,0,wxEXPAND)
        self.SetSizer(panelbox)
        self.SetAutoLayout(true)
        panelbox.Fit(self)
        panelbox.SetSizeHints(self)
        self.SetSize(wxSize(300,400))
        self.Centre()

        #self.Show(true)
        #self.Width=400
        #self.Height=500
        # Datas
        # IDLE !

    def OnIdle(self, event):
        if (self.ProcThread<>None):
           info=self.ProcThread.GetInfo()
           if (info<>''):

              if (self.memo.GetLastPosition()>3000):
                 self.memo.Remove(0,1500)
              self.memo.AppendText(info+"\n")
              #self.sb.SetStatusText("Last:
"+str(self.memo.GetLastPosition()))
        event.RequestMore()

    def StartIt(self):
        if (self.ProcThread==None) :
          self.memo.AppendText("Starting...\n")
          self.btn_start.Enable(False)
          self.spin_w.Enable(False)
          self.spin_b.Enable(False)
          self.spin_s.Enable(False)
          self.btn_stop.Enable(True)
          self.ProcThread=ProcThread([])
          self.memo.AppendText("Started\n")

    def onStartClick(self, event):
        self.StartIt()

    def StopIt(self):
        if (self.ProcThread<>None):
          self.memo.AppendText("Stopping...\n")
          self.ProcThread.Aborted=True
          while (not self.ProcThread.Ended): pass
          self.ProcThread=None
          self.memo.AppendText("Stopped\n")

    def CloseIt(self,event):
        self.memo.AppendText("Closing...")
        if (self.ProcThread<>None):
          self.btn_start.Enable(False)
          self.btn_stop.Enable(False)
          self.StopIt()
        self.Destroy()

    def onStopClick(self, event):
        if (self.ProcThread<>None):
          self.StopIt()
          self.btn_start.Enable(True)
          self.btn_stop.Enable(False)
          self.spin_w.Enable(True)
          self.spin_b.Enable(True)
          self.spin_s.Enable(True)

    def onCloseClick(self, event):
        self.btn_start.Enable(False)
        self.btn_stop.Enable(False)
        self.StopIt()
        self.Destroy()

class MainApp(wxApp):
    def OnInit(self):
        self.frame = MainFrame(NULL,-1)
        self.frame.Show(true)
        self.SetTopWindow(self.frame)
        return true

if __name__ == '__main__':
    app = MainApp(0)
    app.MainLoop()

I think it is becasue you are adding the status bar as an element in a
sizer. What you should do is call:
self.SetStatusBar(self.sb)
instead of panelbox.Add(self.sb,0,wxEXPAND)

Sam

Quoting Krisztian Kepes <Kepes.Krisztian@peto.hu>:

···

Hi !

When I put a statusbar into frame, it was expand the frame, and I
cannot descrease it's width !

Why ?

class MainFrame(wxFrame):
    def __init__(self, parent, id):
        ''' Local '''
        selfcolor="LIGHT GRAY"
        self.ProcThread=None
        wxFrame.__init__(self,parent,id,'GNeurolotto')
        ''' Idle '''
        EVT_IDLE(self,self.OnIdle)
        EVT_IDLE(self,self.OnIdle)
        EVT_CLOSE(self, self.CloseIt)
        self.SetBackgroundColour(selfcolor)
        ''' Options '''
        txt1=wxStaticText(self,-1,'Week count')
        txt1.SetBackgroundColour(selfcolor)
        txt2=wxStaticText(self,-1,'Succ count')
        txt2.SetBackgroundColour(selfcolor)
        txt3=wxStaticText(self,-1,'Break count')
        txt3.SetBackgroundColour(selfcolor)
        self.spin_w=wxSpinCtrl(self,-1,"1")
        self.spin_w.SetRange(1, 100);
        self.spin_w.SetValue(1)
        self.spin_s=wxSpinCtrl(self,-1,"1")
        self.spin_s.SetRange(1,5);
        self.spin_s.SetValue(1)
        self.spin_b=wxSpinCtrl(self,-1,"1000000")
        self.spin_b.SetRange(1, 1000000);
        self.spin_b.SetValue(1)
        box_opts=wxGridSizer(3,2)
        box_opts.AddMany([
         (txt1,0,wxEXPAND|wxALL,4),
         (self.spin_w,0,wxEXPAND|wxALL,4),
         (txt2,0,wxEXPAND|wxALL,4),
         (self.spin_s,0,wxEXPAND|wxALL,4),
         (txt3,0,wxEXPAND|wxALL,4),
         (self.spin_b,0,wxEXPAND|wxALL,4)])
        # Buttons
        self.btn_start = wxButton(self, ID_START, 'Start')
        EVT_BUTTON(self, ID_START, self.onStartClick)
        self.btn_stop = wxButton(self, ID_STOP, 'Stop')
        self.btn_stop.Enable(False)
        EVT_BUTTON(self, ID_STOP, self.onStopClick)
        self.btn_close = wxButton(self, ID_CLOSE, 'Close')
        EVT_BUTTON(self, ID_CLOSE, self.onCloseClick)
        box_btns=wxBoxSizer(wxHORIZONTAL)
        box_btns.Add(self.btn_start,1,wxEXPAND|wxALL,8)
        box_btns.Add(self.btn_stop,1,wxEXPAND|wxALL,8)
        box_btns.Add(self.btn_close,1,wxEXPAND|wxALL,8)
        # Client
        self.memo=wxTextCtrl(self,-1,size=(200, 100),
style=wxTE_MULTILINE|wxTE_READONLY)
        box_clts=wxBoxSizer(wxVERTICAL)
        box_clts.Add(self.memo,1,wxEXPAND|wxALL,8)
        # Layout
        panelbox = wxBoxSizer(wxVERTICAL)
        panelbox.Add(box_opts, 0, wxEXPAND)
        panelbox.Add(box_btns, 0, wxEXPAND)
        panelbox.Add(box_clts, 1, wxEXPAND|wxBOTTOM)
        self.sb=wxStatusBar(self)
        self.sb.SetFieldsCount(3)
        self.sb.SetStatusWidths([10, 10, 10])
        panelbox.Add(self.sb,0,wxEXPAND)
        self.SetSizer(panelbox)
        self.SetAutoLayout(true)
        panelbox.Fit(self)
        panelbox.SetSizeHints(self)
        self.SetSize(wxSize(300,400))
        self.Centre()

        #self.Show(true)
        #self.Width=400
        #self.Height=500
        # Datas
        # IDLE !

    def OnIdle(self, event):
        if (self.ProcThread<>None):
           info=self.ProcThread.GetInfo()
           if (info<>''):

              if (self.memo.GetLastPosition()>3000):
                 self.memo.Remove(0,1500)
              self.memo.AppendText(info+"\n")
              #self.sb.SetStatusText("Last:
"+str(self.memo.GetLastPosition()))
        event.RequestMore()

    def StartIt(self):
        if (self.ProcThread==None) :
          self.memo.AppendText("Starting...\n")
          self.btn_start.Enable(False)
          self.spin_w.Enable(False)
          self.spin_b.Enable(False)
          self.spin_s.Enable(False)
          self.btn_stop.Enable(True)
          self.ProcThread=ProcThread()
          self.memo.AppendText("Started\n")

    def onStartClick(self, event):
        self.StartIt()

    def StopIt(self):
        if (self.ProcThread<>None):
          self.memo.AppendText("Stopping...\n")
          self.ProcThread.Aborted=True
          while (not self.ProcThread.Ended): pass
          self.ProcThread=None
          self.memo.AppendText("Stopped\n")

    def CloseIt(self,event):
        self.memo.AppendText("Closing...")
        if (self.ProcThread<>None):
          self.btn_start.Enable(False)
          self.btn_stop.Enable(False)
          self.StopIt()
        self.Destroy()

    def onStopClick(self, event):
        if (self.ProcThread<>None):
          self.StopIt()
          self.btn_start.Enable(True)
          self.btn_stop.Enable(False)
          self.spin_w.Enable(True)
          self.spin_b.Enable(True)
          self.spin_s.Enable(True)

    def onCloseClick(self, event):
        self.btn_start.Enable(False)
        self.btn_stop.Enable(False)
        self.StopIt()
        self.Destroy()

class MainApp(wxApp):
    def OnInit(self):
        self.frame = MainFrame(NULL,-1)
        self.frame.Show(true)
        self.SetTopWindow(self.frame)
        return true

if __name__ == '__main__':
    app = MainApp(0)
    app.MainLoop()

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