mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Added message to exit method
This commit is contained in:
@@ -449,7 +449,7 @@ class Compositor:
|
||||
map[widget] = MapGeometry(
|
||||
region + layout_offset,
|
||||
order,
|
||||
clip,
|
||||
clip if widget.is_container else sub_clip,
|
||||
total_region.size,
|
||||
container_size,
|
||||
virtual_region,
|
||||
|
||||
@@ -414,14 +414,19 @@ class App(Generic[ReturnType], DOMNode):
|
||||
"""list[Screen]: A *copy* of the screen stack."""
|
||||
return self._screen_stack.copy()
|
||||
|
||||
def exit(self, result: ReturnType | None = None) -> None:
|
||||
def exit(
|
||||
self, result: ReturnType | None = None, message: RenderableType | None = None
|
||||
) -> None:
|
||||
"""Exit the app, and return the supplied result.
|
||||
|
||||
Args:
|
||||
result (ReturnType | None, optional): Return value. Defaults to None.
|
||||
message (RenderableType | None): Optional message to display on exit.
|
||||
"""
|
||||
self._return_value = result
|
||||
self.post_message_no_wait(messages.ExitApp(sender=self))
|
||||
if message:
|
||||
self._exit_renderables.append(message)
|
||||
|
||||
@property
|
||||
def focused(self) -> Widget | None:
|
||||
|
||||
@@ -451,6 +451,7 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
|
||||
|
||||
def clear(self) -> None:
|
||||
"""Clear all nodes under root."""
|
||||
self._line_cache.clear()
|
||||
self._tree_lines_cached = None
|
||||
self._current_id = 0
|
||||
root_label = self.root._label
|
||||
@@ -810,7 +811,7 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
|
||||
cursor_line = meta["line"]
|
||||
if meta.get("toggle", False):
|
||||
node = self.get_node_at_line(cursor_line)
|
||||
if node is not None and self.auto_expand:
|
||||
if node is not None:
|
||||
self._toggle_node(node)
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user