I have problem with my Tkinter code in Python 2.7. I have main window with one widget (button). I want to redraw window (and change value of variable -> add one widget) after click on the button. Where is problem? I think that problem can be, that every loop of mainloop change variable to 0. Thank you!
from Tkinter import *
def function():
global variable
variable = 0
main.update()
variable = 0
main = Tk() #New Tk window
if variable == 1:
Checkbutton(main, text="test").pack()
Button(main, text="Change", command=function).pack()
main.mainloop()