I'm trying to make a button to run my while loop, but I'm stuck a little bit. My button works fine but, the while loop is not running. Can you help me out please? Here's my code:
import tkinter as tk
root = tk.Tk()
buttonClicked = False
def buttonClicked():
global buttonClicked
buttonClicked = not buttonClicked
print(buttonClicked)
canvas = tk.Canvas(root, height=700, width=700)
canvas.pack()
startstop = tk.Button(root, text="Start\stop", bg="green", command=buttonClicked)
startstop.pack()
while buttonClicked == True:
print("Hello")
root.mainloop()
Thank you in advance! Szilárd
mainloop()running. That will either hang the whole window, or the window will not appear.