Restart Slicer button or menu shortcut

Just wondering if there are plans to add a shortcut menu item for researting Slicer? I often find myself closing the app and re-openning it during the development of a module or even using modules under development. I am not aware of a shortcut for restarting Slicer - only when new extensions are installed or certain menu items are changed it prompts and automatic restart. I think it would be good to have a menu item for it - unless there is good reason not to.

Restart button is shown at the top at all scripted module’s GUI.

If you just want to restart without touching your mouse, then you can type restart() in the Python console.

If typing restart is too much then you can specify a shortcut (that you can put into your startup .slicerrc.py file). For example, restart Slicer on Ctrl+Shift+R:

shortcut = qt.QShortcut(qt.QKeySequence("Ctrl+Shift+R"), slicer.util.mainWindow())
shortcut.connect('activated()', slicer.util.restart)
3 Likes

Just to add what Andras said, I think you need to enable “Developer Mode” from the Application Settings for the button to show up.

Thanks, @lassoan. This is useful. I will use this shortcut a lot.

@muratmaga, yes it is enabled for me but I was thinking of a more general case: if users get errors in python interactor when using scripted modules or they mess up other settings in the scene, the cleanest way is to restart the Slicer. For example, when I used “Lights” module, it messed up lights for any volume rendering then on. Cleaning the scene does not solve this. I need to restart the Slicer.

I think having “Restart Slicer” in File menu would be nice for all users.

1 Like

Making it easier for users to restart Slicer would fragment the user community into two groups: those who know that they need to restart Slicer at certain times; and those who don’t know this. I would much rather have a more uniform user community, who don’t suppress errors by frequent restarts, and report any potential errors that they encounter due to prolonged use of the application.

Developers are a different category. They can mess up things up, so allowing restart makes sense for them.

I was having problems finding the .slicerrc.py. If this file is not on your machine you can create it in Application Settings, under Application startup Script, click the folder icon and the script will be created in the specified path.