wxpython - 需要调整 GUI 的帮助
正在编写一个程序(在这里找到,文件较长,因此将它们发布在这里会占用很多空间) 。我的问题是 gui_step_1.py 的主面板偏离了它应该在的中心位置。
我已经尝试了很多事情,包括将其添加到 sizer 中以理顺它,但由于我的程序结构(MVC),我无法做到这一点,因为我在 gui_step_1.py 中实例化 controller
和controller
不继承panel、frame或者任何与wx相关的东西(只是一个普通的类)。
一旦你看到我的程序,我需要的就很明显了:我需要以窗口为中心的 step1
(gui_step_1.py 中的 controller
实例)。
感谢您的帮助!
Working on a program (found here, the files are longer, so posting them here would take up much space). My problem with it is that the main panel of gui_step_1.py is way off center from where it should be.
I have tried numerous things, including adding it to a sizer to straighten it out, but because of my program structure (MVC) I can't do that because I instantiate controller
in gui_step_1.py and controller
does not inherit panel, frame, or anything related to wx (just a normal class).
What I need is pretty obvious once you see my program: I need step1
(instance of controller
in gui_step_1.py) centered on the window.
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有对所有内容进行排序,但我认为
gui_step_1.py
中controller
类中的self.v.Center()
正在重新定位面板位于其框架内,而不是使框架居中。摆脱它,一切似乎都井井有条。如果您想将面板添加到 sizer,您可能必须从controller
类中检索它。不过,您在界面上遇到的问题更多的是设计问题的症状。您的视图框架创建两个不同类的实例,这两个类创建作为框架子级的小部件的实例。尽管您尝试使用 MVC,但它不应该改变向框架添加小部件的方式。
I didn't sort through everything, but I think
self.v.Center()
in yourcontroller
class ingui_step_1.py
is repositioning a Panel within its Frame instead of centering the Frame. Get rid of that, and things seem to line up properly. If you want to add the panel to a sizer, you'll probably have to retrieve it from thecontroller
class.The trouble you're having with the interface is more a symptom of a design problem, though. Your view frame creates instances of two different classes, which create instances of widgets which are children of the frame. Although you're trying to use MVC, it shouldn't be changing the way you add a widget to a frame.