-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllm_generated_code.py
70 lines (55 loc) · 2.34 KB
/
llm_generated_code.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import textual.containers as containers
import textual.widgets as widgets
from textual import events
from textual.app import App, ComposeResult
welcome_text = """Welcome to your Grist cloud setup.
Please fill in the following information so that we can setup your new Grist instance.
"""
class GristSetupApp(App):
def compose(self) -> ComposeResult:
yield widgets.Static(welcome_text)
with containers.Horizontal():
yield widgets.Label("Email:")
self.email = widgets.Input(placeholder="[email protected]")
yield self.email
with containers.Horizontal():
yield widgets.Label("Hostname:")
self.hostname = widgets.Input(placeholder="grist.location")
yield self.hostname
with containers.Horizontal():
yield widgets.Label("Enable automatic HTTPS via Let's Encrypt?")
self.lets_encrypt_toggle = widgets.Switch(value=False)
yield self.lets_encrypt_toggle
self.submit_button = widgets.Button("Submit", id="submit-btn")
yield self.submit_button
self.focused_field = 0
self.fields = [self.email, self.hostname, self.lets_encrypt_toggle, self.submit_button]
def on_mount(self):
self.fields[self.focused_field].focus()
def focus_next(self):
self.focused_field = (self.focused_field + 1) % len(self.fields)
self.fields[self.focused_field].focus()
def focus_previous(self):
self.focused_field = (self.focused_field - 1) % len(self.fields)
self.fields[self.focused_field].focus()
async def on_key(self, event: events.Key):
if event.key == "down":
self.focus_next()
elif event.key == "up":
self.focus_previous()
elif event.key == "enter" and self.focused_field == len(self.fields):
# If Enter is pressed on the button, submit the form
self.submit()
def on_button_pressed(self, event: widgets.Button.Pressed) -> None:
if event.button.id == "submit-btn":
self.submit()
def submit(self):
"""Process the form data."""
app.exit({
'email': self.email.value,
'domain': self.hostname.value,
'tls': self.lets_encrypt_toggle.value
})
# Run the application
app = GristSetupApp()
print(app.run())