Operating system: Windows 10
Slicer version: 4.11
Hi all–
I have created a module (using the ScriptedLoadableModule template), and I am trying to add a button to the widget GUI that sets the window to full screen.
As part of that, I would also like to set the module widget to float and also change the module window icon to a custom icon. I am able to achieve the desired appearance when launching Slicer with a custom launch script using this code:
slicer.util.mainWindow().showFullScreen
slicer.modules.mymodule.widgetRepresentation().show()
slicer.modules.mymodule.widgetRepresentation().setWindowIcon(qt.QIcon(customIconFilePath))
However, once I have opened my module in the module panel in Slicer, the above code that works in the launch script doesn’t show my module in a floating window (but the code runs without error). I assume this has something to do with the fact that my module is already open in the model panel. Is there a way to get around this issue? I would really like to be able to achieve the desired appearance by clicking a button in my module’s GUI rather than launching in full screen.
FYI, I tried to achieve the desired appearance by floating the module panel (after my module was already open in the module panel). Here’s an excerpt of the relevant code:
slicer.util.mainWindow().showFullScreen
moduleBrowser = slicer.util.mainWindow().findChild(“QDockWidget”, “PanelDockWidget”)
moduleBrowser.setFloating(True)
moduleBrowser.setWindowIcon(qt.QIcon(customIconFilePath))
This code runs without error, but I have two issues:
-
The floating module panel includes the Data Probe and a large Slicer logo. (I’d rather not have those things in the window.)
-
The window icon doesn’t actually change. (No window icon appears at all.)
Can anyone tell me how I can achieve my desired appearance when executing code via a button in the module widget GUI? This is a minor issue, but I would still greatly appreciate any help!
Thanks in advance,
EBP