forked from PasarGuard/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasarguard-tui.py
More file actions
53 lines (39 loc) · 1.38 KB
/
pasarguard-tui.py
File metadata and controls
53 lines (39 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env python3
from textual.app import App, ComposeResult
from textual.widgets import Footer, Header
from config import DEBUG
from tui.help import HelpModal
class PasarGuardTUI(App):
"""A Textual app to manage pasarguard"""
CSS_PATH = "tui/style.tcss"
ENABLE_COMMAND_PALETTE = DEBUG
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.theme = "textual-dark"
BINDINGS = [
("ctrl+c", "quit", "Quit"),
("q", "quit", "Quit"),
("?", "help", "Help"),
]
def compose(self) -> ComposeResult:
"""Create child widgets for the app."""
from tui.admin import AdminContent
yield Header()
yield AdminContent(id="admin-content")
yield Footer()
def on_mount(self) -> None:
"""Called when the app is mounted."""
self.action_show_admins()
def action_show_admins(self) -> None:
"""Show the admins section."""
self.query_one("#admin-content")
async def action_quit(self) -> None:
"""An action to quit the app."""
self.exit()
def action_help(self) -> None:
"""Show help information in a modal."""
admin_content = self.query_one("#admin-content")
self.push_screen(HelpModal(self.BINDINGS, admin_content.BINDINGS))
if __name__ == "__main__":
app = PasarGuardTUI()
app.run()