Code Monkey home page Code Monkey logo

Comments (3)

davep avatar davep commented on June 15, 2024 1

This would seem to be down to the internals of the underlying OptionList not being fully-built until the widget itself is fully displayed (which it won't be in on_mount). Compare the above with:

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).

from textual.

willmcgugan avatar willmcgugan commented on June 15, 2024 1

This should work. The Mount message is a guarantee that child widgets are ready to be used. We don't want to deviate from that.

from textual.

rodrigogiraoserrao avatar rodrigogiraoserrao commented on June 15, 2024

Given Dave's clarification, I'm not sure we can do a lot here...
Maybe in get_option raise a different exception saying it's too early to query options by ID?

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.