moved 'get_main_window' to nuke lib

This commit is contained in:
Jakub Trllo 2022-08-31 10:49:32 +02:00
parent c2fdf6d1d0
commit 4cbc82778e
2 changed files with 19 additions and 18 deletions

View file

@ -76,6 +76,23 @@ class Context:
_project_doc = None
def get_main_window():
"""Acquire Nuke's main window"""
if Context.main_window is None:
from Qt import QtWidgets
top_widgets = QtWidgets.QApplication.topLevelWidgets()
name = "Foundry::UI::DockMainWindow"
for widget in top_widgets:
if (
widget.inherits("QMainWindow")
and widget.metaObject().className() == name
):
Context.main_window = widget
break
return Context.main_window
class Knobby(object):
"""For creating knob which it's type isn't mapped in `create_knobs`

View file

@ -26,6 +26,8 @@ from openpype.tools.utils import host_tools
from .command import viewer_update_and_undo_stop
from .lib import (
Context,
get_main_window,
add_publish_knob,
WorkfileSettings,
process_workfile_builder,
@ -33,7 +35,6 @@ from .lib import (
check_inventory_versions,
set_avalon_knob_data,
read_avalon_data,
Context
)
log = Logger.get_logger(__name__)
@ -53,23 +54,6 @@ if os.getenv("PYBLISH_GUI", None):
pyblish.api.register_gui(os.getenv("PYBLISH_GUI", None))
def get_main_window():
"""Acquire Nuke's main window"""
if Context.main_window is None:
from Qt import QtWidgets
top_widgets = QtWidgets.QApplication.topLevelWidgets()
name = "Foundry::UI::DockMainWindow"
for widget in top_widgets:
if (
widget.inherits("QMainWindow")
and widget.metaObject().className() == name
):
Context.main_window = widget
break
return Context.main_window
def reload_config():
"""Attempt to reload pipeline at run-time.