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
In lot of cases I'm forced to use variable for every single widget that I will modify in the future. It's specifically enoying when the components are for examples V.Html(tag="tr") from a table. I implemented a method to reach child or children of a widget using key, value pair.
defget_children(
self,
widget: Optional[v.VuetifyWidget] =None,
klass: Optional[Type[v.VuetifyWidget]] =None,
attr: str="",
value: str="",
id_: str="",
elements: Optional[list] =None,
) ->List[v.VuetifyWidget]:
r"""Recursively search for every element matching the specifications. multiple parameters can be used to search for matching elements. no error is raised if nothing is found. Args: widget: the widget to search into klass: the vuetify widget class to look for . Leave empty for any. attr: the attribute to look at. leave empty for no search value: the value of the attr. ignored if attr is not set elements: the list used to store found elements Returns: List containing all matching elements Retrieve all children elements that matches with the given id\_. Args: id\_ (str, optional): attribute id to compare with. Returns: list with all matching elements if there are more than one, otherwise will return the matching element. """# id_ was the previous variable it should continue working in this implementation# remove kwargs when this will be deprecatedifid_!="":
attr, value= ("id", id_)
warnings.warn(
'"id_" is a deprecated argument, use an ("attr", "value") pair instead',
DeprecationWarning,
)
# init the element listelements= [] ifelementsisNoneelseelements# init the widgetwidget=selfifwidgetisNoneelsewidgetforwinwidget.children:
# exit if children is not a widget (str, DOM objects.. etc)ifnotisinstance(w, (v.VuetifyWidget, v.Html)):
continue# compare the widget with requirements# if no klass is specified, use both vuetifyWidget and Html objectsis_klass= (
isinstance(w, klass)
ifklasselseisinstance(w, ((v.VuetifyWidget, v.Html)))
)
# using "niet" as default so that result is True if attr is Falsy# "niet" is very unlikely to be used compared to None, False, "none"...is_val=w.attributes.get(attr, "niet") ==valueifattrandvalueelseTruenot (is_klassandis_val) orelements.append(w)
# always search for nested elementselements=self.get_children(w, klass, attr, value, id_, elements)
returnelements
Would you see an interest to implement (and refine) this method in ipyvue ?
The text was updated successfully, but these errors were encountered:
Although this sits in Reacton, it actually is very widget oriented.
However, I'm not sure where this needs to go. I think it is more general than ipyvue right? Almost sounds like it should go into ipywidgets.
As I was requested to implemented the class_list management member (#40) here instead of ipywidgets I assumed that was the correct place for generic method. It would then become available for every widgets generated in ipywidget.
In lot of cases I'm forced to use variable for every single widget that I will modify in the future. It's specifically enoying when the components are for examples V.Html(tag="tr") from a table. I implemented a method to reach child or children of a widget using key, value pair.
Would you see an interest to implement (and refine) this method in ipyvue ?
The text was updated successfully, but these errors were encountered: