Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_restart_gui_counter.py
- import tkinter as tk
- class Cv:
- counter = 0
- cv = Cv()
- def create_gui(): # for quick debugging
- def restart():
- cv.counter += 1
- label.configure(text=f"Counter: {cv.counter}")
- root.destroy()
- create_gui()
- root = tk.Tk()
- root.geometry("%dx%d+-10+0"%(200,200))
- label = tk.Label(root, text=f"Counter: {cv.counter}")
- label.pack()
- button = tk.Button(root, text="Restart", command=restart)
- button.pack()
- root.bind('<space>', lambda event: restart())
- root.mainloop()
- create_gui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement