我试图找出一种水平显示复选框的方法。也许有一种在 sizers 内使用定位的方法。
□一□二□三
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,wx.ID_ANY,title='test chkBx')
self.hbox = wx.BoxSizer()
self.vbox= wx.BoxSizer(wx.VERTICAL)
self.background = wx.Panel(self)
choices = ['one', 'two', 'three']
self.chkBx = wx.CheckListBox(self, choices=choices)
self.bottomview = wx.TextCtrl(self,
style=wx.TE_MULTILINE|wx.TE_RICH|wx.BORDER_SIMPLE)
hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
hsizer1.Add(self.chkBx,1,flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.EXPAND)
hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
hsizer2.Add(self.bottomview,1,flag = wx.EXPAND)
self.vbox.Add(hsizer1,proportion = 2,flag = wx.EXPAND)
self.vbox.Add(hsizer2,proportion = 8,flag = wx.EXPAND)
self.SetSizer(self.vbox)
self.Show()
app = wx.App(redirect=False)
frame = MainFrame()
app.MainLoop()
这将具有我想要的外观。但是我的选择列表只有“三个”。
choices = ['one']
self.chkBx1 = wx.CheckListBox(self, choices=choices)
choices = ['two']
self.chkBx2 = wx.CheckListBox(self, choices=choices)
choices = ['three']
self.chkBx3 = wx.CheckListBox(self, choices=choices)
self.bottomview = wx.TextCtrl(self,
style=wx.TE_MULTILINE|wx.TE_RICH|wx.BORDER_SIMPLE)
hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
hsizer1.Add(self.chkBx1,1,flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.EXPAND)
hsizer1.Add(self.chkBx2,1,flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.EXPAND)
hsizer1.Add(self.chkBx3,1,flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.EXPAND)