I’m using a the SizedPanel class from
wx.lib.sized_controls on macOS (Sierra 10.12) and can’t seem to
get children objects to align vertically.
The code snippet below has 3 panes in a vertical sized panel.
header and footer pane are fixed in size (i.e. do not expand), but
the header pane does. I can get the static text object to align
horizontally (e.g. center) but I can’t get it to align vertically
(e.g. center). The text always remains at the top of the pane.
Am I doing something wrong?
Or is there a problem with vertical alignment on macOS perhaps?
Thanks, Brendan.
···
`import wx``
``import wx.lib.sized_controls as wxSC`` `` ``##============================================================================`` `` ``class wxServicePanel(wxSC.SizedPanel):`` `` def __init__(self, parent):`` `` super().__init__(parent)`` `` `` pane = self`` `` pane.SetSizerType("vertical")`` `` #pane.SetSizerType("horizontal")`` `` #pane.SetBackgroundColour("grey")`` `` self.pane = pane`` `` `` ## Row 1`` `` header_pane = self.header_pane =
wxSC.SizedPanel(pane)``
`` wx.StaticText(header_pane,
label=“header_pane”)``
`` header_pane.Fit()`` `` header_pane.SetMinSize(header_pane.GetSize())`` `` `` ## Row 2`` `` main_pane = self.main_pane =
wxSC.SizedPanel(pane)``
`` main_pane.SetBackgroundColour("white")`` `` st = wx.StaticText(main_pane,
label=“main_pane”)``
`` st.SetSizerProps(align='center')`` `` #st.SetSizerProps(valign='bottom')`` `` #st.SetSizerProps(valign='center',
halign=‘center’)``
`` #st.SetSizerProps(align='center',
expand=True, proportion=1)``
`` main_pane.SetSizerProps(align='center')`` `` #main_pane.SetSizerProps(align='center',
expand=True)``
`` #main_pane.SetSizerProps(expand=True,
proportion=1)``
`` #main_pane.SetSizerProps(align='center',
expand=True, proportion=1)``
`` main_pane.Fit()`` `` main_pane.SetMinSize(main_pane.GetSize())`` `` `` ## Row 3`` `` footer_pane = self.footer_pane =
wxSC.SizedPanel(pane)``
`` st = wx.StaticText(footer_pane,
label=“footer_pane”)``
`` #st.SetSizerProps(halign='right')`` `` footer_pane.Fit()`` `` footer_pane.SetMinSize(footer_pane.GetSize())`` `` footer_pane.SetSizerProps(halign='right')`` `` `` ## ensure can't resize dialog to less screen
space than the controls need``
`` self.Fit()`` `` self.SetMinSize(self.GetSize())`` `` ``##============================================================================`