3
我一直在環顧堆棧溢出的年齡試圖找到答案,但我不能得到任何東西的工作,因此我問這個問題。我有一個帶有三個按鈕和一個標籤的小程序,它們在一個網格中。我想知道如何不管大小或形狀的按鈕和標籤將保持相對於框架相同。類似於如果我調整圖像大小,一切都保持相同的大小。Python 3.6 - 根據幀大小調整Tkinter按鈕的大小
這裏是我的代碼:
如果from tkinter import *
class Window(Frame): #All the stuff for the GUI
def __init__(self, master = None):
Frame.__init__(self, master)
self.master = master
self.init_window()
self.grid()
def init_window(self):
self.master.title("EncryptDecrypt")
self.pack(fill = BOTH, expand = 1)
quitButton = Button(self, text = "Quit", command = self.client_exit, width = 10, height = 5) #Quit Button
quitButton.grid(row = 0, column = 0, sticky = W)
encryptModeButton = Button(self, text = "Encrypt", command = lambda: self.execute("decrypted.txt", "encrypted.txt", 1, 0), width = 10, height = 5) #Encrypt Button
encryptModeButton.grid(row = 0, column = 1, sticky = W)
decryptModeButton = Button(self, text = "Decrypt", command = lambda: self.execute("encrypted.txt", "decrypted.txt", 0, 1), width = 10, height = 5) #Decrypt button
decryptModeButton.grid(row = 0, column = 2, sticky = W)
myLabel = Label(self, text = "Select The Action You Wish To Undertake", font = ("Purisa", 15))
myLabel.grid(row = 0, column = 3)
root = Tk()
root.geometry("610x80")
app = Window(root)
root.mainloop()
對不起,答案是顯而易見的,我已經嘗試pack()
我不太清楚你的要求。你是否在說,如果你調整窗戶的大小,你希望一切都會增長? –
@BryanOakley是的,這是正確的 –