python - Syntax errors when using tkinter -
i have imported tkinter @ beginning of code , below have @ end gui. worked fine gui running , buttons displaying until wrote code 'strengthskill' , getting sytax error @ beginning of line:
mlabel=label(text='battle!!').place(x=50,y=130)
it highlighting "mlabel" error have looked , can't see problem is. have created second version tkinter stripped out , works fine.
mgui = tk() ment = diceint() mgui.geometry('400x400') mgui.configure(bg="purple") mgui.title('miss watts dice games') mlabel=label(text='4,6,12 sided dice roller').place(x=50,y=50) mbutton=button(mgui,text="go",command=diceroll).place(x=250,y=50) mentry=entry(mgui,variable=ment).pack() mlabel=label(text='strength , skill calculator').place(x=50,y=90) mbutton=button(mgui,text="go",command=strengthskill.place(x=250,y=90) mlabel=label(text='battle!!').place(x=50,y=130) mbutton=button(mgui,text="go",command=battle.place(x=250,y=130) mbutton=button(mgui,text="exit",command=close).place (x=50,y=250) mlabel=label(text='\n{copyright sign} dru watts 2014').place(x=50,y=300) mgui.mainloop()
unfortunately can't post main part of code creating example show students of controlled assessment coursework need complete , i'd rather didn't find this!
please gentle - new tkinter. worried may have mixed tutorials bit much!
you missing closing parenthesis here:
mbutton=button(mgui,text="go",command=strengthskill).place(x=250,y=90) ^
and here:
mbutton=button(mgui,text="go",command=battle).place(x=250,y=130) ^
also, because place
, pack
methods of every tkinter widget work in-place,mbutton
, mlabel
, etc. assigned none
. thus, if plan use these variables later on, need call these methods on own lines:
mlabel=label(text='4,6,12 sided dice roller') mlabel.place(x=50,y=50)
otherwise, recommend removing variables altogether because unnecessary:
label(text='4,6,12 sided dice roller').place(x=50,y=50) button(mgui,text="go",command=diceroll).place(x=250,y=50) entry(mgui,variable=ment).pack()
Comments
Post a Comment