Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit viewer on control + c in terminal #1101

Open
emil-peters opened this issue Apr 22, 2024 · 2 comments
Open

Exit viewer on control + c in terminal #1101

emil-peters opened this issue Apr 22, 2024 · 2 comments

Comments

@emil-peters
Copy link

When visualizing anything and exiting the python program using control + c it doesn't close the screen and also doesn't kill the python code

It only closes after focusing & clicking in the window again with the following prompt in the terminal afterwards:
Caught a Ctrl-C within python, exiting program.

Is there a way to automatically stop the visualizer after exiting the python program via the terminal?
On a custom VTK viewer we implemented using PyQT the following line seems to do the trick.

# This assures the app quits on CTRL-C (when not in focus)
signal.signal(signal.SIGINT, signal.SIG_DFL)

Visualization code example

        show(
            vedo_meshes,
            camera=camera,
            N=len(vedo_meshes),
            bg="black",
        ).close()

Thanks

@emil-peters
Copy link
Author

I just tested and putting the following snippet at the top of the plotter.py file ensures that the code terminates on control-c in the terminal.
Not sure if this would be a desired solution or if there are other options

import signal

# This assures the app quits on CTRL-C (when not in focus)
signal.signal(signal.SIGINT, signal.SIG_DFL)

@marcomusy
Copy link
Owner

Hi, if you do CTRL-C focusing on the terminal that should terminate the app (maybe after some delay).
CTRL-C focusing on the rendering window will do nothing (although it would be good to have the same).

The way to close the window while focusing on it is to press q.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants