2

我有以下代码,当运行该方法时,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()
4

2 回答 2

6

Tk() and Toplevel() geometry can be set by self.top.geometry("%dx%d%+d%+d" % (300, 200, 250, 125)). First two numbers represent dimensions of window. Third and fourth number say, where the window will appear.

于 2013-05-19T05:41:27.137 回答
1

用这个:

self.secondWin.wm_geometry("1000x1000")
于 2015-10-31T12:51:02.013 回答