Sunday 15 March 2015

python 2.7 - How do you get a Tkinter window displaying a variable, to update when the variable changes? -



python 2.7 - How do you get a Tkinter window displaying a variable, to update when the variable changes? -

so i'm writing game in python tkinter. game works calling function changes values of text variables, , button variables. when button pushed calls function however, screen not redraw , phone call new variables , displays old text.

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 calls storycard text1="welcome treasure quest!! game allows pick own destiny! treasure quest simple game. story display on screen until reaches event. @ each event shown 2 choices. each decision may cause leave more treasure or die horrible death... still true or false question on final exam, have 50/50 chance of ruining entire life if not know! know how play, please click button below start game!" button1=introcard button1name="play" button2=kill button2name="quit"

python-2.7 variables tkinter

No comments:

Post a Comment