I'm working with the tkinter
module for the first time and I found the textvariable
argument when creating labels/buttons and what not.
It only ever updates the first time. I've twisted the method of retrieving the command ever which way but nothing seems to be working. I've hit a brick wall.
from tkinter import *
x = 1
y = 1
z = 0
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
textVar = StringVar()
self.button = Button(
frame, textvariable=textVar, command=textVar.set(str(fibonacci()))
)
self.button.pack()
def fibonacci():
global x, y, z
z = x
x = x + y
y = z
return x
root = Tk()
app = App(root)
root.mainloop()