首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >停止无限循环的命令??

停止无限循环的命令??
EN

Stack Overflow用户
提问于 2017-06-14 20:09:48
回答 0查看 208关注 0票数 0

我正在开发一个图形界面,我希望有能力暂停或取消此文件后发送它。有三个按钮(发送,暂停和停止),我已经完成了发送按钮的功能,我现在必须定义暂停和取消这两个按钮的功能,我该怎么办?下面是程序

代码语言:javascript
复制
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)

感谢所有人

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44544410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档