Improve Tkinter exit
This commit is contained in:
@@ -16,6 +16,7 @@ import tkinter as tk
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
import atexit
|
||||||
|
|
||||||
def translate(val, lmin, lmax, rmin, rmax):
|
def translate(val, lmin, lmax, rmin, rmax):
|
||||||
lspan = lmax - lmin
|
lspan = lmax - lmin
|
||||||
@@ -68,6 +69,9 @@ class LogPen(Node):
|
|||||||
callback_group=self._callback_group,
|
callback_group=self._callback_group,
|
||||||
)
|
)
|
||||||
self.get_logger().info("Initialization successful.")
|
self.get_logger().info("Initialization successful.")
|
||||||
|
#atexit.register(self.cleanup)
|
||||||
|
#def cleanup(self):
|
||||||
|
#app.quit()
|
||||||
|
|
||||||
def pen_position_callback(self, msg: Odometry):
|
def pen_position_callback(self, msg: Odometry):
|
||||||
"""
|
"""
|
||||||
@@ -90,7 +94,7 @@ def main(args=None):
|
|||||||
rclpy.shutdown()
|
rclpy.shutdown()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
def log_thread(queue=Queue()):
|
def start_log_thread(queue=Queue()):
|
||||||
|
|
||||||
rclpy.init()
|
rclpy.init()
|
||||||
|
|
||||||
@@ -98,10 +102,10 @@ def log_thread(queue=Queue()):
|
|||||||
|
|
||||||
executor = rclpy.executors.MultiThreadedExecutor(2)
|
executor = rclpy.executors.MultiThreadedExecutor(2)
|
||||||
executor.add_node(log_pen)
|
executor.add_node(log_pen)
|
||||||
executor.spin()
|
#executor.spin()
|
||||||
|
|
||||||
rclpy.shutdown()
|
#rclpy.shutdown()
|
||||||
exit(0)
|
#exit(0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@@ -109,13 +113,18 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
q = Queue()
|
q = Queue()
|
||||||
|
|
||||||
thread0 = threading.Thread(target=log_thread, args=[q])
|
global app
|
||||||
thread0.start()
|
app = DrawingApp(q)
|
||||||
|
|
||||||
|
global log_thread
|
||||||
|
log_thread = threading.Thread(target=start_log_thread, args=[q])
|
||||||
|
log_thread.start()
|
||||||
|
|
||||||
#thread0.join()
|
#thread0.join()
|
||||||
#thread1 = threading.Thread(target=DrawingApp().mainloop)
|
#thread1 = threading.Thread(target=DrawingApp().mainloop)
|
||||||
#thread1.start()
|
#thread1.start()
|
||||||
#thread1.join()
|
#thread1.join()
|
||||||
|
|
||||||
app = DrawingApp(q)
|
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
rclpy.shutdown()
|
||||||
|
exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user