[PyQt] Handling of Ctrl-C/SIGINT in PyQt

Florian Bruhin me at the-compiler.org
Mon Mar 16 13:05:47 GMT 2015


Hi!

It seems to be surprising for many people why Ctrl-C doesn't work in
PyQt applications:

    http://stackoverflow.com/q/4938723
    http://stackoverflow.com/q/5160577
    https://www.mail-archive.com/pyqt@riverbankcomputing.com/msg13757.html
    etc.

If I want to run custom code on Ctrl-C, it seems the only solution is
the one presented at [1], i.e. running a QTimer which executes
something like "lambda: None" all few milliseconds.

[1] http://stackoverflow.com/a/4939113

This is because Python only handles the signal after control has been
passed to Python.

Couldn't PyQt have something similiar to pyqtRemoveInputHook and
pyqtRestoreInputHook to register a signal handler for a given signal
on C++ level, and then somehow give the control to Python so it can
process the signal?

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150316/35edd312/attachment.sig>


More information about the PyQt mailing list