几周前我开始在 Python 上学习 Tkinter,并想创建一个猜谜游戏。但不幸的是,我遇到了一个问题,使用这段代码,规则的文本(在函数 Rules;text='Here are the rules...
中)没有出现在窗口(rule_window)上。
window = Tk()
window.title("Guessing Game")
welcome = Label(window,text="Welcome To The Guessing Game!",background="black",foreground="white")
welcome.grid(row=0,column=0,columnspan=3)
def Rules():
rule_window = Tk()
rule_window = rule_window.title("The Rules")
the_rules = Label(rule_window, text='Here are the rules...', foreground="black")
the_rules.grid(row=0,column=0,columnspan=3)
rule_window.mainloop()
rules = Button(window,text="Rules",command=Rules)
rules.grid(row=1,column=0,columnspan=1)
window.mainloop()
有谁知道如何解决这个问题?