From a885298d00a4e08caaac278d40edbe7acbc1cf5a Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Sun, 19 May 2024 15:21:44 +0200 Subject: [PATCH] refactor AboutCommand into own file --- AboutCommand.py | 24 ++++++++++++++++++++++++ bingo.py | 19 +------------------ 2 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 AboutCommand.py diff --git a/AboutCommand.py b/AboutCommand.py new file mode 100644 index 0000000..10ba9e9 --- /dev/null +++ b/AboutCommand.py @@ -0,0 +1,24 @@ +from textual.command import DiscoveryHit, Provider, Hits, Hit + +class AboutCommand(Provider): + '''Class to represent the About command in the menu''' + + async def discover(self) -> Hits: + yield DiscoveryHit( + display='About', + command=self.app.action_toggle_sidebar, + help='Link to repo etc.' + ) + + async def search(self, query: str) -> Hits: + '''Called when the search functionality is used''' + matcher = self.matcher(query) + command = "About" + score = matcher.match(command) + if score > 0: + yield Hit( + score, + matcher.highlight(command), + self.app.action_toggle_sidebar, + 'Link to repo etc.' + ) diff --git a/bingo.py b/bingo.py index e8d15f9..e778f06 100644 --- a/bingo.py +++ b/bingo.py @@ -4,12 +4,12 @@ from textual.app import App, ComposeResult from textual.widgets import Header, Input, Static, Button from textual.containers import Horizontal, Container from textual.validation import Number -from textual.command import DiscoveryHit, Provider, Hits, Hit from textual.reactive import reactive from datetime import datetime from BingoBoard import BingoBoard +from AboutCommand import AboutCommand MESSAGE = ''' Be excellent to each other! @@ -23,23 +23,6 @@ Built using [@click="app.open_link('https://textual.textualize.io/')"]Textual[/] ''' -class AboutCommand(Provider): - '''Class to represent the About command in the menu''' - - async def discover(self) -> Hits: - yield DiscoveryHit(display='About', command=self.app.action_toggle_sidebar, help='Link to repo etc.') - - def show_about(self) -> None: - pass - - async def search(self, query: str) -> Hits: - '''Called when the search functionality is used''' - matcher = self.matcher(query) - command = "About" - score = matcher.match(command) - if score > 0: - yield Hit(score, matcher.highlight(command), self.app.action_toggle_sidebar, 'Link to repo etc.') - class Sidebar(Container): '''Class to represent the sidebar'''