summaryrefslogtreecommitdiff
path: root/rag/tui.py
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2025-08-25 00:06:19 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2025-08-25 00:06:19 +0200
commit28a1f5d4eddab6eb7c9ca77346c6fa9608856dd5 (patch)
tree563ffd32f1a6f5705c1fbf6230d5d226fd0e0e48 /rag/tui.py
parent6afba9079eebe867ac4f1b6073b5277513e7491b (diff)
Broken stateHEADmaster
Diffstat (limited to 'rag/tui.py')
-rw-r--r--rag/tui.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/rag/tui.py b/rag/tui.py
new file mode 100644
index 0000000..ead4f71
--- /dev/null
+++ b/rag/tui.py
@@ -0,0 +1,71 @@
+from textual import events
+from textual.app import App, ComposeResult
+from textual.containers import Vertical, Container, VerticalScroll
+from textual.widgets import Input, Label, Markdown, Static, TabbedContent, TabPane
+
+JESSICA = """
+# Lady Jessica
+
+Bene Gesserit and concubine of Leto, and mother of Paul and Alia.
+"""
+
+PAUL = """
+# Paul Atreides
+
+Son of Leto and Jessica.
+"""
+
+TEXT = """\
+Docking a widget removes it from the layout and fixes its position, aligned to either the top, right, bottom, or left edges of a container.
+
+Docked widgets will not scroll out of view, making them ideal for sticky headers, footers, and sidebars.
+
+"""
+
+class TabbedApp(App):
+ """An example of tabbed content."""
+
+ CSS_PATH = "static/styles.tcss"
+
+ BINDINGS = [
+ ("n", "show_tab('rag')", "Rag"),
+ ("e", "show_tab('settings')", "Settings"),
+ ]
+
+ def compose(self) -> ComposeResult:
+ """Compose app with tabbed content."""
+ # Add the TabbedContent widget
+ with Container(id="rag"):
+ with VerticalScroll(id="references"):
+ yield Static("test3", classes="context")
+ with VerticalScroll(id="history"):
+ yield Static(TEXT * 10, classes="output")
+ with Vertical(id="chat"):
+ yield Static("test2", classes="input")
+ # with TabbedContent(initial="rag"):
+ # with TabPane("RAG", id="rag"): # First tab
+ # # yield Input(placeholder=">>", id="chat")
+ # yield Static("test1", classes="chat")
+ # yield Static("test", classes="context")
+ # with TabPane("Settings", id="settings"):
+ # yield Markdown(JESSICA)
+ # with TabbedContent("Paul", "Alia"):
+ # yield TabPane("Paul", Label("First child"))
+ # yield TabPane("Alia", Label("Second child"))
+
+ def action_show_tab(self, tab: str) -> None:
+ """Switch to a new tab."""
+ self.get_child_by_type(TabbedContent).active = tab
+
+ def on_key(self, event: events.Key) -> None:
+ if event.key == "s":
+ self.action_show_tab("settings")
+ if event.key == "r":
+ self.action_show_tab("rag")
+ if event.key == "q":
+ self.exit()
+
+
+if __name__ == "__main__":
+ app = TabbedApp()
+ app.run()