-
Notifications
You must be signed in to change notification settings - Fork 815
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
get_option in SelectionList not working #3903
Comments
This would seem to be down to the internals of the underlying from textual.app import App
from textual.widgets import SelectionList
from textual.widgets.selection_list import Selection
class QuickApp(App):
BINDINGS = [
("f", "find"),
]
def compose(self):
yield SelectionList(
Selection("a", 1, id="a")
)
def action_find(self):
self.notify(f"{self.query_one(SelectionList).get_option('a')}")
if __name__ == "__main__":
QuickApp().run() Once the app is up and running, press f. (aside: IIRC this isn't the only widget in Textual where this can be a gotcha). |
Given Dave's clarification, I'm not sure we can do a lot here... |
This should work. The |
This builds option IDs earlier than the first render, which means that IDs can be used to fetch options earlier. Related issue: #3903.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
The function
get_option
inSelectionList
does not work as intended. The following raisesOptionDoesNotExist
I looked through the code and it looks like
_option_ids
is never set inOptionList
but gets evaluated inget_option_index
.The text was updated successfully, but these errors were encountered: