Contents
Python
matplotlib: no window
The problem
No window is opened when a script is run from a command line. Running the script in an interactive IDE is fine.
What happens
The module matplotlib closes all windows when unloaded. This happens immediately after the script terminates if it is run from a command line. When run inside a IDE, then the module stays loaded, keeping windows opened.
How to fix
A quick solution is wait for an input from a user at the end of the script. The following code, when added at the end of the script, opens an extra window asking to press any key:
The function waitforbuttonpress() waits for a mouse click or a key being pressed and returns respectively False or True. The loop makes it sure that the program exists only in the second situation, so that you can interact with the windows using your mouse.
Note: the program stops only when a key is pressed while the extra window is active. This allows to interact with other windows without limitation.
ngsolve.webgui.Draw() does not show a picture
The problem
The command Draw(...) prints BaseWebGuiScene instead of showing a graphics
What happens
The WebGUI extension used by NGSolve has not been integrated with Jupyter, so that the notebook does not know what to do with them.
How to solve
Install the WebGUI extension with the following commands:
pip3 install webgui_jupyter_widgets jupyter nbextension install --user --py widgetsnbextension jupyter nbextension enable --user --py widgetsnbextension jupyter nbextension install --user --py webgui_jupyter_widgets jupyter nbextension enable --user --py webgui_jupyter_widgets