예제 #1
0
class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.setGeometry(0, 0, 1280, 780)

        # Create actions and menus
        self.createMenu()
        self.createToolBar()

        # Create status bar
        self.statusBar().showMessage("Ready")

        # Vulkan widget
        self.vulkanWindow = VulkanWindow(self)
        self.vulkanWindowWidget = QtWidgets.QWidget.createWindowContainer(
            self.vulkanWindow)
        self.vulkanWindow.initialize()

        # Stop rendering while moving the window
        self.moveEventTimer = QtCore.QTimer(self)
        self.moveEventTimer.timeout.connect(self.moveEventDone)

        # Dock layout
        dock = QtWidgets.QDockWidget()
        dock.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea
                             | QtCore.Qt.RightDockWidgetArea)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock)

        # Property editor
        self.variantManager = QtVariantPropertyManager(self)
        self.variantManager.valueChangedSignal.connect(self.valueChanged)
        topItem = self.variantManager.addProperty(
            QtVariantPropertyManager.groupTypeId(), "Group Property")
        item = self.variantManager.addProperty(QtCore.QVariant.Bool, "Pause?")
        item.setValue(False)
        topItem.addSubProperty(item)
        self.variantFactory = QtVariantEditorFactory()
        self.propertyEditor = QtTreePropertyBrowser(dock)
        self.propertyEditor.setFactoryForManager(self.variantManager,
                                                 self.variantFactory)
        self.propertyEditor.addProperty(topItem)
        self.propertyEditor.setPropertiesWithoutValueMarked(True)
        self.propertyEditor.setRootIsDecorated(False)

        dock.setWidget(self.propertyEditor)

        # Vulkan viewport
        dock = QtWidgets.QDockWidget()
        dock.setWidget(self.vulkanWindowWidget)

        # Box layout
        #layout = QtWidgets.QVBoxLayout()
        #layout.addWidget(self.button)
        #layout.addWidget(self.vulkanWindowWidget)
        #layout.addWidget(dock)

        #mainWidget = QtWidgets.QWidget()
        #mainWidget.setLayout(layout)

        #self.setCentralWidget(mainWidget)
        self.setCentralWidget(self.vulkanWindowWidget)

        #self.showMaximized()

    def __del__(self):
        del self.variantManager
        del self.variantFactory
        del self.variantEditor
        self.destroy()

    def valueChanged(self, property, value):
        tp = type(value)
        if tp == bool:
            self.vulkanWindow.vk_renderer.is_paused = value

    def closeEvent(self, event):
        self.vulkanWindow.cleanup()
        del self.vulkanWindow

    def moveEvent(self, event):
        self.moveEventTimer.start(500)
        self.vulkanWindow.timer.stop()

    def moveEventDone(self):
        self.vulkanWindow.timer.start()

    def createMenu(self):
        fileMenu = self.menuBar().addMenu("&File")
        fileMenu.addAction("Exit", self.exit)

    def createToolBar(self):
        exitAction = QtWidgets.QAction(QtGui.QIcon(":/images/open.png"),
                                       "&Open...", self)
        exitAction.setStatusTip("Open an existing file")
        exitAction.triggered.connect(self.exit)
        self.fileToolBar = self.addToolBar("File")
        self.fileToolBar.addAction(exitAction)

    def exit(self):
        print("exit")
예제 #2
0
    topItem.addSubProperty(item)

    item = variantManager.addProperty(QVariant.Font, str(i) + " Font Property")
    i += 1
    topItem.addSubProperty(item)

    item = variantManager.addProperty(QVariant.Cursor,
                                      str(i) + " Cursor Property")
    i += 1
    topItem.addSubProperty(item)

    item = variantManager.addProperty(QVariant.Color,
                                      str(i) + " Color Property")
    i += 1
    topItem.addSubProperty(item)

    variantFactory = QtVariantEditorFactory()

    variantEditor = QtTreePropertyBrowser()
    variantEditor.setFactoryForManager(variantManager, variantFactory)
    variantEditor.addProperty(topItem)
    variantEditor.setPropertiesWithoutValueMarked(True)
    variantEditor.setRootIsDecorated(False)

    variantEditor.showMaximized()
    variantEditor.show()
    ret = app.exec_()
    del variantManager
    del variantFactory
    del variantEditor
    item = variantManager.addProperty(QVariant.SizePolicy, str(i) + " SizePolicy Property")
    i += 1
    topItem.addSubProperty(item)

    item = variantManager.addProperty(QVariant.Font, str(i) + " Font Property")
    i += 1
    topItem.addSubProperty(item)

    item = variantManager.addProperty(QVariant.Cursor, str(i) + " Cursor Property")
    i += 1
    topItem.addSubProperty(item)

    item = variantManager.addProperty(QVariant.Color, str(i) + " Color Property")
    i += 1
    topItem.addSubProperty(item)

    variantFactory = QtVariantEditorFactory()

    variantEditor = QtTreePropertyBrowser()
    variantEditor.setFactoryForManager(variantManager, variantFactory)
    variantEditor.addProperty(topItem)
    variantEditor.setPropertiesWithoutValueMarked(True)
    variantEditor.setRootIsDecorated(False)

    variantEditor.showMaximized()
    variantEditor.show()
    ret = app.exec_()
    del variantManager
    del variantFactory
    del variantEditor