running = True # Indicates that the simulation is currently set to be running
clicked = False # Indicates that the mouse has not been clicked
# Create a function to keep track of left-clicks of the mouse
def left_click():
global clicked # To be able to modify the variable "clicked" within the function
clicked = True # If the mouse is clicked, set "clicked" to be True
# When the mouse is left clicked, the "left_click" function (above) will execute
scene.bind('left click', left_click)
while True:
rate(200)
if clicked: # If the mouse gets clicked...
running = !running # If running == True, set to False. If False, set to True.
clicked = False # Done with the current click, so set clicked = False
if running == False:
continue # Skip the rest of the loop if running is set to False