【发布时间】:2009-12-12 03:00:25
【问题描述】:
我无法弄清楚如何让 wxPython 中的 sizer 按我希望的方式工作(除此之外:我是唯一一个认为 wxPython 记录不充分的人吗?)。我有 4 个按钮和一个 textctrl,我想像这样安排:
==============================================
|WINDOW TITLE _ [] X|
|============================================|
|Button1 | Button2 | Button3 | Button4|
|--------------------------------------------|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxTextCtrlxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
==============================================
按钮应该水平扩展,而不是垂直扩展,并且 textctrl 应该水平和垂直扩展。我已经尝试了 wxPython 演示程序中列出的几乎所有尺寸器,但它们都不起作用 - 多个 boxsizer、gridsizers + boxsizeres、plain gridsizer、flexgridsizer 和 rowcolsizer,但它们都不起作用,有人可以帮忙吗?作为参考,这是我现在得到的代码。
...snip...
panel = wx.Panel(self, -1)
select_file = wx.Button(panel, self.BUTTON_0, "Select File")
button1 = wx.Button(panel, self.BUTTON_1, "250 Words")
button2 = wx.Button(panel, self.BUTTON_2, "500 Words")
button3 = wx.Button(panel, self.BUTTON_3, "750 Words")
self.txt = wx.TextCtrl(panel, -1, "", style=wx.TE_MULTILINE | wx.TE_READONLY)
# Now to re-do this with gridsizers instead.
# 4 rows, 4 columns, 2 pixel gap horizontally and vertically.
grid = rcs.RowColSizer()
# These buttons need to expand to fill their space, and then
# expand when the windows are resized.
grid.Add( select_file, row=1, col=1 )
grid.Add( button1, row=1, col=2 )
grid.Add( button2, row=1, col=3 )
grid.Add( button3, row=1, col=4 )
grid.Add( self.txt, row=2, col=1 )
...snip...
【问题讨论】:
标签: wxpython