API for updating value of textinput widget

This commit is contained in:
Darren Burns
2022-05-13 14:54:47 +01:00
parent 9e25752c85
commit 5686b6a2c1
4 changed files with 59 additions and 39 deletions

View File

@@ -30,10 +30,10 @@ class InputApp(App[str]):
return
if event.sender == self.celsius:
fahrenheit = celsius_to_fahrenheit(value)
self.fahrenheit.current_text = f"{fahrenheit:.1f}"
self.fahrenheit.value = f"{fahrenheit:.1f}"
elif event.sender == self.fahrenheit:
celsius = fahrenheit_to_celsius(value)
self.celsius.current_text = f"{celsius:.1f}"
self.celsius.value = f"{celsius:.1f}"
app = InputApp(

View File

@@ -22,6 +22,10 @@ Screen {
width: 50%;
}
#celsius :focus {
border: heavy darkgoldenrod;
}
#inputs {
dock: top;
background: $primary;
@@ -38,3 +42,7 @@ Screen {
height: 1;
border: ;
}
#footer :focus {
border: heavy $secondary;
}