1. 程式人生 > >nuke 視窗置頂

nuke 視窗置頂

#!/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'專案'])



class TreeViewTwo(QtGui.QTreeWidget):
    def __init__(self,parent=None):
        super(TreeViewTwo,self).__init__(parent=parent)
        self.setHeaderLabels([u'場次'])


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"路徑")
        self.pro_path_edit=QtGui.QLineEdit()

        self.import_button=QtGui.QPushButton(u"匯入")
        self.exit_button=QtGui.QPushButton(u"退出")

        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) 在這裡寫上父視窗的名字之後,它就會依附於父視窗了。