我试图在一个面板中垂直居中CheckBox小部件。我无法弄清楚为什么它与顶部对齐。
我必须为CheckBox创建一个Panel,因为没有它,背景看起来很难看(Windows 10 - 见第二张图片)
感谢您的建议!
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.