#๐Ÿ”’ Change content layout with Tabs

5 messages ยท Page 1 of 1 (latest)

molten raven
#

code:
โจ```py
from textual.app import App
from textual.widgets import *

class SunDisk(App):

CSS = """
    Label {
    margin:1 1;
    width: 100%;
    height: 100%;
    background: $panel;
    border: tall $secondary;
    content-align: center middle;
    text-align: center;
}
"""

BINDINGS = [
    ("e", "exit", "Exit from the program."),
    ("c", "close", "Close a specific window from the tab menu."),
]

def on_mount(self):
    self.theme = "gruvbox"

def compose(self):
    yield Header(True, name="SunDisk Utility")
    yield Tabs(
        Tab("Welcome to SunDisk Utility", id="Welcome"),
        Tab("Disk Statistics", id="dstat"),
        Tab("File Explorer", id="fexpl"),
        Tab("Partition Manager (Admin req.)", id="pmanager"),
    )
    yield Label()
    yield Footer()

def on_tabs_tab_activated(self, event: Tabs.TabActivated):
    label = self.query_one(Label)
    if event.tab.id == "Welcome":
        label.update(
            "[bold]Welcome to SunDisk![/bold] \n SunDisk is a disk utility to provide easy access to disk utilities such as a file explorer and partition manager."
        )
I've made this class for my app, and I want to keep my event activated code, but I want to change it so that the layout of each tab is different rather than just having the same layout with each tab (which is what this code does) (it's also unfinished, but I want to ask for future purposes)
autumn echoBOT
#

@molten raven

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

fallen belfry
autumn echoBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.