Problem in logic, how to stop an infinite loop under such circumstances?

0

I'm having a logic problem here: I'm developing a script for automating tasks, and I need to select the floor button. It runs every step in the established order without stopping (or while the stop_onclick button is not pressed) but I also need that when I want to make the script stop running, hit the Stop button.

Code:

from tkinter import *
from tkinter import ttk
import time
import pyautogui
import keyboard
from PIL import ImageGrab
import sys

janela = Tk()
janela["bg"] = "#3F5D7D"

def Andar_onclick():
    while True:
            print("andando")
def Parar_onclick():
    print("parou")
bt1=Button(janela,width=10,text="Andar",command=Andar_onclick)
bt1.place(x=0,y=0)

bt2=Button(janela,width=10,text="Parar",command=Parar_onclick)
bt2.place(x=0,y=40)

janela.title("bot")
janela.geometry("200x200")
janela.resizable(False,False)
janela.mainloop()
janela.destroy()

Fucking no repl:

link

Thank you all for your attention, thank you!

    
asked by anonymous 21.09.2018 / 23:33

0 answers