You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I remove a registered view from the silx.gui.data.DataViewer.DataViewer using the removeView method, the display breaks down after switching between views, see the image below for the display of an 3D volume as image stack
A minimum code example is given below (with debugging prints). The reason is that the DataViewer.__getStackIndex method always calls the __stack.addWidget method of the QStackedWidget when the view is not listed in the __index (which is invalidated after the call to removeView). The addWidget always appends the given widget to the end of the QStackedWidgets list which moves all other widgets "up" in the list without updating the index.
from qtpy import QtWidgets
from silx.gui.data.DataViewer import DataViewer
from silx.gui.data import DataViews
import numpy as np
def get_view_indices(viewer):
return {
v.__class__.__name__: (
viewer._DataViewer__stack.indexOf(v.getWidget()),
viewer._DataViewer__index.get(v, "None"),
) for v in viewer.availableViews()
}
if __name__ == "__main__":
data = np.random.random((100, 100, 10))
app = QtWidgets.QApplication([])
viewer = DataViewer()
viewer.setData(data)
# Force creation of views
for v in viewer.currentAvailableViews():
viewer.setDisplayedView(v)
for v in viewer.availableViews():
if v.__class__.__name__ == "_ImageView":
viewer.removeView(v)
viewer.show()
viewer.setData(data)
print(get_view_indices(viewer))
viewer.setDisplayMode(DataViews.STACK_MODE)
print(get_view_indices(viewer))
viewer.setDisplayMode(DataViews.PLOT1D_MODE)
print(get_view_indices(viewer))
viewer.setDisplayMode(DataViews.STACK_MODE)
print(get_view_indices(viewer))
app.exec()
The text was updated successfully, but these errors were encountered:
When I remove a registered view from the
silx.gui.data.DataViewer.DataViewer
using theremoveView
method, the display breaks down after switching between views, see the image below for the display of an 3D volume as image stackA minimum code example is given below (with debugging prints). The reason is that the
DataViewer.__getStackIndex
method always calls the__stack.addWidget
method of the QStackedWidget when the view is not listed in the__index
(which is invalidated after the call toremoveView
). TheaddWidget
always appends the given widget to the end of the QStackedWidgets list which moves all other widgets "up" in the list without updating the index.The text was updated successfully, but these errors were encountered: