Commande bouton ( pause ou annuler) pour une boucle infinie
Je suis entrain de développer une interface graphique, je souhaite avoir la possibilité de mettre en pause ou d'annuler ce fichier après l'avoir envoyé. Il y a trois boutons (Envoyer, pause et arrêt), j'ai déjà fait la fonction du bouton d'envoi, je dois définir maintenant la fonction du bouton pause et annuler.
Voici le programme
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
def moh():
# Open grbl serial port
s = serial.Serial('/dev/ttyS0',115200)
# Open g-code file
f = open(file_path.get(), "r");
# Wake up grbl
s.write("\r\n\r\n".encode('utf8'))
time.sleep(2) # Wait for grbl to initialize
s.flushInput() # Flush startup text in serial input
# Stream g-code to grbl
for line in f:
l = line.strip() # Strip all EOL characters for consistency
print ('Sending: ' + l)
s.write((l + '\n').encode("utf8")) # Send g-code block to grbl
grbl_out = s.readline().decode("utf8") # Wait for grbl response with carriage return
print (' : ' + grbl_out)
# Wait here until grbl is finished to close serial port and file.
raw_input(" Press <Enter> to exit and disable grbl.")
# Close file and serial port
f.close()
s.close()
b1= Button(Outil, text ="Send",background='White', command=moh) |