39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from textual.containers import Vertical
|
|
from textual.widgets import Button, ContentSwitcher
|
|
|
|
|
|
class SidebarButton(Button):
|
|
DEFAULT_CSS = """
|
|
SidebarButton {
|
|
max-width: 100%;
|
|
margin-bottom: 1;
|
|
}
|
|
"""
|
|
|
|
class HomeSidebar(Vertical):
|
|
DEFAULT_CSS = """
|
|
HomeSidebar {
|
|
width: 11;
|
|
background: $boost;
|
|
border-right: $surface-lighten-1 tall;
|
|
padding: 1;
|
|
dock: left;
|
|
margin-top: 1;
|
|
}
|
|
"""
|
|
|
|
def on_button_pressed(self, event: Button.Pressed):
|
|
content_switcher: ContentSwitcher = self.screen.query_one(ContentSwitcher)
|
|
|
|
match event.button.id:
|
|
case "home-btn":
|
|
content_switcher.current = "home-info"
|
|
case "channels-btn":
|
|
content_switcher.current = "channels-list"
|
|
case "settings-btn":
|
|
content_switcher.current = "settings"
|
|
|
|
def compose(self):
|
|
yield SidebarButton("", tooltip="Home", id="home-btn")
|
|
yield SidebarButton("", tooltip="Channels", id="channels-btn")
|
|
yield SidebarButton("", tooltip="Settings", id="settings-btn") |