我希望我的程序以这样的方式运行:一旦用户按下按钮,就会根据按钮的命令显示Info一个名为的标签。在相同的条件下(如果按下按钮),我想添加一个删除/销毁.GameInfoLabel
InfoInfoBackGameInfoLabel
我试图在下面的代码中实现这一点,但我收到了消息
NameError:名称“GameInfoLabel”未定义。
from tkinter import *
root = Tk()
root.title("Game Menu")
root.geometry("1920x1080")
root.resizable(True, True)
def QuitGameInfo():
GameInfoLabel.destroy()
BackInfoButton['state'] = NORMAL
def GameInfo():
RulesNotepad = open("GameInfo.txt",'r')
Rules = RulesNotepad.read()
GameInfoLabel = Label(root, text = Rules, fg = "blue", bg = "red", height = "14", width = "140").pack()
BackInfoButton = Button(root, text = "Back", command = QuitGameInfo).pack()
RulesNotepad.close()
button3 = Button(root, text = "Info", command = GameInfo, width = "20", height = "3").pack()
root.mainloop()
哔哔one
holdtom
相关分类