Simple multiline text widget to help model text base class

This commit is contained in:
Darren Burns
2022-05-12 11:15:41 +01:00
parent 75085a9f4f
commit c34973ce80
6 changed files with 194 additions and 91 deletions

View File

@@ -1,7 +1,7 @@
from textual.app import App
from textual.widget import Widget
from textual.widgets.text_input import TextInput, TextInputBase
from textual.widgets.text_input import TextInput, TextWidgetBase, TextArea
def celsius_to_fahrenheit(celsius: float) -> float:
@@ -19,8 +19,10 @@ class InputApp(App[str]):
self.fahrenheit.focus()
text_boxes = Widget(self.fahrenheit, self.celsius)
self.mount(inputs=text_boxes)
self.mount(spacer=Widget())
self.mount(text_area=TextArea())
def handle_changed(self, event: TextInputBase.Changed) -> None:
def handle_changed(self, event: TextWidgetBase.Changed) -> None:
try:
value = float(event.value)
except ValueError:

View File

@@ -1,11 +1,17 @@
App {
layout: dock;
docks: top=top bot=bottom;
background: $secondary;
}
#spacer {
height: 1;
background: $primary-darken-2;
dock: top;
}
Screen {
layout: dock;
docks: top=top bottom=bottom;
background: $secondary;
}
@@ -29,3 +35,7 @@ Screen {
background: $secondary;
height: 20;
}
#text_area {
dock: bottom;
}