如何获得一个显示变量的Tkinter窗口,以便在变量变化时更新?

时间:2014-10-24 19:16:46

标签: python-2.7 variables tkinter

所以我用Tkinter在python中编写这个游戏。游戏通过调用一个改变文本变量和按钮变量值的函数来工作。按下按钮调用该功能时,屏幕不会重绘并调出新变量,只显示旧文本。

startGame()

win=Tkinter.Tk()
win.title("TREASURE QUEST!!")
Textlabel=Tkinter.Label\
  (win,text = text1,font=('Times New Roman',12),wraplength=600,)
Textlabel.pack()
Row2=Tkinter.Frame(win)
Btn1=Tkinter.Button\
  (Row2, text=button1Name, command= button1(),font=('Times New Roman',12))
Btn2=Tkinter.Button\
  (Row2, text=button2Name, command= button2(), font=('Times New Roman',12))
Btn1.pack(side='left')
Btn2.pack(side='left')
Row2.pack()

win.mainloop()



def startGame():
    global text1,button1,button1Name,button2,button2Name
    ##adds name
    ##button that calls StoryCard

    text1="Welcome to Treasure Quest!! The Game that allows you to pick your own destiny! Treasure quest is a very simple game. The story will display on the screen until it reaches an event. At each event you will be shown two choices. Each decision may cause you to leave with more treasure or to die a horrible death... Still like any true or false question on a final exam, you only have a 50/50 chance of ruining your entire life if you do not know! Now that you know how to play, please click the button below to start the game!" 
    button1=introCard
    button1Name="Play"

    button2=kill
    button2Name="Quit"

0 个答案:

没有答案