wxpython GridBagSizer问题
每当我在 GridBagSizer 中使用 span 时,我都会遇到问题,这是我的代码:
hbox3.Add(arrangeLabel)
hbox3.Add(self.arrangeComboBox, flag=wx.LEFT, border=10)
sizer.Add(hbox3, pos=(7,0), span=(7,3), flag=wx.ALL, border=15)
#######################
hbox4 = wx.BoxSizer(wx.HORIZONTAL)
runButton = wx.Button(panel, -1, label='Run', size=(50,25))
saveButton = wx.Button(panel, -1, label='Save', size=(50,25))
cancelButton = wx.Button(panel, -1, label = 'Cancel', size=(50,25))
hbox4.Add(runButton)
hbox4.Add(saveButton, flag=wx.LEFT, border=10)
hbox4.Add(cancelButton, flag=wx.LEFT, border=10)
sizer.Add(hbox4, pos=(8,0), flag=wx.ALIGN_CENTER_HORIZONTAL)
sizer.AddGrowableCol(1)
panel.SetSizer(sizer)
在第三行,我的 hbox3 范围从 7,0 到 7,3。这在某种程度上影响了我的第 8 行,我的第 8 行将消失在窗户的角落里。即使我将 pos=(8,0) 更改为 pos=(9,0) 我仍然遇到同样的问题。我解决这个问题的唯一方法是去掉span=(7,3),这使得我的GUI看起来非常难看。
我这里有什么问题吗?
when ever I use span in GridBagSizer I get a problem, here's my code:
hbox3.Add(arrangeLabel)
hbox3.Add(self.arrangeComboBox, flag=wx.LEFT, border=10)
sizer.Add(hbox3, pos=(7,0), span=(7,3), flag=wx.ALL, border=15)
#######################
hbox4 = wx.BoxSizer(wx.HORIZONTAL)
runButton = wx.Button(panel, -1, label='Run', size=(50,25))
saveButton = wx.Button(panel, -1, label='Save', size=(50,25))
cancelButton = wx.Button(panel, -1, label = 'Cancel', size=(50,25))
hbox4.Add(runButton)
hbox4.Add(saveButton, flag=wx.LEFT, border=10)
hbox4.Add(cancelButton, flag=wx.LEFT, border=10)
sizer.Add(hbox4, pos=(8,0), flag=wx.ALIGN_CENTER_HORIZONTAL)
sizer.AddGrowableCol(1)
panel.SetSizer(sizer)
on the third line, i have my hbox3 spanning from 7,0 to 7,3. This is somehow affecting my 8th row, my 8th row will disappear into the corner of the window. Even if I change pos=(8,0) to pos=(9,0) I still get the same problem. The only way I can solve it is to take away the span=(7,3), which makes my GUI look very ugly.
What is my problem here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您误解了
span
参数。span=(7,3)
告诉 sizer 将小部件从起始位置拉伸到 7 行 3 列。如果您希望它涵盖 7,0 到 7,3,请尝试span=(1,4)
。I think you're misunderstanding the
span
argument.span=(7,3)
is telling the sizer to stretch the widget across 7 rows and 3 columns from its starting position. If you want it to cover 7,0 to 7,3, tryspan=(1,4)
.