-
Notifications
You must be signed in to change notification settings - Fork 28
/
textual-app.py
56 lines (48 loc) · 1.86 KB
/
textual-app.py
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
54
55
56
from textual.app import App
from ui.logic import MicroAgentsLogic
from ui.logging import LoggingHandler
from ui.components import MicroAgentsHeader, MicroAgentsFooter, MicroAgentsStatusbar, MicroAgentsInput, MicroAgentsTable
from ui.constants import CSS, BINDINGS
from textual.widgets import RichLog, TabbedContent
from textual.widgets import Footer, Header, Input, RichLog, TabbedContent, TabPane
class MicroAgentsApp(App):
CSS = CSS
BINDINGS = BINDINGS
def __init__(self):
super().__init__()
self.setup_ui_components()
self.logic = MicroAgentsLogic(self)
self.logging_handler = LoggingHandler(self.logpanel)
self.question_number = 0
def setup_ui_components(self):
self.header = MicroAgentsHeader()
self.footer = MicroAgentsFooter()
self.statusbar = MicroAgentsStatusbar()
self.input_field = MicroAgentsInput()
self.table = MicroAgentsTable()
self.logpanel = RichLog(wrap=True, classes="logpanel")
self.rlog = RichLog(wrap=True, classes="rlog")
def compose(self):
self.header=Header()
yield self.header
yield self.table
with TabbedContent(initial="Output", classes="tabs"):
with TabPane("Output", id="Output"):
yield self.rlog
with TabPane("Logging"):
yield self.logpanel
yield Input(placeholder="Enter question here", classes="prompt")
yield self.statusbar
self.footer=Footer()
yield self.footer
async def on_input_submitted(self, event):
await self.logic.on_input_submitted(event)
def on_ready(self):
pass
def on_worker_state_changed(self, event):
self.logic.on_worker_state_changed(event)
if __name__ == '__main__':
from dotenv import load_dotenv
load_dotenv()
app = MicroAgentsApp()
app.run()