如何在不退出GUI的情况下停止脚本的运行?

9 浏览
0 Comments

如何在不退出GUI的情况下停止脚本的运行?

我已经制作了一个带有开始和关闭Python脚本选项的GUI菜单。到目前为止,我能够使用线程运行多个脚本,但是对于停止按钮的功能,我仍然迷失在其中。

import time
import threading
from threading import Thread
import rospy
from std_msgs.msg import *
from Tkinter import *
from subprocess import call
import subprocess
data_pub = rospy.Publisher('setup', String, queue_size=10)
def start():
    global t1, t2
    t1 = threading.Thread(
        target=call,
        args=("/home/ubuntu/catkin_ws/src/tp/scripts/arduino_io_reader1.py",), )
    t1.start()
    t2 = threading.Thread(
        target=call,
        args=("/home/ubuntu/catkin_ws/src/tp/scripts/move_arm.py",),)
    t2.start()
def stop():
    global t1, t2
    t1._stop()
    t2._stop()

0