wxWidgets 的间距/空边框 [英] Spacing/empty border for wxWidgets

查看:44
本文介绍了wxWidgets 的间距/空边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么东西可以用来在窗口边缘或带有 wxWidgets/wxPython 的组件之间添加空间?我想要一些东西来防止组件被挤压到窗口边框或彼此之间,类似于 Java Swing 的 EmptyBorder 或 Insets 可以做到的.(我知道您可以使用一些 sizer 设置水平/垂直间隙,但我想要更灵活的东西.)

Is there anything you can use to add space around the edges of a window or between components with wxWidgets/wxPython? I want something to prevent components from being squished up against the window border or each other, similar to what can be done with Java Swing's EmptyBorder or Insets. (I know you can set horizontal/vertical gaps with some sizers, but I'd like something more flexible.)

推荐答案

查看 Sizer 的 Add 方法中的边框参数.可以使用flag参数告诉它放置边框的位置,比如wx.ALL、wx.RIGHT、wx.LEFT、wx.TOP等

See the border parameter in the Sizer's Add method. You can use the flag parameter to tell it where to put the border, such as wx.ALL, wx.RIGHT, wx.LEFT, wx.TOP, etc.

这可用于在小部件周围和小部件之间放置空间.有时您可能想使用 sizer 的 AddSpacer 来添加空间.或者你可以这样做:

This can be used to put space around widgets and between widgets. Sometimes you might want to use the sizer's AddSpacer to add space. Or you can just do something like this:

mySizer.Add((20, 100))

这样做是在 y 轴上的两个小部件之间放置 100 像素.您可能需要稍微尝试一下才能按照您想要的方式获得它.

What that does is put 100 pixels between two widgets on the y axis. You'll probably have to play with it a bit to get it the way you want.

另见 http://wiki.wxpython.org/GridSizerTutorialhttp://zetcode.com/wxpython/layout/

这篇关于wxWidgets 的间距/空边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆