Quantcast

Tkinter help?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Tkinter help?

cartman6921
This post has NOT been accepted by the mailing list yet.
Below is a code made by me in 5 minutes, I am new to Tkinter so am kinda noobish. as you can see, lemon equals 0 at the start and when you click the button it adds 1 to the amount lemon equals. After about 15 minutes of trying and 10 minutes googling i can find nothing to help me. when the code loops, lemon is set back to 0 again, how do i stop lemon from being set back to 0.

I need it so if you press the button eg 4 times, lemon=4


from tkinter import *
root=Tk()

root.title("Lemonade Stand")
root.geometry("500x500+500+300")

lemon=0

def BuyLemon():
    str(lemon)+str(1)
    print(lemon)

button = Button(root,text="Buy Lemon x1", command=BuyLemon)
button.pack()

root.mainloop()
Loading...