Skip to content

ENH: WIP: enable pyside2 #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions azure-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
- bash: |
source activate test-environment-$(python)
conda install python=$(python) pytest-azurepipelines pydm --file dev-requirements.txt
conda install python=$(python) pyside2
displayName: 'Anaconda - Install Dependencies'

- bash: |
Expand All @@ -94,12 +95,18 @@ jobs:
echo python location: `which python`
echo pytest location: `which pytest`
python -c "from PyQt5 import QtCore; print(QtCore)"
python -c "from PySide2 import QtCore; print(QtCore)"
displayName: 'Debug - Conda List'
continueOnError: false

- bash: |
source activate test-environment-$(python)
export QT_API="pyqt5"
export PYTEST_QT_API="pyqt5"
python run_tests.py --timeout 30 --show-cov --test-run-title="Tests for $(Agent.OS) - Python $(python)" --napoleon-docstrings
export QT_API="pyside2"
export PYTEST_QT_API="pyside2"
pytest
displayName: 'Tests - Run'
continueOnError: false
env:
Expand Down
14 changes: 7 additions & 7 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, QModelIndex, QVariant, QTimer, Slot
from qtpy.QtCore import QAbstractTableModel, Qt, QModelIndex, QTimer, Slot
from qtpy.QtGui import QBrush
from operator import attrgetter

Expand All @@ -10,7 +10,7 @@ def __init__(self, connections=[], parent=None):
self.update_timer.setInterval(1000)
self.update_timer.timeout.connect(self.update_values)
self.connections = connections

def sort(self, col, order=Qt.AscendingOrder):
if self._column_names[col] == "value":
return
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
if index.row() >= self.rowCount():
return QVariant()
return
if index.column() >= self.columnCount():
return QVariant()
return
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

def headerData(self, section, orientation, role=Qt.DisplayRole):
if role != Qt.DisplayRole:
Expand All @@ -71,4 +71,4 @@ def headerData(self, section, orientation, role=Qt.DisplayRole):

@Slot()
def update_values(self):
self.dataChanged.emit(self.index(0,2), self.index(self.rowCount(),2))
self.dataChanged.emit(self.index(0,2), self.index(self.rowCount(),2))
4 changes: 2 additions & 2 deletions pydm/utilities/iconfont.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import json
from qtpy.QtGui import QFontDatabase, QIconEngine, QPixmap, QPainter, QColor, QFont, QIcon
from qtpy.QtCore import Qt, QRect, QPoint, qRound
from qtpy.QtCore import Qt, QRect, QPoint

if sys.version_info[0] == 3:
unichr = chr
Expand Down Expand Up @@ -121,7 +121,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, Qt.AlignCenter | Qt.AlignVCenter, self.char)
Expand Down
14 changes: 6 additions & 8 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, QModelIndex, QVariant
from qtpy.QtCore import QAbstractTableModel, Qt, QModelIndex
from qtpy.QtGui import QBrush
from .baseplot import BasePlotCurveItem

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

def data(self, index, role=Qt.DisplayRole):
if not index.isValid():
return QVariant()
return
if index.row() >= self.rowCount():
return QVariant()
return
if index.column() >= self.columnCount():
return QVariant()
return
column_name = self._column_names[index.column()]
curve = self.plot._curves[index.row()]
if role == Qt.DisplayRole or role == Qt.EditRole:
return self.get_data(column_name, curve)
elif role == Qt.BackgroundRole and column_name == "Color":
return QBrush(curve.color)
else:
return QVariant()
return

def get_data(self, column_name, curve):
if column_name == "Label":
if curve.name() is None:
return QVariant()
return
return str(curve.name())
elif column_name == "Color":
return curve.color_string
Expand All @@ -87,8 +87,6 @@ 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):
value = value.toString()
if not self.set_data(column_name, curve, value):
return False
else:
Expand Down
4 changes: 2 additions & 2 deletions pydm/widgets/enum_combo_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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 All @@ -77,7 +77,7 @@ def setItemText(self, index, text):
super(PyDMEnumComboBox, self).enum_strings_changed(tuple(self.itemText(i) for i in range(self.count())))
self._has_enums = True
self.check_enable_state()

# Internal methods
def set_items(self, enums):
"""
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,
RedrawModeColumnDelegate)
Expand All @@ -18,11 +18,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
return str(curve.y_address)
elif column_name == "X Channel":
if curve.x_address is None:
return QVariant()
return
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, QVariant
from qtpy.QtCore import QModelIndex
from .baseplot_table_model import BasePlotCurvesModel
from .baseplot_curve_editor import BasePlotCurveEditorDialog

Expand All @@ -12,7 +12,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
return str(curve.address)
return super(PyDMTimePlotCurvesModel, self).get_data(column_name,
curve)
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, QVariant
from qtpy.QtCore import QModelIndex
from .baseplot_table_model import BasePlotCurvesModel
from .baseplot_curve_editor import (BasePlotCurveEditorDialog,
RedrawModeColumnDelegate)
Expand All @@ -18,11 +18,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
return str(curve.y_address)
elif column_name == "X Channel":
if curve.x_address is None:
return QVariant()
return
return str(curve.x_address)
elif column_name == "Redraw Mode":
return curve.redraw_mode
Expand Down