0
我正在開發一個圖形界面,我希望能夠在發送後暫停或取消該文件。 有三個按鈕(發送,暫停&停止),我已經完成了發送按鈕的功能,現在我必須定義兩個按鈕暫停和取消的功能,請問我該怎麼辦? 這裏是節目命令停止無限循環?
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)
感謝所有