Draw requires additional arguments

I believe some changes were made to the Draw() interface in Jupyter, since my previous Draw commands stopped working and are now resulting in an error message.


from ngsolve import *
from ngsolve.webgui import Draw
from netgen.geom2d import unit_square

mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))


The error message reads:

TypeError Traceback (most recent call last)
5 mesh = Mesh(unit_square.GenerateMesh(maxh=0.2))
----> 7 Draw(mesh)

/opt/tljh/user/lib/python3.7/site-packages/ngsolve/webgui.py in Draw(mesh_or_func, mesh_or_none, name, order, min, max, draw_vol, draw_surf, autoscale, intpoints, deformation, interpolate_multidim, animate, clipping, vectors, js_code, eval_function, eval, filename, objects, nodal_p1, settings, width, height)
596 else:
597 # render scene using widgets.DOMWidget
→ 598 scene.Draw(width, height)
599 return scene
600 else:

TypeError: Draw() takes 1 positional argument but 3 were given

This never happend before. I would be grateful for any advice!


You need to upgrade webgui_jupyter_widgets:

pip install --upgrade webgui_jupyter_widgets
jupyter nbextension install --py webgui_jupyter_widgets

There was a new release adding width and height arguments (workaround for jupyter inside vscode, see Problem with Draw function, large scale - #7 by nilsansorgeeagleburg )


Thanks, that solved it!