Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Show app in main window.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokejepsen committed Apr 8, 2024
1 parent 7153e82 commit 143148f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
27 changes: 8 additions & 19 deletions openpype/hosts/nuke/api/push_to_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from openpype.pipeline.workfile import get_workdir_with_workdir_data
from openpype import PACKAGE_DIR
from openpype.lib import get_openpype_execute_args, run_subprocess
from openpype.tools.push_to_project.app import show

from .utils import bake_gizmos_recursively

import nuke
Expand Down Expand Up @@ -47,29 +49,16 @@ def bake_container(container):


def main():
# Get project name, asset id and task name.
push_tool_script_path = os.path.join(
PACKAGE_DIR,
"tools",
"push_to_project",
"app.py"
)
context = show("", "", False, True)

args = get_openpype_execute_args(
"run",
push_tool_script_path,
"--library_filter", "False",
"--context_only", "True"
)
output = run_subprocess(args)
dict_string = re.search(r'\{.*\}', output).group()
result = json.loads(dict_string)
if context is None:
return

# Get workfile path to save to.
project_name = result["project_name"]
project_name = context["project_name"]
project_doc = get_project(project_name)
asset_doc = get_asset_by_id(project_name, result["asset_id"])
task_name = result["task_name"]
asset_doc = get_asset_by_id(project_name, context["asset_id"])
task_name = context["task_name"]
host = registered_host()
system_settings = get_system_settings()
project_settings = get_project_settings(project_name)
Expand Down
44 changes: 18 additions & 26 deletions openpype/tools/push_to_project/app.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
import json

import click

from openpype.tools.utils import get_openpype_qt_app
from openpype.tools.push_to_project.window import PushToContextSelectWindow


def show(project, version, library_filter, context_only):
window = PushToContextSelectWindow(
library_filter=library_filter, context_only=context_only
)
window.show()
window.controller.set_source(project, version)

if __name__ == "__main__":
app = get_openpype_qt_app()
app.exec_()
else:
window.exec_()

return window.context


@click.command()
@click.option("--project", help="Source project name")
@click.option("--version", help="Source version id")
@click.option("--library_filter", help="Filter to library projects only.")
@click.option("--context_only", help="Return new context only.")
def main(project, version, library_filter, context_only):
def main(project, version):
"""Run PushToProject tool to integrate version in different project.
Args:
project (str): Source project name.
version (str): Version id.
version (bool): Filter to library projects only.
"""
app = get_openpype_qt_app()

if library_filter is None:
library_filter = True
else:
library_filter = library_filter == "True"

if context_only is None:
context_only = True
else:
context_only = context_only == "True"

window = PushToContextSelectWindow(
library_filter=library_filter, context_only=context_only
)
window.show()
window.controller.set_source(project, version)

app.exec_()

print(json.dumps(window.context))
show(project, version, True, False)


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion openpype/tools/push_to_project/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def _refresh(self, new_project_name):
self.items_changed.emit()


class PushToContextSelectWindow(QtWidgets.QWidget):
class PushToContextSelectWindow(QtWidgets.QDialog):
def __init__(
self, controller=None, library_filter=True, context_only=False
):
Expand All @@ -376,6 +376,7 @@ def __init__(
controller = PushToContextController(library_filter=library_filter)
self._controller = controller
self.context_only = context_only
self.context = None

self.setWindowTitle("Push to project (select context)")
self.setWindowIcon(QtGui.QIcon(get_app_icon_path()))
Expand Down

0 comments on commit 143148f

Please sign in to comment.