【问题标题】:command to Stop infinite loop ??停止无限循环的命令??
【发布时间】:2017-11-16 14:01:39
【问题描述】:

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

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)

谢谢大家

【问题讨论】:

    标签: python-3.x loops user-interface button breakout


    【解决方案1】:

    用于结束无限循环的命令是break()

    【讨论】:

      猜你喜欢
      • 2012-01-10
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 2013-07-27
      相关资源
      最近更新 更多