0

我在 The Foundry NUKE 中创建了 2 个面板。一个是使用PyQt设计器,另一个是使用nukescripts.PythonPanel. 现在我正在尝试嵌入nukescripts.PythonPanel设计的PyQt面板。

如果您运行第一个模块(测试),您将在面板中看到 2 个选项卡,第一个选项卡中有 Qt 小部件。我正在尝试将第二个模块(test2)面板嵌入到第二个选项卡中。

请找到以下模块进行测试。测试 - pyqt 设计的面板。测试 2 - nukescripts.PythonPanel

测试 -

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')

测试2-

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()
4

1 回答 1

0

我认为您不能将PythonPanel对象嵌入到QWidget对象中。由于PythonPanel只是 nukeQWidgetQWidget.

于 2018-03-22T16:19:21.827 回答