From a565c98de42c8dae924ccfc82ddda0767b207a35 Mon Sep 17 00:00:00 2001 From: Jim Kring Date: Thu, 28 Jul 2022 12:02:02 -0700 Subject: [PATCH 1/2] Upgrade to PySide6 --- main.py | 4 ++-- node_editor/gui/connection.py | 2 +- node_editor/gui/node.py | 8 ++++---- node_editor/gui/node_editor.py | 2 +- node_editor/gui/node_list.py | 2 +- node_editor/gui/node_widget.py | 2 +- node_editor/gui/palette.py | 6 +++--- node_editor/gui/port.py | 4 ++-- node_editor/gui/view.py | 7 ++++--- requirements.txt | 2 +- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/main.py b/main.py index d1d3ec5..e87fa46 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ import sys -from PySide2 import QtWidgets, QtCore, QtGui +from PySide6 import QtWidgets, QtCore, QtGui import logging import os @@ -61,5 +61,5 @@ def closeEvent(self, event): app.setPalette(palette) launcher = NodeEditor() launcher.show() - app.exec_() + app.exec() sys.exit() diff --git a/node_editor/gui/connection.py b/node_editor/gui/connection.py index b86f31b..2faa4c4 100644 --- a/node_editor/gui/connection.py +++ b/node_editor/gui/connection.py @@ -1,4 +1,4 @@ -from PySide2 import QtWidgets, QtGui, QtCore +from PySide6 import QtWidgets, QtGui, QtCore class Connection(QtWidgets.QGraphicsPathItem): diff --git a/node_editor/gui/node.py b/node_editor/gui/node.py index 3c2ab19..1614075 100644 --- a/node_editor/gui/node.py +++ b/node_editor/gui/node.py @@ -1,4 +1,4 @@ -from PySide2 import QtWidgets, QtGui, QtCore +from PySide6 import QtWidgets, QtGui, QtCore from node_editor.gui.port import Port @@ -87,12 +87,12 @@ def build(self): # Get the dimentions of the title and type title_dim = { - "w": QtGui.QFontMetrics(title_font).width(self._title_text), + "w": QtGui.QFontMetrics(title_font).horizontalAdvance(self._title_text), "h": QtGui.QFontMetrics(title_font).height(), } title_type_dim = { - "w": QtGui.QFontMetrics(title_type_font).width("(" + self._type_text + ")"), + "w": QtGui.QFontMetrics(title_type_font).horizontalAdvance("(" + self._type_text + ")"), "h": QtGui.QFontMetrics(title_type_font).height(), } @@ -108,7 +108,7 @@ def build(self): # Add the heigth for each of the ports for port in self._ports: port_dim = { - "w": QtGui.QFontMetrics(port_font).width(port.name()), + "w": QtGui.QFontMetrics(port_font).horizontalAdvance(port.name()), "h": QtGui.QFontMetrics(port_font).height(), } diff --git a/node_editor/gui/node_editor.py b/node_editor/gui/node_editor.py index 4a6eda7..f87cd71 100644 --- a/node_editor/gui/node_editor.py +++ b/node_editor/gui/node_editor.py @@ -1,4 +1,4 @@ -from PySide2 import QtWidgets, QtCore +from PySide6 import QtWidgets, QtCore from node_editor.gui.connection import Connection from node_editor.gui.node import Node diff --git a/node_editor/gui/node_list.py b/node_editor/gui/node_list.py index c0ab9b3..6ab29d8 100644 --- a/node_editor/gui/node_list.py +++ b/node_editor/gui/node_list.py @@ -1,4 +1,4 @@ -from PySide2 import QtWidgets, QtCore, QtGui +from PySide6 import QtWidgets, QtCore, QtGui class NodeList(QtWidgets.QListWidget): diff --git a/node_editor/gui/node_widget.py b/node_editor/gui/node_widget.py index 5328567..4fc1df6 100644 --- a/node_editor/gui/node_widget.py +++ b/node_editor/gui/node_widget.py @@ -1,6 +1,6 @@ # from PySide2.QtWidgets import QWidget, QVBoxLayout, QGraphicsScene -from PySide2 import QtWidgets, QtGui +from PySide6 import QtWidgets, QtGui from node_editor.gui.view import View from node_editor.gui.node import Node diff --git a/node_editor/gui/palette.py b/node_editor/gui/palette.py index 666992c..89e107c 100644 --- a/node_editor/gui/palette.py +++ b/node_editor/gui/palette.py @@ -1,6 +1,6 @@ -from PySide2 import QtGui -from PySide2.QtGui import QPalette, QColor -from PySide2.QtCore import Qt +from PySide6 import QtGui +from PySide6.QtGui import QPalette, QColor +from PySide6.QtCore import Qt palette = QtGui.QPalette() diff --git a/node_editor/gui/port.py b/node_editor/gui/port.py index 142a91b..d71775f 100644 --- a/node_editor/gui/port.py +++ b/node_editor/gui/port.py @@ -1,4 +1,4 @@ -from PySide2 import QtWidgets, QtGui, QtCore +from PySide6 import QtWidgets, QtGui, QtCore class Port(QtWidgets.QGraphicsPathItem): @@ -35,7 +35,7 @@ def set_is_output(self, is_output): def set_name(self, name): self._name = name nice_name = self._name.replace("_", " ").title() - self.port_text_width = self.font_metrics.width(nice_name) + self.port_text_width = self.font_metrics.horizontalAdvance(nice_name) if self._is_output: x = -self.radius_ - self.margin - self.port_text_width diff --git a/node_editor/gui/view.py b/node_editor/gui/view.py index fb431c5..31d6dfe 100644 --- a/node_editor/gui/view.py +++ b/node_editor/gui/view.py @@ -1,4 +1,4 @@ -from PySide2 import QtCore, QtGui, QtWidgets, QtOpenGL +from PySide6 import QtCore, QtGui, QtWidgets, QtOpenGLWidgets from node_editor.gui.connection import Connection from node_editor.gui.node import Node @@ -22,9 +22,10 @@ def __init__(self, parent): self.setRenderHint(QtGui.QPainter.Antialiasing) self._manipulationMode = 0 - gl_format = QtOpenGL.QGLFormat(QtOpenGL.QGL.SampleBuffers) + gl_format = QtGui.QSurfaceFormat() gl_format.setSamples(10) - gl_widget = QtOpenGL.QGLWidget(gl_format) + QtGui.QSurfaceFormat.setDefaultFormat(gl_format) + gl_widget = QtOpenGLWidgets.QOpenGLWidget() self.currentScale = 1 self._pan = False diff --git a/requirements.txt b/requirements.txt index d78765a..e3f31e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -PySide2 \ No newline at end of file +PySide6 \ No newline at end of file From f02d662cfdd915e44a38f660d014830351ad789c Mon Sep 17 00:00:00 2001 From: Jim Kring Date: Thu, 28 Jul 2022 12:03:02 -0700 Subject: [PATCH 2/2] Upgrade to PySide6 --- node_editor/gui/node_widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node_editor/gui/node_widget.py b/node_editor/gui/node_widget.py index 4fc1df6..3c3c100 100644 --- a/node_editor/gui/node_widget.py +++ b/node_editor/gui/node_widget.py @@ -1,4 +1,4 @@ -# from PySide2.QtWidgets import QWidget, QVBoxLayout, QGraphicsScene +# from PySide6.QtWidgets import QWidget, QVBoxLayout, QGraphicsScene from PySide6 import QtWidgets, QtGui