Having a sizer problem; why does my wxPython window layout look fine when sizing larger, but break when sizing smaller?

70 Views Asked by At

I'm trying to lay out a window with a 3:1 height ratio for a wx.grid.Grid (3) and a wx.Button (1). This sounds like a job for a BoxSizer! So I wrote this:

frame = wx.Frame(None, title="Hello World")
sizer = wx.BoxSizer(wx.VERTICAL)
grid = sudoku_9x9grid(frame)
sizer.Add(grid, 3, wx.EXPAND, 8)
button = wx.Button(frame, label="GO BUTTON")
sizer.Add(button, 1, wx.SHAPED | wx.ALIGN_CENTER)

# Show it.
frame.SetSizerAndFit(sizer)
frame.Show()

# Start the event loop.
app.MainLoop()

It works as intended when I'm dragging the window larger: What it's supposed to do

But when I drag the window smaller, the sizer doesn't maintain the height ratio I intended: The button got shrunk

I'm sure I'm doing something wrong setting flags to the Sizer, but I haven't figured out what. Any suggestions?

0

There are 0 best solutions below