You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a python object of type fig.
This fig is used to initialize the ReactWidget.
In the init function, the figure is processed to a string and then later used in the my_message traitlet.
Here is an example on how I would do that:
Question: is this a best practice solution that we could provide in the docs like this?
importmatplotlib.pyplotaspltfig, ax=plt.subplots(figsize=(6, 2))
ax.plot([1,2], [10,20], c="orange");
###importipyreactfromtraitletsimportUnicodeclassTldrawWidget(ipyreact.ReactWidget):
def__init__(self,my_figure=None, **kwargs):
my_str=f"the size of the figure is {my_figure.get_size_inches()}"super().__init__(**kwargs, my_message=my_str)
my_message=Unicode("").tag(sync=True)
_esm=""" import * as React from "react"; export default function MyButton({my_message}) { return < button > {my_message} < /button> };"""TldrawWidget(my_figure=fig)
The text was updated successfully, but these errors were encountered:
I don't like having to define both the default and the observe personally. In Solara we will implement this using reactive variables that auto update based on its dependencies, but this would be the traitlets way :)
Please close if this answers your question! Otherwise I'm happy to help again
I have a python object of type
fig
.This
fig
is used to initialize the ReactWidget.In the init function, the figure is processed to a string and then later used in the
my_message
traitlet.Here is an example on how I would do that:
Question: is this a best practice solution that we could provide in the docs like this?
The text was updated successfully, but these errors were encountered: