I was wondering if there was any way to access the currently running module and its corresponding widgets through code. By this, I mean for example if I were running the Segmentation module, is it possible for me to access the module that is on the display menu, and then isolate the SliceFill widget that is present in the module?
Yes, you can access any module from any other module.
A module must not use another module’s GUI (the GUI is only for user interactions), but instead a module should create/modify MRML nodes and call module logic functions.
I used the segmentation editor as an example but am more specifically looking to pull the widgets out of the Reformat module. I’m having a bit of trouble locating the module (i.e, I am able to call the widgets present on the mainWindow() but could not find access to the module window) and as such, cannot find the widgets that the Reformat module has built in.
In Reslice module’s case, search result shows that the button is in a module widget (qSlicerReformatModuleWidget.ui), so the widget is not reusable. If you are familiar with C++ then you can refactor the code to move the part you need to a separate reusable widget and use that widget in your module. However, it may be simpler to just have a look at the module widget’s code and reimplement in your code whatever you need.
@jcfr in the scenario that you have stated above, does this not take the entire reformat module and simply create a widget elsewhere? in which case the individually packaged components would still not be retrievable, is that correct?
@lassoan thank you for the response! i will certainly take a look into the code and try to develop the widget after i figure out all the individual components of it
This approach is suitable for fast prototyping and experimenting with UI. After, an approach is validated, I suggest to refactor the module so that you could reuse its components.