Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
24.79k stars 761 forks source link

Consider ampersand in queries #3512

Open willmcgugan opened 10 months ago

willmcgugan commented 10 months ago

It may be nice to add a syntax to queries which refers to the current widget.

For instance, if I want to get the immediate child of a widget, I could do this:

self.query("& > Child")

Currently that's rather awkward to implement.

We can also extend this to the CSS itself. i.e. ini a CSS or DEFAULT_CSS. For instance the following would style the widget without the need to specify its type again:

DEFAULT_CSS = """
& { border: heavy red}
"""

Currently, you have to do this:

DEFAULT_CSS = """
MyWidget { border: heavy red}
"""
davep commented 4 months ago

Closing as this was implemented as part of nested CSS.

github-actions[bot] commented 4 months ago

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

davep commented 4 months ago

Ignore that, reopening as this is different from nested CSS (was only half reading).