gpt4 book ai didi

python - GUI 窗口未按指示调整大小

转载 作者:太空宇宙 更新时间:2023-11-03 20:40:09 25 4
gpt4 key购买 nike

我在面板中设置了大小,但当我运行程序时它没有采取任何行动。它只是弹出很小,我必须手动调整大小。

我尝试过设置/初始化框架,但是当我这样做时,它会阻止任何输入。所以我不能再使用我的程序了。我也多次尝试在面板设置中进行设置。

class CipherTexter(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, size=(5000, 5000))
#wx.Frame.__init__(self, parent, size=(5000, 5000))
self.cipherText = wx.StaticText(self, label="Cipher Texter ", pos=(20, 30))

app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "The SS Cipher")
panel = CipherTexter(frame)
frame.Show()
app.MainLoop()

当我第一次打开应用程序时,我得到了这个。我希望能够看到整个内容,而不必手动调整它的大小。 enter image description here

最佳答案

尝试将“面板”放入“框架”内。
我认为这是您所需的起点的模型。

import wx

class CipherTexter(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(1000, 600))
self.panel = wx.Panel(self)
cipherText = wx.StaticText(self.panel, label="Cipher Texter ", pos=(20, 30))
encryptorText = wx.StaticText(self.panel, label="Encryptor ", pos=(20, 70))
decryptorText = wx.StaticText(self.panel, label="Decryptor ", pos=(20, 100))
self.cipher = wx.TextCtrl(self.panel, -1, style=wx.TE_MULTILINE, size=(400,400), pos=(400, 30))
self.encryptor = wx.TextCtrl(self.panel, -1, size=(100,30), pos=(200, 70))
self.decryptor = wx.TextCtrl(self.panel, -1, size=(100,30), pos=(200, 100))
self.encrypt = wx.Button(self.panel, -1, "Encrypt", pos=(20, 140))
self.decrypt = wx.Button(self.panel, -1, "Decrypt", pos=(20, 180))
self.panel.SetBackgroundColour('white')
self.encrypt.Bind(wx.EVT_BUTTON, self.encryptNow)
self.decrypt.Bind(wx.EVT_BUTTON, self.decryptNow)
self.Show()

def encryptNow(self, event):
print("Encrypting")
cipher = self.cipher.GetValue()
encryptor = self.encryptor.GetValue()
print(cipher)
print("with ", encryptor)

def decryptNow(self, event):
print("De-Encrypting")
cipher = self.cipher.GetValue()
decryptor = self.decryptor.GetValue()
print(cipher)
print("with ", decryptor)

app = wx.App(False)
frame = CipherTexter(None, "The SS Cipher")
app.MainLoop()

enter image description here

关于python - GUI 窗口未按指示调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56906149/

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