Skip to content

[Q] Setting a center middle aligned widget's offset #1557

Answered by davep
anzhi0708 asked this question in Q&A
Discussion options

You must be logged in to vote

I think what you're trying to do here is an ideal use for layers. If I'm doing something like this I tend to wrap each "collection" of things that need to work together in a main container, and then place those in different layers. So, if I'm to follow your example above correctly, I'd likely start out like this:

from textual.app        import App, ComposeResult
from textual.containers import Vertical
from textual.widgets    import Header, Footer, Button

class SidebarExample( App[ None ] ):

    CSS = """
    Screen {
        layers: base sidebar;
    }

    #base {
        align: center middle;
        layer: base;
    }

    #sidebar {
        layer: sidebar;
        border: round red;

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by anzhi0708
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