GUI窗口未按指示调整大小

时间:2019-07-05 15:53:55

标签: python wxpython

我在面板中设置了尺寸,但是在运行程序时它不起作用。它只是弹出很小,我必须手动调整大小。

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

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

1 个答案:

答案 0 :(得分:0)

尝试将“面板”放入“框架”中。
我想这是您要求的起点的一个模拟。

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