From 24e85d7005f50ca2f3bdf91a0665a26fa387bb61 Mon Sep 17 00:00:00 2001 From: Maveno Date: Tue, 24 Sep 2024 19:01:58 +0200 Subject: [PATCH] Shows Editor Screen vis --- .gitignore | 1 + bin/ffx.py | 87 +------------------------------------ bin/ffx/__init__.py | 0 bin/ffx/dashboard_screen.py | 16 +++++++ bin/ffx/help_screen.py | 12 +++++ bin/ffx/modes_app.py | 39 +++++++++++++++++ bin/ffx/settings_screen.py | 11 +++++ bin/ffx/shows_screen.py | 85 ++++++++++++++++++++++++++++++++++++ bin/ffx/warning_screen.py | 11 +++++ 9 files changed, 176 insertions(+), 86 deletions(-) create mode 100644 .gitignore create mode 100644 bin/ffx/__init__.py create mode 100644 bin/ffx/dashboard_screen.py create mode 100644 bin/ffx/help_screen.py create mode 100644 bin/ffx/modes_app.py create mode 100644 bin/ffx/settings_screen.py create mode 100644 bin/ffx/shows_screen.py create mode 100644 bin/ffx/warning_screen.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/bin/ffx.py b/bin/ffx.py index 2bbcda2..58b1fdd 100755 --- a/bin/ffx.py +++ b/bin/ffx.py @@ -2,10 +2,7 @@ import os, sys, subprocess, json, click, time, re -from textual.app import App, ComposeResult -from textual.screen import Screen -from textual.widgets import Header, Footer, Placeholder, Label - +from ffx.modes_app import ModesApp VERSION='0.1.0' @@ -56,88 +53,6 @@ SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z] SUBTITLE_FILE_EXTENSION = 'vtt' -class ShowsScreen(Screen): - - def __init__(self): - super().__init__() - - context = self.app.getContext() - context['dashboard'] = 'dashboard' - - def compose(self) -> ComposeResult: - yield Header(show_clock=True) - yield Placeholder("Shows Screen") - yield Footer() - - -class DashboardScreen(Screen): - - def __init__(self): - super().__init__() - - context = self.app.getContext() - context['dashboard'] = 'dashboard' - - def compose(self) -> ComposeResult: - yield Header(show_clock=True) - yield Placeholder("Dashboard Screen") - yield Footer() - -class WarningScreen(Screen): - def __init__(self): - super().__init__() - context = self.app.getContext() - def compose(self) -> ComposeResult: - yield Label("Warning! This file is not compliant to the defined source schema!") - yield Footer() - - -class SettingsScreen(Screen): - def __init__(self): - super().__init__() - context = self.app.getContext() - def compose(self) -> ComposeResult: - yield Placeholder("Settings Screen") - yield Footer() - - -class HelpScreen(Screen): - def __init__(self): - super().__init__() - context = self.app.getContext() - def compose(self) -> ComposeResult: - yield Placeholder("Help Screen") - yield Footer() - - -class ModesApp(App): - - BINDINGS = [ - ("q", "quit()", "Quit"), - # ("d", "switch_mode('dashboard')", "Dashboard"), - # ("s", "switch_mode('settings')", "Settings"), - # ("h", "switch_mode('help')", "Help"), - ] - - MODES = { - "warning": WarningScreen, - "dashboard": DashboardScreen, - "settings": SettingsScreen, - "help": HelpScreen, - } - - - def __init__(self, context = {}): - super().__init__() - self.context = context - - def on_mount(self) -> None: - self.switch_mode("warning") - - def getContext(self): - return self.context - - def executeProcess(commandSequence): process = subprocess.Popen(commandSequence, stdout=subprocess.PIPE, stderr=subprocess.PIPE) diff --git a/bin/ffx/__init__.py b/bin/ffx/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/ffx/dashboard_screen.py b/bin/ffx/dashboard_screen.py new file mode 100644 index 0000000..31305a3 --- /dev/null +++ b/bin/ffx/dashboard_screen.py @@ -0,0 +1,16 @@ +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Header, Footer, Placeholder, Label + +class DashboardScreen(Screen): + + def __init__(self): + super().__init__() + + context = self.app.getContext() + context['dashboard'] = 'dashboard' + + def compose(self) -> ComposeResult: + yield Header(show_clock=True) + yield Placeholder("Dashboard Screen") + yield Footer() diff --git a/bin/ffx/help_screen.py b/bin/ffx/help_screen.py new file mode 100644 index 0000000..24928b7 --- /dev/null +++ b/bin/ffx/help_screen.py @@ -0,0 +1,12 @@ +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Header, Footer, Placeholder, Label + +class HelpScreen(Screen): + def __init__(self): + super().__init__() + context = self.app.getContext() + def compose(self) -> ComposeResult: + yield Placeholder("Help Screen") + yield Footer() + diff --git a/bin/ffx/modes_app.py b/bin/ffx/modes_app.py new file mode 100644 index 0000000..760c9e9 --- /dev/null +++ b/bin/ffx/modes_app.py @@ -0,0 +1,39 @@ +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Header, Footer, Placeholder, Label + +from .shows_screen import ShowsScreen +from .warning_screen import WarningScreen +from .dashboard_screen import DashboardScreen +from .settings_screen import SettingsScreen +from .help_screen import HelpScreen + +class ModesApp(App): + + TITLE = "FFX" + + BINDINGS = [ + ("q", "quit()", "Quit"), + # ("d", "switch_mode('dashboard')", "Dashboard"), + # ("s", "switch_mode('settings')", "Settings"), + # ("h", "switch_mode('help')", "Help"), + ] + + MODES = { + "shows": ShowsScreen, + "warning": WarningScreen, + "dashboard": DashboardScreen, + "settings": SettingsScreen, + "help": HelpScreen, + } + + + def __init__(self, context = {}): + super().__init__() + self.context = context + + def on_mount(self) -> None: + self.switch_mode("shows") + + def getContext(self): + return self.context diff --git a/bin/ffx/settings_screen.py b/bin/ffx/settings_screen.py new file mode 100644 index 0000000..9f6298f --- /dev/null +++ b/bin/ffx/settings_screen.py @@ -0,0 +1,11 @@ +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Header, Footer, Placeholder, Label + +class SettingsScreen(Screen): + def __init__(self): + super().__init__() + context = self.app.getContext() + def compose(self) -> ComposeResult: + yield Placeholder("Settings Screen") + yield Footer() diff --git a/bin/ffx/shows_screen.py b/bin/ffx/shows_screen.py new file mode 100644 index 0000000..18675b9 --- /dev/null +++ b/bin/ffx/shows_screen.py @@ -0,0 +1,85 @@ + +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button +from textual.containers import Grid, Horizontal + + +class ShowsScreen(Screen): + + CSS = """ + + Grid { + grid-size: 1; + grid-rows: 2 auto; + height: 100%; + width: 100%; + padding: 1; + } + + #top { + height: 1; + } + + + #two { + column-span: 2; + row-span: 2; + tint: magenta 40%; + } + + .box { + height: 100%; + border: solid green; + } + """ + + BINDINGS = [ + ("q", "quit()", "Quit"), + ("e", "switch_mode('settings')", "Edit Show"), + ("n", "switch_mode('dashboard')", "New Show") + # ("h", "switch_mode('help')", "Help"), + ] + + def __init__(self): + super().__init__() + + context = self.app.getContext() + context['dashboard'] = 'dashboard' + + def compose(self): + + # Create the DataTable widget + table = DataTable() + + # Define the columns with headers + table.add_column("ID", width=10) + table.add_column("Name", width=20) + table.add_column("Age", width=10) + table.add_column("Country", width=20) + + table.cursor_type = 'row' + + # Sample data for rows + data = [ + (1, "John Doe", 28, "USA"), + (2, "Jane Smith", 34, "Canada"), + (3, "Alice Johnson", 29, "UK"), + (4, "Bob Brown", 45, "Australia"), + (5, "Charlie Davis", 23, "USA"), + ] + + # Add rows to the table + for i in range(20): + for row in data: + table.add_row(*map(str, row)) # Convert each element to a string before adding + + yield Header() + + with Grid(): + + yield Static("Shows") # , classes="box" + + yield table + + yield Footer() diff --git a/bin/ffx/warning_screen.py b/bin/ffx/warning_screen.py new file mode 100644 index 0000000..1bed7f5 --- /dev/null +++ b/bin/ffx/warning_screen.py @@ -0,0 +1,11 @@ +from textual.app import App, ComposeResult +from textual.screen import Screen +from textual.widgets import Header, Footer, Placeholder, Label + +class WarningScreen(Screen): + def __init__(self): + super().__init__() + context = self.app.getContext() + def compose(self) -> ComposeResult: + yield Label("Warning! This file is not compliant to the defined source schema!") + yield Footer()