Open dylanmcreynolds opened 4 years ago
A similar problem occurred with the metadataviewer. @ronpandolfi fixed it by removing the excludedkeys keyword before the super() call.
My solution is to change the dynimageviewer.__init__
as follows:
class DynImageView(ImageView):
def __init__(self, *args, **kwargs):
if 'stream' in kwargs:
del kwargs['stream']
super(DynImageView, self).__init__(*args, **kwargs)
The plugin continues to work in this case
That should work for NCEMViewerPlugin
, but it I'm not sure it will work for FFTViewerPlugin
and FourDImageView
, since they don't inherit DynImageView
. I'm thinking about what we can do about this (see notes that will follow).
Notes:
When instantiating the widgetcls
passed to TabView
, we pass the itemdata
(which can be a NonDBHeader
or BlueskyRun
), a stream, a field, and any additional kwargs passed into TabView:
# TabView constructor for references
class TabView(QTabWidget):
def __init__(
self,
catalogmodel: QStandardItemModel = None,
selectionmodel: QItemSelectionModel = None,
widgetcls=None,
stream=None,
field=None,
bindings: List[tuple] = [],
**kwargs,
):
# ...
# tabview.py:89
newwidget = self.widgetcls(itemdata, stream=self.stream, field=self.field, **self.kwargs)
If the widgetcls
does not capture stream
(or field
) in its constructor, these will be passed as kwargs
in the inheritance change. This can (as @ercius wrote above) cause a base class to fail to initialize due to unexpected arguments.
Here are some design questions I have regarding this:
widgetcls
passed into TabView
be expected to handle stream
and field
(i.e. have stream
and field
as arguments in its __init__
)?widgetcls
inspect its kwargs
and remove stream
and/or field
if they won't be used?widgetcls
types that use mixins, how should the mixins handle stream
and field
if no mixin uses them (as an example, SAXSGUIPlugin
passes a SAXSCalibrationViewer
to a TabView
)?For now Im going to fix this in my plugins by adding stream = 'primary'
to the init class of the plugin.
This was reported by Peter Ercias. The xi-cam.NCEM plugin cannot instatiate because of the stream kwarg introduced in cea06d189da0fc12130c55aeb7d2a5d0a3b0e2f8.
When the DunImageView instantiates, it complains that stream is unexpected.