add MessageScreen back and tweak/enhance screen layouts
this will be used for a help screen, which isn't done yet, but this makes the edit screen incrementally better too Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
5fc2339c74
commit
1d887c9fdf
|
@ -5,12 +5,12 @@ Tree {
|
||||||
Button {
|
Button {
|
||||||
border: round gray;
|
border: round gray;
|
||||||
content-align: center middle;
|
content-align: center middle;
|
||||||
width: 100%;
|
max-width: 50%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0 1;
|
margin: 0 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditScreen {
|
EditScreen, MessageScreen {
|
||||||
align: center middle;
|
align: center middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,14 +31,25 @@ EditScreen Label {
|
||||||
}
|
}
|
||||||
|
|
||||||
#edit-dialog {
|
#edit-dialog {
|
||||||
grid-size: 2;
|
|
||||||
grid-rows: 1fr 3fr 1fr 2fr;
|
|
||||||
padding: 0 1;
|
padding: 0 1;
|
||||||
|
grid-rows: 1fr 1fr 1fr 1fr;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
height: 50%;
|
height: 50%;
|
||||||
border: tall gray 100%;
|
border: tall gray 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#message-dialog {
|
||||||
|
padding: 0 1;
|
||||||
|
grid-rows: 3fr 1fr;
|
||||||
|
width: 50%;
|
||||||
|
height: 50%;
|
||||||
|
border: tall gray 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#button-container {
|
||||||
|
align: right middle;
|
||||||
|
}
|
||||||
|
|
||||||
#field-name, #field-input, #input-errors {
|
#field-name, #field-input, #input-errors {
|
||||||
column-span: 2;
|
column-span: 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ from rich.highlighter import ReprHighlighter
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
from textual import on
|
from textual import on
|
||||||
from textual.app import App, ComposeResult
|
from textual.app import App, ComposeResult
|
||||||
from textual.containers import Grid
|
from textual.containers import Container, Grid, Horizontal
|
||||||
from textual.logging import TextualHandler
|
from textual.logging import TextualHandler
|
||||||
from textual.screen import ModalScreen
|
from textual.screen import ModalScreen
|
||||||
from textual.validation import Number
|
from textual.validation import Number
|
||||||
|
@ -57,11 +57,12 @@ class EditScreen(ModalScreen):
|
||||||
# we don't handle whatever these are yet
|
# we don't handle whatever these are yet
|
||||||
self.input_field = Label(repr(self.field_value), id='field-input')
|
self.input_field = Label(repr(self.field_value), id='field-input')
|
||||||
yield Grid(
|
yield Grid(
|
||||||
Label(self.field_descriptor.full_name, id="field-name"),
|
Container(Label(self.field_descriptor.full_name, id="field-name"), id="field-name-container"),
|
||||||
self.input_field,
|
Container(self.input_field, id="input-field-container"),
|
||||||
Pretty('', id='input-errors', classes='hidden'),
|
Container(Pretty('', id='input-errors', classes='hidden'), id="error-container"),
|
||||||
Button("Confirm", id='confirm-button'),
|
Horizontal(Button("Confirm", id='confirm-button'),
|
||||||
Button("Cancel", id='cancel-button'),
|
Button("Cancel", id='cancel-button'),
|
||||||
|
id="button-container"),
|
||||||
id='edit-dialog',
|
id='edit-dialog',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,6 +103,27 @@ class EditScreen(ModalScreen):
|
||||||
self.node.set_label(pb_field_to_node_label(self.field_descriptor, field_value))
|
self.node.set_label(pb_field_to_node_label(self.field_descriptor, field_value))
|
||||||
|
|
||||||
|
|
||||||
|
class MessageScreen(ModalScreen):
|
||||||
|
"""Simple screen for displaying messages."""
|
||||||
|
|
||||||
|
def __init__(self, text: str, *args, **kwargs):
|
||||||
|
"""Store the message for later display."""
|
||||||
|
self.text = text
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def compose(self) -> ComposeResult:
|
||||||
|
"""Build the pop-up window with the desired message displayed."""
|
||||||
|
yield Grid(
|
||||||
|
Container(Label(self.text, id="message-text"), id="text-container"),
|
||||||
|
Container(Button("OK", id='ok-button'), id="button-container"),
|
||||||
|
id='message-dialog',
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
|
"""Process the button action (close the window)."""
|
||||||
|
self.app.pop_screen()
|
||||||
|
|
||||||
|
|
||||||
class ConfigEditor(App):
|
class ConfigEditor(App):
|
||||||
"""Display the GP2040-CE configuration as a tree."""
|
"""Display the GP2040-CE configuration as a tree."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue