I have this code :
from tkinter import *
def mine():
global textVar
textVar = StringVar()
textVar.set('Text')
root = Tk()
root.title('Miner v1.0')
root.geometry('400x240')
miningButton = Button(root, text='Mine', command=mine)
miningButton.pack()
mainLabel = Label(root, textvariable=textVar)
mainLabel.pack()
root.mainloop()
I have made textVar
a global variable but the mainLabel
it don't find it, it says that it is undefined. But when the textVar
is outside the def
it works
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…