Вставьте qtpynodeeditor в главное окно pyside2 - PullRequest
0 голосов
/ 14 апреля 2020

Я хочу использовать редактор узлов в pyside2, я получил библиотеку qtpynodeeditor (https://pypi.org/project/qtpynodeeditor/). Я не могу вставить внутрь моего главного окна. Я могу отобразить отдельно, левое окно - редактор узлов, справа - главное окно.

enter image description here

MainWindow_UI.py

# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'ListViewForNodeEditor_UI.ui'
##
## Created by: Qt User Interface Compiler version 5.14.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
    QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
    QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
    QRadialGradient)
from PySide2.QtWidgets import *


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(u"verticalLayout")

        self.graphicsView = QGraphicsView(self.centralwidget)
        self.graphicsView.setObjectName(u"graphicsView")

        self.verticalLayout.addWidget(self.graphicsView)

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 800, 21))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
    # retranslateUi

NodeEditor.py

from ListViewForNodeEditor_UI import Ui_MainWindow
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtCore import *
import qdarkstyle
import qtpynodeeditor as nodeeditor

class testNode(QMainWindow):
    def __init__(self, parent=None):
        super(testNode, self).__init__(parent)
        self.Wui = Ui_MainWindow()
        self.Wui.setupUi(self)

        #Shows the Node Editor
        registry = nodeeditor.DataModelRegistry()
        scene = nodeeditor.FlowScene(registry=registry)
        self.view = nodeeditor.FlowView(scene)
        self.view.show()

if __name__=="__main__":
    import sys
    app = QApplication(sys.argv)
    dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
    app.setStyleSheet(dark_stylesheet)
    w = testNode()
    w.show()
    sys.exit(app.exec_())

любой альтернативный редактор узлов для pyside2 высоко ценится.

...