From baa0f543df881cd3ac043e2f8b1d4b88a8b708c4 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 29 Oct 2021 18:47:26 +0200 Subject: [PATCH] give ability to set context of dialog --- openpype/tools/context_dialog/window.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/openpype/tools/context_dialog/window.py b/openpype/tools/context_dialog/window.py index b3128ed159..393ac5b8a8 100644 --- a/openpype/tools/context_dialog/window.py +++ b/openpype/tools/context_dialog/window.py @@ -126,6 +126,10 @@ class ContextDialog(QtWidgets.QDialog): self._strict = False + # Values set by `set_context` method + self._set_context_project = None + self._set_context_asset = None + # Output of dialog self._context_to_store = { "project": None, @@ -154,6 +158,18 @@ class ContextDialog(QtWidgets.QDialog): self.accept() + def set_context(self, project_name=None, asset_name=None): + if project_name is None: + asset_name = None + + self._set_context_project = project_name + self._set_context_asset = asset_name + + self._context_to_store["project"] = project_name + self._context_to_store["asset"] = asset_name + + self._set_refresh_on_next_show() + def get_context(self): return self._context_to_store @@ -166,6 +182,7 @@ def main( ): app = QtWidgets.QApplication([]) window = ContextDialog() + window.set_context(project_name, asset_name) window.show() app.exec_()