mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Allow setting of app title in constructor, fix input validation
This commit is contained in:
@@ -60,7 +60,6 @@ _ASYNCIO_GET_EVENT_LOOP_IS_DEPRECATED = sys.version_info >= (3, 10, 0)
|
||||
|
||||
LayoutDefinition = "dict[str, Any]"
|
||||
|
||||
|
||||
DEFAULT_COLORS = {
|
||||
"dark": ColorSystem(
|
||||
primary="#004578",
|
||||
@@ -82,7 +81,6 @@ DEFAULT_COLORS = {
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
ComposeResult = Iterable[Widget]
|
||||
RenderResult = RenderableType
|
||||
|
||||
@@ -178,7 +176,6 @@ class App(Generic[ReturnType], DOMNode):
|
||||
)
|
||||
self.error_console = Console(markup=False, stderr=True)
|
||||
self.driver_class = driver_class or self.get_driver_class()
|
||||
self._title = title
|
||||
self._screen_stack: list[Screen] = []
|
||||
self._sync_available = False
|
||||
|
||||
@@ -192,9 +189,9 @@ class App(Generic[ReturnType], DOMNode):
|
||||
self._animate = self._animator.bind(self)
|
||||
self.mouse_position = Offset(0, 0)
|
||||
if title is None:
|
||||
self._title = f"{self.__class__.__name__}"
|
||||
self.title = f"{self.__class__.__name__}"
|
||||
else:
|
||||
self._title = title
|
||||
self.title = title
|
||||
|
||||
self._logger = Logger(self._log)
|
||||
|
||||
@@ -1021,7 +1018,6 @@ class App(Generic[ReturnType], DOMNode):
|
||||
|
||||
Reactive._initialize_object(self)
|
||||
|
||||
self.title = self._title
|
||||
self.stylesheet.update(self)
|
||||
self.refresh()
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ class Input(Widget, can_focus=True):
|
||||
COMPONENT_CLASSES = {"input--cursor", "input--placeholder"}
|
||||
|
||||
cursor_blink = reactive(True)
|
||||
value = reactive("", layout=True)
|
||||
value = reactive("", layout=True, init=False)
|
||||
input_scroll_offset = reactive(0)
|
||||
cursor_position = reactive(0)
|
||||
cursor_position = reactive(0, init=False)
|
||||
view_position = reactive(0)
|
||||
placeholder = reactive("")
|
||||
complete = reactive("")
|
||||
@@ -104,7 +104,7 @@ class Input(Widget, can_focus=True):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
value: str = "",
|
||||
value: str | None = None,
|
||||
placeholder: str = "",
|
||||
highlighter: Highlighter | None = None,
|
||||
password: bool = False,
|
||||
@@ -113,10 +113,12 @@ class Input(Widget, can_focus=True):
|
||||
classes: str | None = None,
|
||||
) -> None:
|
||||
super().__init__(name=name, id=id, classes=classes)
|
||||
self.value = value
|
||||
if value is not None:
|
||||
self.value = value
|
||||
self.placeholder = placeholder
|
||||
self.highlighter = highlighter
|
||||
self.password = password
|
||||
self.view_position = 0
|
||||
|
||||
def _position_to_cell(self, position: int) -> int:
|
||||
"""Convert an index within the value to cell position."""
|
||||
@@ -169,7 +171,6 @@ class Input(Widget, can_focus=True):
|
||||
return self._position_to_cell(len(self.value)) + 1
|
||||
|
||||
def render(self) -> RenderableType:
|
||||
self.view_position = self.view_position
|
||||
if not self.value:
|
||||
placeholder = Text(self.placeholder)
|
||||
placeholder.stylize(self.get_component_rich_style("input--placeholder"))
|
||||
|
||||
Reference in New Issue
Block a user