¿Cómo agregar botones de inicio y parada en script Python?
Usa el componente de botón de tkinter.
Establezca el tamaño de fuente (tipo int) y agregue componentes dentro del bucle (tome while como ejemplo):
xunhuan=1 # Controle el inicio y el final del bucle
p># Definir bucle de inicio
def start():
global xunhuan
xunhuan = 1
# Fin
def end():
xunhuan global
xunhuan = 0
tamaño=(tamaño de palabra)
# Ahora importa la biblioteca
inporta tkinter como tk # Entrada conveniente
window = tk.Tk()
s = tk.Button(window, text = "Inicio ", comando = iniciar) # Botón Inicio
e = tk.Button(ventana, texto = "Detener", comando = finalizar) # Botón Finalizar
# Botón Dibujar
s.pack()
e.pack()
# El siguiente es el bucle
while True:
if xunhuan:
...(Cosas a hacer dentro del bucle)
window.mainloop() # En tkinter, se debe agregar esta línea de código p>