From b6ff1843302b2c809c882820a6b86ccce1151e73 Mon Sep 17 00:00:00 2001 From: Mark Sandell Date: Thu, 4 Jul 2024 14:05:35 -0700 Subject: [PATCH] PyQt vs. PySide QFontDialog.getFont difference python3 QMimeData requires QByteArray, not str Signed-off-by: Mark Sandell s --- usdmanager/__init__.py | 6 +++--- usdmanager/preferences_dialog.py | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/usdmanager/__init__.py b/usdmanager/__init__.py index 8f9ff93..98a8993 100644 --- a/usdmanager/__init__.py +++ b/usdmanager/__init__.py @@ -3862,9 +3862,9 @@ def mouseMoveEvent(self, e): drag = QtGui.QDrag(self) drag.setPixmap(self.style().standardIcon(QtWidgets.QStyle.SP_ArrowUp).pixmap(12, 12)) mimeData = QtCore.QMimeData() - mimeData.setData("action", "moveTab") + mimeData.setData("action", QtCore.QByteArray(b"moveTab")) # Set the source window index so we know which window the drag/drop came from. - mimeData.setData("window", str(self.currentWindowIndex())) + mimeData.setData("window", QtCore.QByteArray(str(self.currentWindowIndex()).encode('utf-8'))) drag.setMimeData(mimeData) drag.exec_() @@ -3877,7 +3877,7 @@ def dragEnterEvent(self, e): """ mime = e.mimeData() formats = mime.formats() - if "action" in formats and "window" in formats and mime.data("action") == "moveTab": + if "action" in formats and "window" in formats and mime.data("action") == b"moveTab": e.acceptProposedAction() def currentWindowIndex(self): diff --git a/usdmanager/preferences_dialog.py b/usdmanager/preferences_dialog.py index eb7cb7e..deb29e9 100644 --- a/usdmanager/preferences_dialog.py +++ b/usdmanager/preferences_dialog.py @@ -17,6 +17,7 @@ """ Create a Preferences dialog. """ +import Qt from Qt.QtCore import Slot, QRegExp from Qt.QtGui import QRegExpValidator from Qt.QtWidgets import QAbstractButton, QDialog, QDialogButtonBox, QFontDialog, QLineEdit, QMessageBox, QVBoxLayout @@ -376,7 +377,11 @@ def restoreDefaults(self, btn): def selectFont(self, *args): """ Update the user's font preference. """ - font, ok = QFontDialog.getFont(self.docFont, self, "Select Font") + result = QFontDialog.getFont(self.docFont, self, "Select Font") + if Qt.IsPyQt4 or Qt.IsPyQt5: + font, ok = result + else: + ok, font = result if ok: self.docFont = font self.updateFontLabel()