Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_child_by_id and get_widget_by_id #1146

Merged
merged 19 commits into from
Nov 16, 2022
Merged

Add get_child_by_id and get_widget_by_id #1146

merged 19 commits into from
Nov 16, 2022

Conversation

darrenburns
Copy link
Member

@darrenburns darrenburns commented Nov 9, 2022

  • Maintains dict of ID -> Widget inside the NodeList for quick access children by ID
  • Removes DOMNode.get_child
  • Removes App.get_child
  • Adds Widget.get_child_by_id
  • Adds App.get_child_by_id (delegates to self.screen.get_child_by_id)
  • Adds Widget.get_widget_by_id
  • Adds App.get_widget_by_id (delegates to self.screen.get_widget_by_id)

@darrenburns darrenburns marked this pull request as ready for review November 9, 2022 13:55
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted an potential issue with duplicate IDs.

src/textual/_node_list.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_widget_by_id may be more complicated than in appears...

src/textual/_node_list.py Show resolved Hide resolved
src/textual/_node_list.py Outdated Show resolved Hide resolved
src/textual/widget.py Outdated Show resolved Hide resolved
src/textual/widget.py Show resolved Hide resolved
@willmcgugan
Copy link
Collaborator

@darrenburns Could you do a quick pass on this one next change you get.

@darrenburns darrenburns merged commit df37a9b into main Nov 16, 2022
@darrenburns darrenburns deleted the get-widget-by-id branch November 16, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants