Skip to content

Commit

Permalink
🔨 Base the main screen on EnhancedScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Feb 4, 2025
1 parent 5ca2eb5 commit 035f3a3
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions src/peplum/app/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
# Textual imports.
from textual import on, work
from textual.app import ComposeResult
from textual.command import CommandPalette
from textual.message import Message
from textual.reactive import var
from textual.screen import Screen
from textual.widgets import Footer, Header

##############################################################################
# Textual enhanced imports.
from textual_enhanced.commands import Command, CommandsProvider, Help, Quit
from textual_enhanced.commands import Command, Help, Quit
from textual_enhanced.dialogs import HelpScreen, ModalInput
from textual_enhanced.screen import EnhancedScreen

##############################################################################
# Local imports.
Expand Down Expand Up @@ -82,7 +81,7 @@


##############################################################################
class Main(Screen[None]):
class Main(EnhancedScreen[None]):
"""The main screen for the application."""

TITLE = f"Peplum v{__version__}"
Expand Down Expand Up @@ -278,19 +277,6 @@ def watch_active_peps(self) -> None:
StatusCommands.active_peps = self.active_peps
TypeCommands.active_peps = self.active_peps

def _show_palette(self, provider: type[CommandsProvider]) -> None:
"""Show a particular command palette.
Args:
provider: The commands provider for the palette.
"""
self.app.push_screen(
CommandPalette(
providers=(provider,),
placeholder=provider.prompt(),
)
)

@on(PEPsView.PEPHighlighted)
def select_pep(self, message: PEPsView.PEPHighlighted) -> None:
"""Make the currently-selected PEP the one to view."""
Expand Down Expand Up @@ -380,7 +366,7 @@ def visit_pep(self, command: VisitPEP) -> None:
@on(FindPEP)
def action_find_pep_command(self) -> None:
"""Find a PEP and jump to it."""
self._show_palette(PEPsCommands)
self.show_palette(PEPsCommands)

@on(Search)
@work
Expand All @@ -394,22 +380,22 @@ async def action_search_command(self) -> None:
@on(SearchAuthor)
def action_search_author_command(self) -> None:
"""Search for an author and use them as a filter."""
self._show_palette(AuthorCommands)
self.show_palette(AuthorCommands)

@on(SearchPythonVersion)
def action_search_python_version_command(self) -> None:
"""Search for a Python version and then use it as a filter."""
self._show_palette(PythonVersionCommands)
self.show_palette(PythonVersionCommands)

@on(SearchStatus)
def action_search_status_command(self) -> None:
"""Search for a status and use it as a filter."""
self._show_palette(StatusCommands)
self.show_palette(StatusCommands)

@on(SearchType)
def action_search_type_command(self) -> None:
"""Search for a PEP type and then use it as a filter."""
self._show_palette(TypeCommands)
self.show_palette(TypeCommands)

@on(RedownloadPEPs)
def action_redownload_peps_command(self) -> None:
Expand Down

0 comments on commit 035f3a3

Please sign in to comment.