From a3e73d5cfcd09aeaa27712b9d39a7a7cfffe6855 Mon Sep 17 00:00:00 2001 From: dinhlongviolin1 Date: Wed, 15 Nov 2023 20:20:09 +0700 Subject: [PATCH 1/3] partial gui builder --- src/taipy/gui/partial.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/taipy/gui/partial.py b/src/taipy/gui/partial.py index 3d079fb09..430d6aca8 100644 --- a/src/taipy/gui/partial.py +++ b/src/taipy/gui/partial.py @@ -16,6 +16,7 @@ from ._page import _Page from ._warnings import _warn from .state import State +from .page import Page class Partial(_Page): @@ -50,7 +51,7 @@ def __init__(self, route: t.Optional[str] = None): else: self._route = route - def update_content(self, state: State, content: str): + def update_content(self, state: State, content: str | Page): """Update partial content. Arguments: @@ -62,7 +63,10 @@ def update_content(self, state: State, content: str): else: _warn("'Partial.update_content()' must be called in the context of a callback.") - def __copy(self, content: str) -> Partial: + def __copy(self, content: str | Page) -> Partial: new_partial = Partial(self._route) - new_partial._renderer = type(self._renderer)(content=content) if self._renderer is not None else None + if isinstance(content, Page): + new_partial._renderer = content + else: + new_partial._renderer = type(self._renderer)(content=content) if self._renderer is not None else None return new_partial From e1fcd68f8b65b5ed36c36bea2afb6d55ac2cb688 Mon Sep 17 00:00:00 2001 From: dinhlongviolin1 Date: Tue, 28 Nov 2023 15:31:46 +0700 Subject: [PATCH 2/3] issort --- src/taipy/gui/partial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/taipy/gui/partial.py b/src/taipy/gui/partial.py index 430d6aca8..c3e6d5731 100644 --- a/src/taipy/gui/partial.py +++ b/src/taipy/gui/partial.py @@ -15,8 +15,8 @@ from ._page import _Page from ._warnings import _warn -from .state import State from .page import Page +from .state import State class Partial(_Page): From 543d5c0b200c196e9465221da61313d923a0a8b8 Mon Sep 17 00:00:00 2001 From: dinhlongviolin1 Date: Wed, 29 Nov 2023 15:38:50 +0700 Subject: [PATCH 3/3] resolve import error --- src/taipy/gui/partial.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/taipy/gui/partial.py b/src/taipy/gui/partial.py index c3e6d5731..088f55b42 100644 --- a/src/taipy/gui/partial.py +++ b/src/taipy/gui/partial.py @@ -15,9 +15,11 @@ from ._page import _Page from ._warnings import _warn -from .page import Page from .state import State +if t.TYPE_CHECKING: + from .page import Page + class Partial(_Page): """Re-usable Page content. @@ -51,7 +53,7 @@ def __init__(self, route: t.Optional[str] = None): else: self._route = route - def update_content(self, state: State, content: str | Page): + def update_content(self, state: State, content: str | "Page"): """Update partial content. Arguments: @@ -63,8 +65,10 @@ def update_content(self, state: State, content: str | Page): else: _warn("'Partial.update_content()' must be called in the context of a callback.") - def __copy(self, content: str | Page) -> Partial: + def __copy(self, content: str | "Page") -> Partial: new_partial = Partial(self._route) + from .page import Page + if isinstance(content, Page): new_partial._renderer = content else: