Nuke window top

#!/usr/bin/env python
# -*- coding:utf-8 -*-

Import sys
Import os
Import traceback
Import time

Try:
    From PySide2 import QtWidgets as QtGui
    From PySide2 import QtGui as QtGui1
    From PySide2 import QtCore
Except ImportError:
    From PySide import QtGui
    From PySide import QtCore

Class TreeViewOne(QtGui.QTreeWidget):
    Def __init__(self,parent=None):
        Super(TreeViewOne,self).__init__(parent=parent)
        self.setHeaderLabels([u'project'])



Class TreeViewTwo(QtGui.QTreeWidget):
    Def __init__(self,parent=None):
        Super(TreeViewTwo,self).__init__(parent=parent)
        self.setHeaderLabels([u'courts'])


Class ImportNukeUI(QtGui.QDialog):
    parentUI=QtGui.QApplication.activeWindow()
    Def __init__(self, parent=parentUI):
        Super(ImportNukeUI,self).__init__(parent)
        self.setWindowTitle('nuke_data_Preview')
        Self.resize(420,391)
        self.initUI()
    Def initUI(self):
        Self.tree_one=TreeViewOne()
        Self.tree_two=TreeViewTwo()

        Pro_path=QtGui.QLabel(u"path")
        Self.pro_path_edit=QtGui.QLineEdit()

        Self.import_button=QtGui.QPushButton(u"import")
        Self.exit_button=QtGui.QPushButton(u"exit")

        Lay1=QtGui.QHBoxLayout()
        lay1.addWidget(self.tree_one)
        lay1.addWidget(self.tree_two)

        Lay2=QtGui.QHBoxLayout()
        lay2.addWidget(pro_path)
        lay2.addWidget(self.pro_path_edit)

        Lay3=QtGui.QHBoxLayout()
        lay3.addStretch(1)
        lay3.addWidget(self.import_button)
        lay3.addWidget(self.exit_button)



        Layt=QtGui.QVBoxLayout()
        Layt.addLayout(lay1)
        Layt.addLayout(lay2)
        Layt.addLayout(lay3)

        self.setLayout(Layt)

If __name__ == '__main__':
    Import sys
    #app = QtGui.QApplication(sys.argv)
    Dialog = ImportNukeUI()
    Dialog.show()
    #sys.exit(app.exec_())

这里写图片描述 同理,如果不置顶,有些常用的窗口使用起来很不方便。 parentUI=QtGui.QApplication.activeWindow() def init(self, parent=parentUI) After writing the name of the parent window here, it will be attached to the parent window.