positron icon indicating copy to clipboard operation
positron copied to clipboard

Python: Add support for additional widget types (in viewer or plots pane)

Open isabelizimm opened this issue 2 years ago • 5 comments

Once #1918 is merged, we will have basic support for the widgets such as ipywidgets, ipydatagrid, and ipyleaflet in the plot pane. Still not working ❌ is:

  • %matplotlib widget mode
  • bqplot
  • ipycanvas
  • pythreejs
  • ipytree

Here is a gist of all the different widgets, for testing purposes

CC: @jgutman

isabelizimm avatar Dec 06 '23 21:12 isabelizimm

@isabelizimm I imagine these were all tested prior to the switchover to the later version of html-manager, it might be worth us re-testing to see whether there are any changes in what works/what doesn't after the update -- we should also specify here the module version of the above widget types that we tested, since we know now that makes a difference to whether it's compatible or not

jgutman avatar Dec 11 '23 17:12 jgutman

In order to support matplotlib widgets and others that require a live Python kernel, we need to enable an actual non-stubbed RendererContext.

See current TODO in https://github.com/posit-dev/positron/blob/aa6476a862089ffa5b720ef37ca14f40bf175278/src/vs/workbench/contrib/positronOutputWebview/browser/notebookOutputWebviewServiceImpl.ts#L189-L193

and stubbed RendererContext https://github.com/posit-dev/positron/blob/aa6476a862089ffa5b720ef37ca14f40bf175278/src/vs/workbench/contrib/positronOutputWebview/browser/notebookOutputWebviewServiceImpl.ts#L208-L219

Also see how this gets handled for ipywidgets in the jupyter extension https://github.com/microsoft/vscode-jupyter/blob/4ca00b28cf3b890593e9c84d73b65e67f51a8061/src/webviews/webview-side/ipywidgets/renderer/index.ts#L244-L257

jgutman avatar Jan 16 '24 19:01 jgutman

Does this cover plotly / bokeh plots?

peekxc avatar Jul 05 '24 19:07 peekxc

@peekxc I believe that plotly works:

plotly

Are you observing something different?

For bokeh, I do not believe we have that working correctly right now (the plot opens in an external browser).

juliasilge avatar Jul 05 '24 20:07 juliasilge

For bokeh, I do not believe we have that working correctly right now (the plot opens in an external browser).

Ahh, I was talking about bokeh; sorry, I assumed the behavior would be identical

Screenshot 2024-07-06 at 9 21 29 AM

peekxc avatar Jul 06 '24 13:07 peekxc

https://github.com/posit-dev/positron/pull/4172 and https://github.com/posit-dev/positron/pull/4208 should get the following widgets working:

  • anywidget
  • bqplot
  • drawdata
  • ipydatagrid
  • ipyleaflet
  • ipympl
  • ipytree
  • ipywidgets – all widget types except Output which needs special handling
  • pythreejs

There may be smaller issues with those, which we can log separately.

I haven't yet figured out why ipycanvas isn't working.

seeM avatar Aug 01 '24 18:08 seeM

Verified Fixed

Positron Version(s) : 2024.08.0-24
OS Version          : OSX

Test scenario(s)

Validated with everything here: https://gist.github.com/isabelizimm/02f7ba16dc74b202935f6d3e9ed6b892 Everything looks good except ipycanvas, which is noted above

Link(s) to TestRail test cases run or created: N/A

testlabauto avatar Aug 09 '24 16:08 testlabauto