refactor Sidebar into own file
This commit is contained in:
parent
a885298d00
commit
cfe7e49a9e
31
Sidebar.py
Normal file
31
Sidebar.py
Normal file
@ -0,0 +1,31 @@
|
||||
from textual.containers import Container
|
||||
from textual.app import ComposeResult
|
||||
from textual.widgets import Static, Button
|
||||
|
||||
MESSAGE = '''
|
||||
Be excellent to each other!
|
||||
|
||||
Made with :red_heart: by Panki
|
||||
|
||||
[@click="app.open_link('https://tty0.social/@panki')"]Mastodon:[/] tty0.social/@panki
|
||||
[@click="app.open_link('https://git.theresno.cloud/panki/bingo-cli')"]Source:[/] git.theresno.cloud/panki/bingo-cli
|
||||
|
||||
Built using [@click="app.open_link('https://textual.textualize.io/')"]Textual[/]
|
||||
|
||||
'''
|
||||
|
||||
class Sidebar(Container):
|
||||
'''Class to represent the sidebar'''
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
'''Create the widgets that make up the sidebar'''
|
||||
yield Static('CCC Bingo', classes='title')
|
||||
yield Static(MESSAGE, classes='message')
|
||||
self.button = Button('< Back', variant='primary', classes='btn_sidebar')
|
||||
self.button.disabled = True
|
||||
yield self.button
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
'''Closes the sidebar'''
|
||||
self.app.action_toggle_sidebar()
|
||||
|
30
bingo.py
30
bingo.py
@ -2,7 +2,7 @@
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Header, Input, Static, Button
|
||||
from textual.containers import Horizontal, Container
|
||||
from textual.containers import Horizontal
|
||||
from textual.validation import Number
|
||||
from textual.reactive import reactive
|
||||
|
||||
@ -10,33 +10,7 @@ from datetime import datetime
|
||||
|
||||
from BingoBoard import BingoBoard
|
||||
from AboutCommand import AboutCommand
|
||||
|
||||
MESSAGE = '''
|
||||
Be excellent to each other!
|
||||
|
||||
Made with :red_heart: by Panki
|
||||
|
||||
[@click="app.open_link('https://tty0.social/@panki')"]Mastodon:[/] tty0.social/@panki
|
||||
[@click="app.open_link('https://git.theresno.cloud/panki/bingo-cli')"]Source:[/] git.theresno.cloud/panki/bingo-cli
|
||||
|
||||
Built using [@click="app.open_link('https://textual.textualize.io/')"]Textual[/]
|
||||
|
||||
'''
|
||||
|
||||
class Sidebar(Container):
|
||||
'''Class to represent the sidebar'''
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
'''Create the widgets that make up the sidebar'''
|
||||
yield Static('CCC Bingo', classes='title')
|
||||
yield Static(MESSAGE, classes='message')
|
||||
self.button = Button('< Back', variant='primary', classes='btn_sidebar')
|
||||
self.button.disabled = True
|
||||
yield self.button
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
'''Closes the sidebar'''
|
||||
self.app.action_toggle_sidebar()
|
||||
from Sidebar import Sidebar
|
||||
|
||||
class BingoApp(App):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user