Created
March 15, 2024 10:24
-
-
Save promto-c/8a1ae7110ebbdebe2a3b94fc5d7c1349 to your computer and use it in GitHub Desktop.
PySide2 Script to Find Nuke's Main Window: This script iterates through top-level widgets to locate the main window, enabling further customization or interaction through Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from PySide2 import QtWidgets | |
| def GetNukeMainWindow(): | |
| """Finds and returns the main Nuke window. | |
| Iterates through all top-level widgets, checking for the Nuke main window | |
| based on its class name. | |
| Returns: | |
| QtWidgets.QWidget: The found main window of Nuke, or None if not found. | |
| """ | |
| for widget in QtWidgets.QApplication.instance().topLevelWidgets(): | |
| if widget.metaObject().classname() != 'Foundry::UI::DockMainWindow': | |
| continue | |
| return widget | |
| if __name__ == '__main__': | |
| nuke_main_window = get_nuke_main_window() | |
| _override_shortkey = QtWidgets.QShortCut(QtGui.QKeySequence('Ctrl+q', nuke_main_window) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment