Files
GiTui/screens/welcome_screen.py

51 lines
1.3 KiB
Python

from textual.containers import Vertical, HorizontalGroup, Center
from textual.screen import Screen
from textual.app import ComposeResult
from textual.widgets import Static, Button
from textualeffects.widgets import EffectLabel, EffectType, effects
from screens.search_screen import SearchScreen
from widgets import Navbar
from random import choice
class WelcomeScreen(Screen):
DEFAULT_CSS = """
Center {
padding: 2;
width: 100%;
Static {
text-align: center;
}
EffectLabel {
text-style: bold;
min-width: 100%;
}
#buttons {
margin-top: 1;
align: center middle;
Button {
margin: 0 2;
}
}
}
"""
def on_button_pressed(self, event: Button.Pressed):
if event.button.id == "explore":
self.app.switch_screen(SearchScreen())
def compose(self) -> ComposeResult:
yield Navbar()
with Center():
with open("assets/banner.txt", "r") as f:
yield EffectLabel(text=f.read(), effect=choice(list(effects.keys())))
yield Static("[white]Gitea, in your terminal.")
with HorizontalGroup(id="buttons"):
yield Button("\uee45 Explore", variant="primary", flat=True, id="explore")