Files
mesh-network-project/desktop_app/ui/widgets/channels_list.py

55 lines
1.5 KiB
Python

from textual.containers import VerticalScroll, Vertical, HorizontalGroup
from textual.widgets import Static, Button, Rule
from api.channel import Channel
class ChannelView(Button):
DEFAULT_CSS = """
ChannelView {
margin: 0 1;
background: $boost;
border: $surface-lighten-1 tall;
content-align: left middle;
text-align: left;
width: 30;
}
"""
def __init__(self, channel: Channel):
super().__init__(" [b]" + channel.name, flat=True)
self.channel = channel
class ChannelsList(Vertical):
DEFAULT_CSS = """
ChannelsList {
Rule {
color: $surface-lighten-1;
}
#buttons {
margin-bottom: 1;
Button {
margin: 0 1;
}
}
}
"""
def compose(self):
with VerticalScroll():
yield Static("channels", classes="banner")
yield ChannelView(Channel("test channel", "AQ=="))
yield ChannelView(Channel("test channel", "AQ=="))
yield ChannelView(Channel("test channel", "AQ=="))
yield ChannelView(Channel("test channel", "AQ=="))
yield ChannelView(Channel("test channel", "AQ=="))
yield ChannelView(Channel("test channel", "AQ=="))
yield ChannelView(Channel("test channel", "AQ=="))
yield Rule()
with HorizontalGroup(id="buttons"):
yield Button("Create Channel")
yield Button("Advertise")