View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004051 | Slicer4 | Core: Scripting (Wrapping, Python) | public | 2015-09-21 06:51 | 2015-09-21 09:21 |
Reporter | lassoan | Assigned To | jcfr | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0004051: No logic object is instantiated for scripted modules | ||||
Description | Scripted modules currently cannot do anything until the widget class is instantiated, because Slicer does not instantiate the module logic class. This is a problem because it is not possible to create "background" modules in Slicer, which performs operations without requiring the user to open the module's user interface. Slicer correctly instantiated module logic class for loadable modules. Instantiation is performed in an order computed based on specified module dependencies. Workarounds, such as creating logic class manually would not be consistent with other types of modules and would not work because dependencies between modules are ignored:
| ||||
Tags | No tags attached. | ||||
Agreed - scripted modules should have all the same features and behave consistently with any other module (as much as possible). |
|
Couldn't agree more. Few years ago, in an attempt to address this, we created: vtkSlicerScriptedLoadableModuleLogic [1] Similarly to loadable module, this would allow the logic of scripted module to be instantiated before the associated representation. This raises the following questions / remarks: (1) Being able to leverage QtCore classes in python logic has been great. (2) Currently, loadable logic only depends on VTK/ITK. The base class derives from vtkObject and there are no dependency on Qt. We could either:
[1] https://github.com/Slicer/Slicer/blob/master/Base/Logic/vtkSlicerScriptedLoadableModuleLogic.h |
|
Yes, it's aways been possible for scripted logics to use qt and being explicit that QtCore is exptected makes sense. This would give a hook for implementing the things Andras mentions. |
|
Making module logic depend on Qt would be a huge change. For me it would only make sense if we made all MRML classes to be based on Qt instead of MRML but then we would depend on Qt forever, for everything. Using Qt instead of VTK would have serious performance consequences, as VTK observers are typically about 10x faster than Qt signals/slots. Developers can still leverage qt features in their scripted module logic if Qt dependency is not an issue (it's typically not, as scripted modules are mostly high-level application modules anyway). |
|
Something like that is done for the module widget would work well:
I see that Python object creation code is there but it is commented out: vtkSlicerScriptedLoadableModuleLogic* logic = vtkSlicerScriptedLoadableModuleLogic::New(); // bool ret = logic->SetPythonSource(d->PythonSource.toStdString()); return logic; |
|
Indeed, at that time we didn't have a use case. The idea of having a dedicated Python class to implement the logic wasn't formalised. Now we have more use case, it would be great to have the scripted logic instantiated by the module manager. That said, some more work would be needed to implement the "reload" function directly within the module manager. Otherwise, the existing "Reload and Test" wouldn't be as useful. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2015-09-21 06:51 | lassoan | New Issue | |
2015-09-21 06:51 | lassoan | Status | new => assigned |
2015-09-21 06:51 | lassoan | Assigned To | => jcfr |
2015-09-21 06:55 | pieper | Note Added: 0013286 | |
2015-09-21 08:28 | jcfr | Note Added: 0013287 | |
2015-09-21 08:34 | pieper | Note Added: 0013288 | |
2015-09-21 08:51 | lassoan | Note Added: 0013289 | |
2015-09-21 09:14 | lassoan | Note Added: 0013290 | |
2015-09-21 09:21 | jcfr | Note Added: 0013291 |