I am trying to center a CheckBox widget vertically inside a panel. I cannot figure out why it's aligned to the top.
I had to create a Panel for the CheckBox because without that the background looks ugly (Windows 10 -- see second image)
Thanks for suggestions!
class wxUIE(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, size=(800, 400), title=title)
self.editorText = wx.TextCtrl (self, style=wx.TE_MULTILINE+wx.SUNKEN_BORDER+wx.TE_BESTWRAP)
self.myBar = wx.TextCtrl (self, -1)
# Checkbox
self.myCheckBoxPanel = wx.Panel(self, size=(-1, 25))
self.myCheckBox = wx.CheckBox(self.myCheckBoxPanel, label="Highlight", style=wx.ALIGN_CENTER_VERTICAL)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.sizer.Add(self.editorText, 1, wx.EXPAND)
self.sizer.Add(self.sizer2, 0, wx.EXPAND)
self.sizer2.Add(self.myBar, 10, wx.EXPAND)
self.sizer2.Add(self.myCheckBoxPanel, 0, wx.EXPAND)
self.SetSizeHints(800,400)
self.SetSizer(self.sizer)
self.SetAutoLayout(True)
self.Show()
# Run the program
if __name__ == "__main__":
app = wx.App(False)
frame = wxUIE(None, "My Edit Control")
frame.Show()
app.MainLoop()
CheckBox aligned to top of panel
CheckBox is aligned vertically correctly but the background sucks.
Aucun commentaire:
Enregistrer un commentaire