I want to make a \"program\" that updates a label when you press a button and print out a variable, but with the code i have it does not work. Can someone help me out?
T
If you want to write it as a class, which has numerous advantages...
import Tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
self.x = tk.IntVar()
tk.Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
tk.Label(self, textvariable=self.x).pack()
tk.Button(self, text='Click', command=self.increment).pack()
def increment(self):
self.x.set(self.x.get() + 1)
root = tk.Tk()
app = Application(master=root)
app.mainloop()