wxPython:嵌套 GridBagSizer 不跨越?
我在现有的 GridBagSizer (sizer) 中有一个 GridBagSizer (folderBagSizer)...现在我尝试用一些标签填充嵌套的 sizer (folderBagSizer)。他们出现在尺寸测量器下面......?
# Create static box
self.sb_ExtractOptions = wx.StaticBox(panel, label="Options for Extract",
size=(100,100))
folderBoxSizer = wx.GridBagSizer(4, 9)
folderBoxSizer.Add(self.sb_ExtractOptions, pos=(0,0), span=(1,4),
flag=wx.EXPAND, border=10)
# Create the options
label_OptionsCreated = wx.StaticText(panel, label="Created:")
label_OptionsInserted = wx.StaticText(panel, label="Inserted:")
label_OptionsModified = wx.StaticText(panel, label="Modified:")
# Add them to the sizer (folderBoxSizer)
folderBoxSizer.Add(label_OptionsCreated, pos=(1, 0), flag=wx.LEFT|
wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=3)
folderBoxSizer.Add(label_OptionsInserted, pos=(2, 0), flag=wx.LEFT|
wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=3)
folderBoxSizer.Add(label_OptionsModified, pos=(3, 0), flag=wx.LEFT|
wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=3)
folderBoxSizer.AddGrowableCol(2)
sizer.Add(folderBoxSizer, pos=(2, 0), span=(1,6),flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=10)
sizer.AddGrowableCol(2)
panel.SetSizer(sizer)
提前致谢。 :)
I've g0t a GridBagSizer (folderBagSizer)within an existing GridBagSizer (sizer)... now I am trying to populate the nested sizer (folderBagSizer) with some labels. They are showing up UNDER the sizers...?
# Create static box
self.sb_ExtractOptions = wx.StaticBox(panel, label="Options for Extract",
size=(100,100))
folderBoxSizer = wx.GridBagSizer(4, 9)
folderBoxSizer.Add(self.sb_ExtractOptions, pos=(0,0), span=(1,4),
flag=wx.EXPAND, border=10)
# Create the options
label_OptionsCreated = wx.StaticText(panel, label="Created:")
label_OptionsInserted = wx.StaticText(panel, label="Inserted:")
label_OptionsModified = wx.StaticText(panel, label="Modified:")
# Add them to the sizer (folderBoxSizer)
folderBoxSizer.Add(label_OptionsCreated, pos=(1, 0), flag=wx.LEFT|
wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=3)
folderBoxSizer.Add(label_OptionsInserted, pos=(2, 0), flag=wx.LEFT|
wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=3)
folderBoxSizer.Add(label_OptionsModified, pos=(3, 0), flag=wx.LEFT|
wx.ALIGN_CENTER_VERTICAL|wx.TOP, border=3)
folderBoxSizer.AddGrowableCol(2)
sizer.Add(folderBoxSizer, pos=(2, 0), span=(1,6),flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, border=10)
sizer.AddGrowableCol(2)
panel.SetSizer(sizer)
Thanks in advance. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了,当然,完全是菜鸟逻辑问题。
我最初将静态框的大小调整器添加到错误的大小调整器中 - 它需要工作的方式是:
sizer 将位于其中,在本例中为 StaticBoxSizer。
(sbs_ExtractOptions)
在 sizer (OptionBoxSizer) 中
将它们添加到 OptionBoxSizer
StaticBoxSizer(即将步骤 4 中所做的操作添加到步骤 2 中)
将 StaticBoxSizer 添加到面板的主大小调整器(在本例中为大小调整器)
非常注意你在做什么!
Figured it out, and of course, total noob logic problem.
I was adding the sizer for the static box to the wrong sizer initially -- the way it needs to work is to:
sizer that will live within it, in this case a StaticBoxSizer.
(sbs_ExtractOptions)
within the sizer (OptionBoxSizer)
them to OptionBoxSizer
StaticBoxSizer (i.e. add what you did in step 4 to step 2)
the StaticBoxSizer to the panel's main sizer (sizer, in this case)
paying freaking attention to what you are doing!