如何在 Vertical BoxSizer 中设置间隙?
如何在 Vertical BoxSizer 中设置间隙? Vertival BoxSizer 中与 GridSizer 中的 SetVGap
(设置 sizer 中单元格之间的垂直间隙(以像素为单位))的类似或替代方法是什么?
How can I set gap in Vertical BoxSizer? What's in the Vertival BoxSizer the similar or alternative method of SetVGap
(which sets the vertical gap (in pixels) between the cells in the sizer) in GridSizer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有多种方法可以在尺寸调整器中添加空白区域。
上面的代码将添加所有边都有 5 像素边框的小部件。如果您想在两个小部件之间放置一些空间,您可以执行以下操作之一:
执行 sizer.Add((0,0)) 的好处是,您可以按 1(一)的比例添加它,如果您想要,这会将所有以下小部件推到底部。我用它来更好地控制小部件的放置。
另请参阅http://www.wxpython.org/docs/api/wx.Sizer-class。 html
There are several ways to add blank space in a sizer.
The code above will add the widget with a 5 pixel border on all sides of it. If you want to put some space between two widgets, you can do one of the following:
The nice thing about doing sizer.Add((0,0)) is that you can add it with a proportion of 1 (one) if you want and that will push all the following widgets to the bottom. I use it to give me a little more control over widget placement.
See also http://www.wxpython.org/docs/api/wx.Sizer-class.html
我假设你的意思是一个垂直框大小调整器,如下所示
以下调用将
在Python中添加10个像素的“垂直间隙”,我想它看起来像这样
I assume you mean a vertical box sizer, like so
The following call will add 10 pixels of 'vertical gap'
In Python, I guess it would look something like this
wx.BoxSizer
中没有间隙参数(正如您所说,GridSizers 中是否有)。创建间隙的方法是在小部件中设置边框。这可以通过以下样式来完成:wx.ALL
、wx.BOTTOM
和/或wx.TOP
。例如:
将在顶部和底部带有 5 点边框的框中添加一个居中的小部件(我的代码中的一个按钮)。
如果您这样写,则显示:
您会得到 3 个有间隙的按钮,类似于使用
SetVGap
所获得的效果,并且您还可以通过设置 vgap 来控制插槽之间的间隔。正如其他答案所示,您也可以在小部件之间插入分隔符以获得相同的效果,但在我看来,如果您想要相当于网格 vgap 的东西,这似乎更干净(没有额外的“sizer.add”行)。
There is no gap parameter in
wx.BoxSizer
s (do there is in GridSizers as you said). The way to create a gap is by setting the border in your widgets. This can be done with the styles:wx.ALL
,wx.BOTTOM
and/orwx.TOP
.For example:
will add a centered widget (a button in my code) in the Box with 5-points border at the top and bottom.
Show if you write:
you get 3 buttons gapped similarly to what you would have with
SetVGap
and you can aswell control the separation between slots by setting vgap.As other answers indicate you can also insert separators between your widgets to obtain the same effect but this seems to me cleaner (no addditional "sizer.add" lines) if what you want is something equivalent to grids vgap.
中找到标题“wx.BoxSizer”
可能也很有趣:在http://zetcode.com/wxpython/layout/
May also be interesting : find the title "wx.BoxSizer" in
http://zetcode.com/wxpython/layout/