summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtsp.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tsp.py b/tsp.py
index dbdefb9..3a0aa42 100755
--- a/tsp.py
+++ b/tsp.py
@@ -639,6 +639,16 @@ class AlgoGui (gtk.Window):
self.resume_button.set_sensitive (True)
self.stop_button.set_sensitive (False)
+ def halt (self):
+ '''Final halt'''
+ if self.thread:
+ self.thread.stop ()
+ self.thread.join (0.1)
+ if self.thread.isAlive ():
+ gobject.timeout_add (100, self.halt)
+ return
+ gtk.main_quit ()
+
def update_best (self, length, time):
'''Update best solution length label'''
if not length:
@@ -667,4 +677,9 @@ if __name__ == "__main__":
gtk.main ()
except KeyboardInterrupt:
pass
- gui.stop ()
+ gui.hide ()
+ gobject.timeout_add (100, gui.halt)
+ try:
+ gtk.main ()
+ except KeyboardInterrupt:
+ pass