[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Raise exception from event handler
From:       Jack Cosgrove <jackcosgrove () gmail ! com>
Date:       2011-05-28 21:56:21
Message-ID: 1306619781.1918.8.camel () fanserver
[Download RAW message or body]

I am making a shell for PyQt. I have an odd program architecture.

The Qt event loop is initiated by my shell, which is written in C++. The
shell executes a block of Python code using PyRun_String and its sister
functions.

The behavior I want is to end this execution by raising a
KeyboardInterrupt when a user presses a certain button during execution.

I can catch the button press in the event handler, but raising a
KeyboardInterrupt from this location consumes the event somewhere along
the way so that execution does not stop. I know Qt does not support
raising exceptions from signals, slots, and event handlers, and I am at
a loss as to go about raising this exception and terminating the Python
interpreter execution upon a button press.

The exception is reported by printing out all errors, so it is consumed
somewhere by the Python interpreter but not in a place that ends
execution.

I can stop execution if I hard-code raising the exception into the
Python code being executed, i.e. not in an event handler.

Any ideas how to stop execution of the PyRun_* functions when something
is triggered in a PyQt event handler?

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic