Why is statusbar messing layout?

Hello,

When adding a statusbar, it messes the layout: The listbox and button are on top of each other.

Why is that? What’s the fix?

Thank you.

import wx
 
class ListBoxFrame(wx.Frame):
		def __init__(self, *args, **kwargs):
			super().__init__(None, -1, title="Statusbar messing layout")

			self.Centre()

			panel = wx.Panel(self, -1)

			sizer = wx.BoxSizer(wx.VERTICAL)

			#BAD!
			self.statusbar = self.CreateStatusBar()

			self.lb1 = wx.ListBox(panel, wx.ID_ANY, style=(wx.LB_SINGLE | wx.LB_ALWAYS_SB))
			sizer.Add(self.lb1,proportion=1, flag=wx.ALL | wx.EXPAND, border=5)

			self.dload_btn = wx.Button(panel, wx.ID_ANY, "Test")
			sizer.Add(self.dload_btn,proportion=0, flag=wx.EXPAND)
			self.dload_btn.Bind(wx.EVT_BUTTON, self.do_work)
		
			panel.SetSizer(sizer)

		def do_work(self, event):
			self.statusbar.SetStatusText("blah")

app = wx.App()
ListBoxFrame().Show()
app.MainLoop()

I am not seeing a problem running your code using wxPython 4.2.3 gtk3 (phoenix) wxWidgets 3.2.7 + Python 3.12.3 + Linux Mint 22.1

Does calling self.Layout() at the end of ListBoxFrame.__init__() help?

1 Like

Yes, thank you.

...
panel.SetSizer(sizer)
#NO CHANGE self.Layout()
panel.Layout()