1
我有下面的代碼,當運行該方法時,Toplevel窗口顯示正確的標題和內容,但仍然是微小的默認大小。我在這裏做了一些愚蠢而明顯錯誤的事情嗎?Tkinter Toplevel寬度和高度不起作用
def new_game(self):
self.top = tk.Toplevel(width=300, height=200)
self.top.title("New Game Settings")
title_msg = tk.Message(self.top, text="Which players do you wish to be controlled by the AI?")
msg_ai_1 = tk.Message(self.top, text="Player 1")
msg_ai_2 = tk.Message(self.top, text="Player 2")
title_msg.pack()
msg_ai_1.pack()
msg_ai_2.pack()
self.confirm_button = tk.Button(self.top, text="Okay", command=self.top.destroy)
self.confirm_button.pack()
我確認這工作。這裏記錄它:http://effbot.org/tkinterbook/wm.htm#Tkinter.Wm.geometry-method – twasbrillig