Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some bug fixes in Input + add title to App constructor #934

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

LayoutDefinition = "dict[str, Any]"


DEFAULT_COLORS = {
"dark": ColorSystem(
primary="#004578",
Expand All @@ -82,7 +81,6 @@
),
}


ComposeResult = Iterable[Widget]
RenderResult = RenderableType

Expand Down Expand Up @@ -178,7 +176,6 @@ def __init__(
)
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

Expand All @@ -192,9 +189,9 @@ def __init__(
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)

Expand Down Expand Up @@ -1021,7 +1018,6 @@ async def run_process_messages():

Reactive._initialize_object(self)

self.title = self._title
self.stylesheet.update(self)
self.refresh()

Expand Down
8 changes: 4 additions & 4 deletions src/textual/widgets/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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)
view_position = reactive(0)
Expand All @@ -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,
Expand All @@ -113,7 +113,8 @@ def __init__(
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
Expand Down Expand Up @@ -169,7 +170,6 @@ def cursor_width(self) -> int:
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"))
Expand Down
Loading