Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make Qt4 backend safe for interactive use.

  • Loading branch information...
commit 831f6f3e4630a3bd449d82e7af8be51a3262c2d9 1 parent ae16da2
@epatters epatters authored
Showing with 21 additions and 8 deletions.
  1. +21 −3 pyface/i_gui.py
  2. +0 −5 pyface/ui/qt4/gui.py
View
24 pyface/i_gui.py
@@ -57,6 +57,17 @@ def __init__(self, splash_screen=None):
# 'GUI' class interface.
###########################################################################
+ def allow_interrupt():
+ """ Override the SIGINT handler to ensure the process can be
+ interrupted. This prevents GUI toolkits from swallowing
+ KeyboardInterrupt exceptions.
+
+ Warning: do not call this method if you intend your application to be
+ run interactively.
+ """
+
+ allow_interrupt = staticmethod(allow_interrupt)
+
def invoke_after(cls, millisecs, callable, *args, **kw):
""" Call a callable after a specific delay in the main GUI thread. """
@@ -80,7 +91,6 @@ def set_trait_later(cls, obj, trait_name, new):
def process_events(allow_user_events=True):
""" Process any pending GUI events. If allow_user_events is False then
user generated events are not processed.
-
"""
process_events = staticmethod(process_events)
@@ -111,6 +121,16 @@ class MGUI(object):
Implements: _default_state_location()
"""
+ def allow_interrupt():
+ """ Override the SIGINT handler to ensure the process can be
+ interrupted. This prevents GUI toolkits from swallowing
+ KeyboardInterrupt exceptions.
+ """
+ import signal
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+
+ allow_interrupt = staticmethod(allow_interrupt)
+
def _default_state_location(self):
""" Return the default state location. """
@@ -122,5 +142,3 @@ def _default_state_location(self):
logger.debug('GUI state location is <%s>', state_location)
return state_location
-
-#### EOF ######################################################################
View
5 pyface/ui/qt4/gui.py
@@ -102,11 +102,6 @@ def set_busy(busy=True):
###########################################################################
def start_event_loop(self):
- # Make sure that SIGINTs actually stop the application event loop (Qt
- # sometimes swallows KeyboardInterrupt exceptions):
- import signal
- signal.signal(signal.SIGINT, signal.SIG_DFL)
-
if self._splash_screen is not None:
self._splash_screen.close()
Please sign in to comment.
Something went wrong with that request. Please try again.