widgetti / ipyvuetify

Jupyter widgets based on vuetify UI components
MIT License
348 stars 59 forks source link

Replace ipywidgets.Output with ipyvuetify #316

Open CnBDM-Su opened 6 months ago

CnBDM-Su commented 6 months ago

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')
12rambau commented 6 months ago

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.

CnBDM-Su commented 6 months ago

``> 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?

12rambau commented 6 months ago

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.

maartenbreddels commented 6 months ago

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

CnBDM-Su commented 6 months ago

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

CnBDM-Su commented 6 months ago

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

maartenbreddels commented 6 months ago

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?