Kaynağa Gözat

Support relative file path for Page (#425) (#973)

Dinh Long Nguyen 1 yıl önce
ebeveyn
işleme
6b88705b5e
1 değiştirilmiş dosya ile 6 ekleme ve 1 silme
  1. 6 1
      taipy/gui/_renderers/__init__.py

+ 6 - 1
taipy/gui/_renderers/__init__.py

@@ -53,7 +53,12 @@ class _Renderer(Page, ABC):
             )
 
     def __process_content(self, content: str) -> None:
-        if path.exists(content) and path.isfile(content):
+        relative_file_path = (
+            None if self._frame is None else path.join(path.dirname(self._frame.f_code.co_filename), content)
+        )
+        if relative_file_path is not None and path.exists(relative_file_path) and path.isfile(relative_file_path):
+            content = relative_file_path
+        if content == relative_file_path or (path.exists(content) and path.isfile(content)):
             self.__parse_file_content(content)
             # Watchdog observer: watch for file changes
             if _is_in_notebook() and self._observer is None: