Skip to content

select() may generate an identifier that is unusable #23

@ryan-summers

Description

@ryan-summers

When using the select() function, the provided path cannot necessarily be used for a subsequent select() (or getattr(), etc) and will not properly select any items.

This appears to arise because the XPATH index syntax is slightly different than the path_to syntax use different semantics.

Specifically, the current to_path syntax uses the index of the element in the child widgets list.

def path_to(widget):
from kivy.core.window import Window
root = Window
if widget.parent is root or widget.parent == widget or not widget.parent:
return "/{}".format(widget.__class__.__name__)
return "{}/{}[{}]".format(
path_to(widget.parent), widget.__class__.__name__,
widget.parent.children.index(widget))

However, the XPATH syntax uses the index into the list of previously filtered items. This means that if any items are filtered out, the index used by XPATH and the index into the Kivy child list are no longer equivalent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions