ipyvuetify icon indicating copy to clipboard operation
ipyvuetify copied to clipboard

Replace ipywidgets.Output with ipyvuetify

Open CnBDM-Su opened this issue 1 year ago • 7 comments

Is there any ipyvuetify component can be used to replace the ipwidgets.Output?

Ipywidgets.Output can capture all ipython output run under this component. eg:

import ipywidgets as widgets
out = widgets.Output()
with out:
    print('test')

CnBDM-Su avatar May 07 '24 03:05 CnBDM-Su

does this do the trick ?

import ipyvuetify as v 

v.Html(tag="div", children=["test"])

And then you can update the children member as much as you want.

12rambau avatar May 07 '24 09:05 12rambau

``> does this do the trick ?

import ipyvuetify as v 

v.Html(tag="div", children=["test"])

And then you can update the children member as much as you want.

Yes, if the children is easy like that, this works. But in my situation, I want to capture the plot rendered html from IPython. If I use ipywidgets, it is easy

import ipywidgets as widgets
from IPython.display import HTML
out = widgets.Output()
with out:
    fig_obj.show()
out

But seems there is no element which can capture ipython result automatically in ipyvuetify. Under your suggestion, I need to get the html script and rerender it as a v.html then it can be displayed. Seems it is not very convinent. Some thing like this.

import ipyvuetify as v
out = v.Html(tag="div", children=[])
fig_html = v.Html(tag='div', children=[fig_obj.return_html_script()])
out.children=[fig_html]
out

If I cannot restructure the html, is there any way I can render the plot?

CnBDM-Su avatar May 07 '24 16:05 CnBDM-Su

if the plot is not a DOM element you cannot display it using ipyvuetify. usualy i do interactive plots (bqplot, bokeh, plotly) that are DOM elements and can thus directly be added to the children list. Not sure it's possible with vanilla matplotlib.

12rambau avatar May 08 '24 20:05 12rambau

You can mix classic ipywidgets, do you can make the output widget a child of an ipyvuetify widget.

maartenbreddels avatar May 08 '24 20:05 maartenbreddels

@12rambau Can you provide one simple case of ployly? Then I can follow. Thanks

CnBDM-Su avatar May 09 '24 10:05 CnBDM-Su

@maartenbreddels Yeah, for now, I am doing like this.

CnBDM-Su avatar May 09 '24 10:05 CnBDM-Su

There is no other solution, this is how it should work. Ipyvuetify does not need to re implement features of other libraries, or its parent library. I hope this make sense?

maartenbreddels avatar May 09 '24 10:05 maartenbreddels