I have created 2 panels in The Foundry NUKE. One is using PyQt
designer and another using nukescripts.PythonPanel
. Now I am trying to embed nukescripts.PythonPanel
to PyQt
designed panel.
If you run 1st module (test) you will see 2 tabs in panel 1st Tab has Qt widgets in it. I am trying to embed 2nd module (test2) panel in to 2nd Tab.
Please find the below modules for test. test - pyqt designed panel. test 2 - nukescripts.PythonPanel
test -
import nuke
import os
import sys
from nukescripts import panels
import nukescripts
from PyQt4 import Qt
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_MainWindow(QtGui.QWidget):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.tabWidget = QtGui.QTabWidget(self.centralwidget)
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.tab = QtGui.QWidget()
self.tab.setObjectName(_fromUtf8("tab"))
self.pushButton = QtGui.QPushButton(self.tab)
self.pushButton.setGeometry(QtCore.QRect(20, 40, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton_2 = QtGui.QPushButton(self.tab)
self.pushButton_2.setGeometry(QtCore.QRect(110, 40, 75, 23))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.pushButton_3 = QtGui.QPushButton(self.tab)
self.pushButton_3.setGeometry(QtCore.QRect(30, 110, 75, 23))
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.pushButton_4 = QtGui.QPushButton(self.tab)
self.pushButton_4.setGeometry(QtCore.QRect(120, 110, 75, 23))
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
self.tabWidget.addTab(self.tab, _fromUtf8(""))
self.tab_2 = QtGui.QWidget()
self.tab_2.setObjectName(_fromUtf8("tab_2"))
self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
self.horizontalLayout.addWidget(self.tabWidget)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "button1", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_2.setText(QtGui.QApplication.translate("MainWindow", "button1", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_3.setText(QtGui.QApplication.translate("MainWindow", "button3", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_4.setText(QtGui.QApplication.translate("MainWindow", "button4", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Tab 1", None, QtGui.QApplication.UnicodeUTF8))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("MainWindow", "Tab 2", None, QtGui.QApplication.UnicodeUTF8))
class Main(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui=Ui_MainWindow()
self.ui.setupUi(self)
## make this work in a .py file and in 'copy and paste' into the script editor
moduleName = __name__
if moduleName == '__main__':
moduleName = ''
else:
moduleName = moduleName + '.'
panels.registerWidgetAsPanel( moduleName + 'Main', 'Mk test','com.ohufx.test')
test2-
import nuke
import os
import re
class test( nukescripts.PythonPanel ):
def __init__( self ):
nukescripts.PythonPanel.__init__( self, 'MkGlobal', 'com.ohufx.MkPanel')
self.BeginChromaGroup= nuke.BeginTabGroup_Knob('ChromaPresets','ChromaPresets')
self.GreenscreenPresets = nuke.Tab_Knob('GreenscreenPresets','GreenscreenPresets')
self.Greenscreen = nuke.PyScript_Knob('Greenscreen','Greenscreen','Presets.GreenScreen()')
#####################AdditiveKeyerPresets
self.AdditiveKeyerPresets = nuke.Tab_Knob('AdditiveKeyerPresets','AdditiveKeyerImage' )
self.AdditiveKeyerPresets.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_1 = nuke.PyScript_Knob('AdditiveKeyer_1',' AdditiveKeyer_1 ','Presets.AdditiveKeyer_1()')
self.AdditiveKeyer_1.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_2 = nuke.PyScript_Knob('AdditiveKeyer_2',' AdditiveKeyer_2 ','Presets.AdditiveKeyer_2()')
self.AdditiveKeyer_2.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_3 = nuke.PyScript_Knob('AdditiveKeyer_3',' AdditiveKeyer_3 ','Presets.AdditiveKeyer_3()')
self.AdditiveKeyer_3.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_4 = nuke.PyScript_Knob('AdditiveKeyer_4',' AdditiveKeyer_4 ','Presets.AdditiveKeyer_4()')
self.AdditiveKeyer_4.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_5 = nuke.PyScript_Knob('AdditiveKeyer_5',' AdditiveKeyer_5 ','Presets.AdditiveKeyer_5()')
self.AdditiveKeyer_5.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_6 = nuke.PyScript_Knob('AdditiveKeyer_6',' AdditiveKeyer_6 ','Presets.AdditiveKeyer_6()')
self.AdditiveKeyer_6.setFlag(nuke.STARTLINE)
self.AdditiveKeyer_7 = nuke.PyScript_Knob('AdditiveKeyer_7',' AdditiveKeyer_7 ','Presets.AdditiveKeyer_7()')
self.AdditiveKeyer_7.setFlag(nuke.STARTLINE)
for k in (
self.BeginChromaGroup,
self.GreenscreenPresets,self.Greenscreen,
self.AdditiveKeyerPresets,
self.AdditiveKeyer_1,self.AdditiveKeyer_2,self.AdditiveKeyer_3,self.AdditiveKeyer_4,self.AdditiveKeyer_5,self.AdditiveKeyer_6,self.AdditiveKeyer_7):
self.addKnob(k)
p=test()
p.show()
You can insert the PyQT/Pyside2 into nukescripts.PythonPanel Something like this: