From: Dima K. <di...@se...> - 2025-06-26 22:30:30
|
Hello. This is another issue i just looked into, that I would appreciate some pointers for. I have this trivial pyfltk program: #!/usr/bin/python3 from fltk import * window = Fl_Window(100,200,"xxx") window.end() window.show() Fl.run() I run it. Instead of hitting Escape, I go back to the console, and hit Ctrl-c. I expect the program to exit, but it ignores the C-c, and does nothing. If I go back to the application, and hit Escape, it does exit, but also says this: Traceback (most recent call last): File "/home/dima/projects/mrcam/tst.py", line 9, in <module> Fl.run() ~~~~~~^^ File "/usr/lib/python3/dist-packages/fltk/fltk.py", line 3292, in run return _fltk.Fl_run(*args) ~~~~~~~~~~~~^^^^^^^ KeyboardInterrupt I vaguely remember seeing this in other contexts before. This was years ago, but back then, when Python called an extension-module function it reset the SIGINT handler to a function that sets a flag, and does nothing else. Then when the extension module function returned, it would look at the flag, and respond to it at that time. This would cause us to ignore C-c until the Python interpreter got control back. I actually work around this in all my extension modules. For instance: https://github.com/dkogan/mrcam/blob/f37ea3577567e4bd64fe3b69a8196c48f538ee03/mrcam-pywrap.c#L30 At the top of any extension-module function that is not expected to return immediately, I SET_SIGINT(), and RESET_SIGINT() when done. Do we need to do something vaguely similar here? pyfltk should allow the expected thing to happen: when we get a Ctrl-c, the application should exit. As with the previous email, this is on a very recent Debian system with: $ dpkg -l python3-fltk libfltk1.4 python3 ii python3-fltk:amd64 1.4.2.0-2 amd64 Python wrapper for the Fast Light Toolkit ii libfltk1.4:amd64 1.4.3-1 amd64 Fast Light Toolkit - main shared library ii python3 3.13.1-2 amd64 interactive high-level object-oriented language (default python3 version) Thanks |