Skip to content

Commit

Permalink
Merge pull request #1139 from nstelter-slac/pyside6_upgrade_pt_1
Browse files Browse the repository at this point in the history
Pyside6/Qt6 Upgrade Pt 1
  • Loading branch information
YektaY authored Dec 19, 2024
2 parents a58c074 + cf85264 commit 583ac93
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 30 deletions.
14 changes: 12 additions & 2 deletions pydm/about_pydm/about.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
from qtpy.QtWidgets import QWidget, QTableWidgetItem
from qtpy.QtCore import Qt, PYQT_VERSION_STR, qVersion
from qtpy.QtCore import Qt, qVersion
from .about_ui import Ui_Form
from numpy import __version__ as numpyver
from pyqtgraph import __version__ as pyqtgraphver
import pydm
import sys
from os import path
import inspect
import qtpy

# get Qt binding and version
PYQT_VERSION = ""
if "PyQt" in qtpy.API_NAME:
PYQT_VERSION = qtpy.QtCore.PYQT_VERSION_STR
elif "PySide" in qtpy.API_NAME:
PYQT_VERSION = qtpy.QtCore.__version__
else:
PYQT_VERSION = "Unknown version"


class AboutWindow(QWidget):
Expand All @@ -18,7 +28,7 @@ def __init__(self, parent=None):
pyver = ".".join([str(v) for v in sys.version_info[0:3]])
self.ui.modulesVersionLabel.setText(
str(self.ui.modulesVersionLabel.text()).format(
pyver=pyver, numpyver=numpyver, pyqtgraphver=pyqtgraphver, pyqtver=PYQT_VERSION_STR, qtver=qVersion()
pyver=pyver, numpyver=numpyver, pyqtgraphver=pyqtgraphver, pyqtver=PYQT_VERSION, qtver=qVersion()
)
)
self.populate_external_tools_list()
Expand Down
10 changes: 5 additions & 5 deletions pydm/connection_inspector/connection_table_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QAbstractTableModel, Qt, QVariant, QTimer, Slot
from qtpy.QtCore import QAbstractTableModel, Qt, QTimer, Slot
from operator import attrgetter


Expand Down Expand Up @@ -47,17 +47,17 @@ def columnCount(self, parent=None):

def data(self, index, role=Qt.DisplayRole):
if not index.isValid():
return QVariant()
return None
if index.row() >= self.rowCount():
return QVariant()
return None
if index.column() >= self.columnCount():
return QVariant()
return None
column_name = self._column_names[index.column()]
conn = self.connections[index.row()]
if role == Qt.DisplayRole or role == Qt.EditRole:
return str(getattr(conn, column_name))
else:
return QVariant()
return None

def headerData(self, section, orientation, role=Qt.DisplayRole):
if role != Qt.DisplayRole:
Expand Down
4 changes: 2 additions & 2 deletions pydm/utilities/iconfont.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Optional

from qtpy import QtGui, QtWidgets
from qtpy.QtCore import QPoint, QRect, Qt, qRound
from qtpy.QtCore import QPoint, QRect, Qt
from qtpy.QtGui import QColor, QFont, QFontDatabase, QIcon, QIconEngine, QPainter, QPixmap

if sys.version_info[0] == 3:
Expand Down Expand Up @@ -182,7 +182,7 @@ def paint(self, painter, rect, mode, state):
color = self._base_color
painter.setPen(color)
scale_factor = 1.0
draw_size = 0.875 * qRound(rect.height() * scale_factor)
draw_size = 0.875 * round(rect.height() * scale_factor)
painter.setFont(self.icon_font.font(draw_size))
painter.setOpacity(1.0)
painter.drawText(rect, int(Qt.AlignCenter | Qt.AlignVCenter), self.char)
Expand Down
4 changes: 2 additions & 2 deletions pydm/widgets/axis_table_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QAbstractTableModel, Qt, QModelIndex, QVariant
from qtpy.QtCore import QAbstractTableModel, Qt, QModelIndex
from .baseplot import BasePlotAxisItem


Expand Down Expand Up @@ -83,7 +83,7 @@ def setData(self, index, value, role=Qt.EditRole):
column_name = self._column_names[index.column()]
axis = self.plot._axes[index.row()]
if role == Qt.EditRole:
if isinstance(value, QVariant):
if value is not None:
value = value.toString()
if not self.set_data(column_name, axis, value):
return False
Expand Down
4 changes: 2 additions & 2 deletions pydm/widgets/baseplot_table_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QAbstractTableModel, Qt, QVariant, QModelIndex
from qtpy.QtCore import QAbstractTableModel, Qt, QModelIndex
from qtpy.QtGui import QBrush
from .baseplot import BasePlotCurveItem

Expand Down Expand Up @@ -113,7 +113,7 @@ def setData(self, index, value, role=Qt.EditRole):
column_name = self._column_names[index.column()]
curve = self.plot._curves[index.row()]
if role == Qt.EditRole:
if isinstance(value, QVariant):
if value is not None:
value = value.toString()
if not self.set_data(column_name, curve, value):
return False
Expand Down
2 changes: 1 addition & 1 deletion pydm/widgets/enum_combo_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def addItem(self, text, userData=None):
----------
text : str
Title of the item
userData : QVariant
userData : object
Arbitrary user data that is stored in the Qt.UserRole
"""
super(PyDMEnumComboBox, self).addItem(text, userData)
Expand Down
8 changes: 4 additions & 4 deletions pydm/widgets/eventplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QModelIndex, QVariant
from qtpy.QtCore import QModelIndex
from .baseplot_table_model import BasePlotCurvesModel
from .baseplot_curve_editor import BasePlotCurveEditorDialog, PlotStyleColumnDelegate

Expand All @@ -17,15 +17,15 @@ def __init__(self, plot, parent=None):
def get_data(self, column_name, curve):
if column_name == "Channel":
if curve.address is None:
return QVariant()
return None
return str(curve.address)
elif column_name == "Y Index":
if curve.y_idx is None:
return QVariant()
return None
return curve.y_idx
elif column_name == "X Index":
if curve.x_idx is None:
return QVariant()
return None
return curve.x_idx
elif column_name == "Buffer Size":
return curve.getBufferSize()
Expand Down
8 changes: 4 additions & 4 deletions pydm/widgets/nt_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ def columnCount(self, parent=None):

def data(self, index, role=QtCore.Qt.DisplayRole):
if not index.isValid():
return QtCore.QVariant()
return None
if index.row() >= self.rowCount():
return QtCore.QVariant()
return None
if index.column() >= self.columnCount():
return QtCore.QVariant()
return None
if role == QtCore.Qt.DisplayRole:
try:
item = str(self._list[index.row()][index.column()])
except IndexError:
item = ""
return item
else:
return QtCore.QVariant()
return None

def setData(self, index, value, role=QtCore.Qt.EditRole):
if self.edit_method is None:
Expand Down
6 changes: 3 additions & 3 deletions pydm/widgets/scatterplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QModelIndex, QVariant
from qtpy.QtCore import QModelIndex
from .baseplot_table_model import BasePlotCurvesModel
from .baseplot_curve_editor import BasePlotCurveEditorDialog, PlotStyleColumnDelegate, RedrawModeColumnDelegate

Expand All @@ -17,11 +17,11 @@ def __init__(self, plot, parent=None):
def get_data(self, column_name, curve):
if column_name == "Y Channel":
if curve.y_address is None:
return QVariant()
return None
return str(curve.y_address)
elif column_name == "X Channel":
if curve.x_address is None:
return QVariant()
return None
return str(curve.x_address)
elif column_name == "Redraw Mode":
return curve.redraw_mode
Expand Down
4 changes: 2 additions & 2 deletions pydm/widgets/timeplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QModelIndex, QObject, QVariant
from qtpy.QtCore import QModelIndex, QObject
from typing import Optional
from .baseplot_table_model import BasePlotCurvesModel
from .baseplot_curve_editor import BasePlotCurveEditorDialog, ColorColumnDelegate, PlotStyleColumnDelegate
Expand All @@ -13,7 +13,7 @@ def __init__(self, plot, parent=None):
def get_data(self, column_name, curve):
if column_name == "Channel":
if curve.address is None:
return QVariant()
return None
return str(curve.address)
elif column_name == "Style":
return curve.plot_style
Expand Down
6 changes: 3 additions & 3 deletions pydm/widgets/waveformplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from qtpy.QtCore import QModelIndex, QObject, QVariant
from qtpy.QtCore import QModelIndex, QObject
from .baseplot_table_model import BasePlotCurvesModel
from .baseplot_curve_editor import (
BasePlotCurveEditorDialog,
Expand All @@ -23,11 +23,11 @@ def __init__(self, plot, parent=None):
def get_data(self, column_name, curve):
if column_name == "Y Channel":
if curve.y_address is None:
return QVariant()
return None
return str(curve.y_address)
elif column_name == "X Channel":
if curve.x_address is None:
return QVariant()
return None
return str(curve.x_address)
elif column_name == "Style":
return curve.plot_style
Expand Down

0 comments on commit 583ac93

Please sign in to comment.