|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from textual.app import App, ComposeResult
|
|
|
|
from textual.widgets import Header
|
|
|
|
from textual.reactive import reactive
|
|
|
|
|
|
|
|
from BingoDisplay import BingoDisplay
|
|
|
|
from AboutCommand import AboutCommand
|
|
|
|
from Sidebar import Sidebar
|
|
|
|
|
|
|
|
class BingoApp(App):
|
|
|
|
'''
|
|
|
|
A Textual app to run a Bingo board.
|
|
|
|
|
|
|
|
Contains the sidebar, header, and BingoDisplay.
|
|
|
|
'''
|
|
|
|
|
|
|
|
CSS_PATH = "bingo.tcss"
|
|
|
|
COMMANDS = App.COMMANDS | {AboutCommand}
|
|
|
|
AUTO_FOCUS = 'Input'
|
|
|
|
|
|
|
|
show_sidebar = reactive(False)
|
|
|
|
|
|
|
|
def action_toggle_sidebar(self) -> None:
|
|
|
|
'''Toggle the sidebar on or off'''
|
|
|
|
sidebar = self.query_one(Sidebar)
|
|
|
|
self.set_focus(None)
|
|
|
|
if sidebar.has_class("-hidden"):
|
|
|
|
sidebar.remove_class("-hidden")
|
|
|
|
sidebar.button.disabled = False
|
|
|
|
else:
|
|
|
|
if sidebar.query("*:focus"):
|
|
|
|
self.screen.set_focus(None)
|
|
|
|
sidebar.add_class("-hidden")
|
|
|
|
sidebar.button.disabled = True
|
|
|
|
|
|
|
|
def compose(self) -> ComposeResult:
|
|
|
|
'''Create child widgets for the app.'''
|
|
|
|
yield Sidebar(classes="-hidden")
|
|
|
|
yield Header(show_clock=True)
|
|
|
|
yield BingoDisplay()
|
|
|
|
|
|
|
|
def on_mount(self) -> None:
|
|
|
|
'''Set title of the app'''
|
|
|
|
self.title = 'CCC Bingo'
|
|
|
|
self.sub_title = 'GPN22 Edition'
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app = BingoApp()
|
|
|
|
app.run()
|