wxpython sizer 错误
我不知道应该如何调整这个大小,我一直在尝试使用 sizer 但似乎我一直在做错事。
基本上我有这个代码:
self.button = wx.Button(self, label="Create New", pos=(25,250))
我想使用它的大小调整器。所以它会始终将其位置调整到窗口。初始起始位置为25、250。初始窗口高度为400。 我希望按钮能够根据窗口的变化进行相应调整。
谢谢,如果您有任何疑问或需要澄清,请发表评论。
I am not sure how I should size this, I have been trying to use sizer but it seems i am doing something wrong all the time.
Basically i have this code:
self.button = wx.Button(self, label="Create New", pos=(25,250))
and i would like to use a sizer with it. So it will adjust its position always to the window. The initial starting position is 25, 250. The height of the initial window is 400.
I would like the button to adjust accordingly to the window changes.
Thank you, please comment if you have any questions or need clarification.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一个 wxglade 自动生成的代码,展示了如何使用
wx.BoxSizer
。它只是一个带有面板小部件的框架。您可以使用按钮更改面板,它将完美运行。这个想法是,您可以添加其他小部件,就像在
wx.Panel
中所做的那样:这会使您的小部件位于一行中。如果您想要其他配置,您可以使用不同的 sizer,您还可以将带有小部件的 sizer 添加到其他 sizer。 sizer.Add() 中的参数确定 sizer 的边框和行为。您应该检查 wxPython/wxglade 文档。不管怎样,结构总是像下面这样:
Here you have a wxglade automatically-generated code showing how to use a
wx.BoxSizer
.It is simply a Frame with a panel widget. You can change the panel with your button and it will work perfectly. The idea is that you could add other widgets as it is done for the
wx.Panel
in:this produce your widgets being situated in a row. If you want another disposition you could use a different sizer, You can also add sizers with widgets to other sizers. The parameters in sizer.Add() determine the borders and behavior of the sizer. You should check wxPython/wxglade documentation for that. Anyway, the estructure is always like the one below: