mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
removed cruft
This commit is contained in:
@@ -733,10 +733,17 @@ class App(Generic[ReturnType], DOMNode):
|
||||
str | None: The name of the screen that was uninstalled, or None if no screen was uninstalled.
|
||||
"""
|
||||
if isinstance(screen, str):
|
||||
uninstalled_screen = self._installed_screens.pop(screen)
|
||||
self.log(f"{uninstalled_screen} UNINSTALLED name={screen!r}")
|
||||
if screen not in self._installed_screens:
|
||||
return None
|
||||
uninstall_screen = self._installed_screens[screen]
|
||||
if uninstall_screen in self._screen_stack:
|
||||
raise ScreenStackError("Can't uninstall screen in screen stack")
|
||||
del self._installed_screens[screen]
|
||||
self.log(f"{uninstall_screen} UNINSTALLED name={screen!r}")
|
||||
return screen
|
||||
else:
|
||||
if screen in self._screen_stack:
|
||||
raise ScreenStackError("Can't uninstall screen in screen stack")
|
||||
for name, installed_screen in self._installed_screens.items():
|
||||
if installed_screen is screen:
|
||||
self._installed_screens.pop(name)
|
||||
|
||||
@@ -445,11 +445,6 @@ class DOMNode(MessagePump):
|
||||
"""The children which don't have display: none set."""
|
||||
return [child for child in self.children if child.display]
|
||||
|
||||
def detach(self) -> None:
|
||||
if self._parent and isinstance(self._parent, DOMNode):
|
||||
self._parent.children._remove(self)
|
||||
self._detach()
|
||||
|
||||
def get_pseudo_classes(self) -> Iterable[str]:
|
||||
"""Get any pseudo classes applicable to this Node, e.g. hover, focus.
|
||||
|
||||
|
||||
@@ -130,10 +130,6 @@ class MessagePump(metaclass=MessagePumpMeta):
|
||||
"""
|
||||
self._parent = parent
|
||||
|
||||
def _detach(self) -> None:
|
||||
"""Unset the parent, removing it from the tree."""
|
||||
self._parent = None
|
||||
|
||||
def check_message_enabled(self, message: Message) -> bool:
|
||||
return type(message) not in self._disabled_messages
|
||||
|
||||
|
||||
@@ -64,6 +64,16 @@ async def test_screens():
|
||||
assert app.screen is screen2
|
||||
assert app.screen_stack == [screen2]
|
||||
|
||||
# Uninstall screens
|
||||
app.uninstall_screen(screen1)
|
||||
assert not app.is_screen_installed(screen1)
|
||||
app.uninstall_screen("screen3")
|
||||
assert not app.is_screen_installed(screen1)
|
||||
|
||||
# Check we can't uninstall a screen on the stack
|
||||
with pytest.raises(ScreenStackError):
|
||||
app.uninstall_screen(screen2)
|
||||
|
||||
# Check we can't pop last screen
|
||||
with pytest.raises(ScreenStackError):
|
||||
app.pop_screen()
|
||||
|
||||
Reference in New Issue
Block a user