refactor AboutCommand into own file
This commit is contained in:
parent
2879d2abb1
commit
a885298d00
24
AboutCommand.py
Normal file
24
AboutCommand.py
Normal file
@ -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.'
|
||||||
|
)
|
19
bingo.py
19
bingo.py
@ -4,12 +4,12 @@ from textual.app import App, ComposeResult
|
|||||||
from textual.widgets import Header, Input, Static, Button
|
from textual.widgets import Header, Input, Static, Button
|
||||||
from textual.containers import Horizontal, Container
|
from textual.containers import Horizontal, Container
|
||||||
from textual.validation import Number
|
from textual.validation import Number
|
||||||
from textual.command import DiscoveryHit, Provider, Hits, Hit
|
|
||||||
from textual.reactive import reactive
|
from textual.reactive import reactive
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from BingoBoard import BingoBoard
|
from BingoBoard import BingoBoard
|
||||||
|
from AboutCommand import AboutCommand
|
||||||
|
|
||||||
MESSAGE = '''
|
MESSAGE = '''
|
||||||
Be excellent to each other!
|
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 Sidebar(Container):
|
||||||
'''Class to represent the sidebar'''
|
'''Class to represent the sidebar'''
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user