Tkinter, add pressed buttons onto string display string, how to?

7stud bbxx789_05ss at
Sat Apr 5 21:55:26 CEST 2008

skanem... at wrote:
> using tkinter and python i now have a small App (that will hopefully
> soon be a fully functioning calculator) where u can push buttons and
> the corresponding number or operator is shown.
> when u press 1, "1" appears on the screen, pres + and "+" appears etc.
> at the moment every output overwrites the previous so what i want to
> do is obviosuly to add every new output to a string so that i can read
> the string and perform the calculation.
> so i want:
> *  when pushing the button push the token of the button onto a string
> * display the new string, ie "1+2" for example
> * want to be able to access this string when pressing calculate so i
> can figure out which operators should
> be done first so it can solve something like this: "(1+2*3)(3-4/2)"
> and not just simple "1+2"-stuff.
> do i have to have some global string-variable in the GUIframework
> then? im not sure where to start...

input = "hello"
input += " world"
print input


A caculator program is pretty complex.  Based on your rudimentary
questions, I don't think you have enough programming experience to
tackle a project like that yet.

More information about the Python-list mailing list