如何使用 wxPython 以正确的大小打开 GUI? [英] How Do I Make a GUI Open with the Correct Size with wxPython?

查看:41
本文介绍了如何使用 wxPython 以正确的大小打开 GUI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调整窗口大小时遇到​​问题.首次打开 GUI 时,初始大小仅显示窗口中的一部分;太小了.存在滚动条,所以我可以获取信息,但我希望它以正确的大小打开,而不是必须对角拖动它以便所有信息都可见.此外,当扩大窗口大小时,按钮的外观会出现故障并且措辞变得像断断续续的一样.

I'm having trouble with the sizing of my window. When first opening the GUI, the initial size only shows a portion of what's in the window; its too small. Scroll bars are present so I can get to the information, but I want it to open with the correct size, rather than having to drag it diagonally so that all the information will be visible. Also, when expanding the window size, the appearance of the buttons glitches and the wording gets all choppy-like.

如何更改大小器/滚动以便初始窗口将打开到正确的大小并显示所有数据?

How can I change the sizers/scrolling so that the initial window will open to the correct size and all data will be shown?

下面列出了我的部分代码(为了简单起见,删除了很多信息),我知道表格不好,抱歉.谢谢您的帮助!

Part of my code is listed below (a lot of information removed for simplicity), I know the form is bad, sorry. Thanks for the help!

class Part_1(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'CR Part 1')
        global panel

        panel = ScrolledPanel(self)         

        # LAYOUT -----------------------------------------------------
        # Setting up different sizers
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(lbl, flag=wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL, border=10)

        staticbox = wx.StaticBoxSizer(wx.StaticBox(panel, wx.ID_ANY, u"Part 1: Initiation (completed by initiator)"), wx.VERTICAL)

        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox1.Add((20,20), 1)
        hbox1.Add(crnum)
        hbox1.Add((0,0), 1)
        hbox1.Add(crrev)
        hbox1.Add((20,20), 1)


        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2.Add((20,20), 1)
        hbox2.Add(attachBtn)  
        hbox2.Add((20,20), 1)   

        staticbox.Add(hbox2, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=25)

        # Add sizers to the the main panel sizer
        vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10) 
        vbox.Add(staticbox, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10) 
        panel.SetSizer(vbox)
        panel.SetupScrolling()```

推荐答案

创建 Frame 时只需添加大小:

Just add the size when creating the Frame:

wx.Frame.__init__(self, None, -1, 'CR Part 1', size=(800, 600))

这篇关于如何使用 wxPython 以正确的大小打开 GUI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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