Hi All,
I'm having some difficulties understanding wx.ALIGN_CENTER_VERTICAL.
I'm trying to get text to center horizontally (this works well with
wx.ALIGN_CENTER) and vertically in a box with a wx.SIMPLE_BORDER. I
can't seem to get the vertical-centering part to work.
Here's my sample code:
===SAMPLE BELOW===
#!/usr/bin/env python
import wx
class MainApp(wx.App):
def OnInit(self):
self.frame = wx.Frame(None, wx.ID_ANY, size=((400,400)))
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.textItem = wx.StaticText(parent=self.frame, label="THIS IS A
LABEL.", size=((200,50)), pos=((100,100)), style=wx.ALIGN_CENTER|
wx.SIMPLE_BORDER)
self.textItem.SetBackgroundColour(wx.WHITE)
self.textItem.SetForegroundColour(wx.BLACK)
self.vbox.Add(item=self.textItem, flag=wx.ALIGN_CENTER_VERTICAL)
self.frame.SetSizer(self.vbox)
self.frame.Show()
self.frame.Refresh()
return True
if __name__ == '__main__':
app = MainApp(False)
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()
===SAMPLE ABOVE===
When I use the inspection tool (I learned from last time! ) I can
see that the flag wx.ALIGN_CENTER_VERTICAL is applied to the Static
Text item as a Sizer Item, but it does not align in the center
vertically - only horizontally.
(To be clear, I am trying to get the text to center both horizontally
and vertically in the box. That the positioning of the box doesn't
seem to work is ok for this. (That is, unless that's part of the
problem.))
What (likely very obvious?) thing am I missing?
Thanks in advance!