gpt4 book ai didi

python - 在 WxPython 中设置帧大小?

转载 作者:行者123 更新时间:2023-12-01 05:10:45 24 4
gpt4 key购买 nike

我对此非常陌生,所以如果这是显而易见的,我深表歉意。我正在使用示例代码(它运行正常):

class MainWindow(wx.Frame):
def __init__(self, parent, title):
self.dirname=''


# A "-1" in the size parameter instructs wxWidgets to use the default size.
# In this case, we select 200px width and the default height.
wx.Frame.__init__(self, parent, title=title, size=(1000,1000))
self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
self.CreateStatusBar() # A Statusbar in the bottom of the window

# Setting up the menu.
filemenu= wx.Menu()
menuOpen = filemenu.Append(wx.ID_OPEN, "&Open"," Open a file to edit")
menuAbout= filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program")
menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")

# Creating the menubar.
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar
self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content.

# Events.
self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen)
self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)

self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.buttons = []
for i in range(0, 6):
self.buttons.append(wx.Button(self, -1, "Button &"+str(i)))
self.sizer2.Add(self.buttons[i], 1, wx.EXPAND)

# Use some sizers to see layout options
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.control, 1, wx.EXPAND)
self.sizer.Add(self.sizer2, 0, wx.EXPAND)

#Layout sizers
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
self.Show()

我认为这就像更改 wx.Frame.init 中的“size =”值一样简单,但是当我更改时什么也没有发生。如何更改窗口大小?

此外,我如何告诉窗口在屏幕上的哪个位置打开?谢谢

最佳答案

我认为尺寸调整器正在改变你身上的窗口尺寸——毕竟,这就是他们所做的。注释掉之后的所有代码(包括

)
self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)

看看是否可以通过 init 方法更改窗口大小。

关于python - 在 WxPython 中设置帧大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24290118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com