Skip to content

How to make a layour from state #5178

Answered by MrNemo64
MrNemo64 asked this question in Q&A
Discussion options

You must be logged in to vote

I was trying to hold onto a reference of the components to be able to use their methods. After looking thru the examples folder I was able to figure out that the way to do this is using the query_one method so I did some refactoring now it works!

class View(App):
    async def on_mount(self):
        logger = self.query_one(LogView)
        mapa = self.query_one(MapView)
        taxi = Taxi(logger, self.query_one(ViewSensores), mapa)
        await taxi.iniciar()
    
    def compose(self) -> ComposeResult:
        yield Horizontal(
            VerticalScroll(MapView()),
            Vertical(
                VerticalScroll(LogView()), 
                ViewSensores()
            )
        )…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MrNemo64
Comment options

Answer selected by MrNemo64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants