Module 'JupyterNotebooksLib' has no attribute 'AppWindow'

Hi,

I’m interested in the newly developed feature of displaying Slicer output within Jupyter and have downloaded the Slicer jupyter notebook tutorials from… https://mybinder.org/v2/gh/lassoan/SlicerNotebooks/master

However, I get the following error message after running the first cell:


AttributeError Traceback (most recent call last)
In [1]:
Line 4:

AttributeError: module ‘JupyterNotebooksLib’ has no attribute ‘AppWindow’

I can however load volumes within Jupyter and display them:

[success, loadedVolumeNode] = slicer.util.loadVolume(’/home/vinny/temp_data/test/t1.nii’, returnNode=True)

slicernb.ViewDisplay(“OneUpRedSlice”)

Slicer preview release 4.11.0-2020-06-05
OS: Ubuntu 20.04.

Thanks for your help,

Vinny

Have you completed all installation step? In particular, have you installed ipywidgets in Slicer?

Hi Andras,

Thanks for the link. I followed the instructions (including installing ipywidgets) and no longer get the error message regarding a missing AppWindow. However, the output doesn’t appear to be scaled to 0.5 similar to what is in the tutorial. If I change the scaling factor, the window size does not change. Is there anything else I missed?

Does it work if you set the main window width and height directly?

If I interpreted it correctly, I changed the width and height as follows:

slicernb.AppWindow.setWindowSize(width=500,height=100)

but the height and width have not changed in the output.

Initially during the installation, a message appeared stating ipywidgets 7.0.0 was not compatible with ipycanvas. So I had upgraded it within Slicer to ipywidgets 7.5.1.

If you execute slicer.util.mainWindow().size = qt.QSize(width, height) then does your main window size change? Maybe the window is maximized? We should then add a call before setting the window size to set normal window state.

Thanks, I tried your suggestion but the window size still looks maximized. Please see attached screenshot…perhaps I’m not calling the function properly?

Does size change work if you call slicer.util.mainWindow().showNormal() before?

Thanks Andras, that does the job! If the call is placed for example:

slicer.util.mainWindow().showNormal()
slicer.util.mainWindow().size = qt.QSize(1200,1200)

Then when the width and height are changed, the window size changes.

With the tutorial set, adding in slicer.util.mainWindow().showNormal() before the slicernb.AppWindow.setWindowSize(scale=0.5) does the job too.

1 Like

Thanks for testing, I’ve pushed a fix to SlicerJupyter.

Thanks for pushing the fix. How can I install the latest SlicerJupyter extension with this fix? I uninstalled the SlicerJupyter extension and re-installed it. But the window size still does not change.

Extensions are rebuilt nightly (for each new Preview Release and the latest Stable Release), so you can either wait for that or update the modified .py file on your computer.

Thanks Andras for your help. Just downloaded and installed the latest preview release (Version 4.11.0; 2020-06-06; revision 29114) and it works now.

1 Like