Skip to content

Commit

Permalink
Merge pull request #9 from PyMoDAQ/bugfix/pyqt6_pyside2_6_compat
Browse files Browse the repository at this point in the history
Bugfix/pyqt6 pyside2 6 compat
  • Loading branch information
seb5g authored Oct 29, 2024
2 parents 39b701f + 3f1e1e2 commit 5a2cc3b
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/Testbase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
python-version: ${{ inputs.python }}
- name: Install package
run: |
sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils libgl1 libegl1
python -m pip install --upgrade pip
export QT_DEBUG_PLUGINS=1
pip install flake8 pytest pytest-cov pytest-qt pytest-xdist pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }}
pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }}
git branch
pip install -e .
- name: create local pymodaq folder and setting permissions
Expand All @@ -41,7 +41,7 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=docs
- name: Test with pytest
run: |
pytest --cov=pymodaq --cov-report=xml -n auto
pytest --cov --cov-report=xml
- name: Upload coverage to codecov.io
uses: codecov/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Testbase_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
set QT_DEBUG_PLUGINS=1
pip install flake8 pytest pytest-cov pytest-qt pytest-xdist pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }}
pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }}
git branch
pip install -e .
- name: Linting with flake8
Expand All @@ -36,7 +36,7 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=src/pymodaq/resources/QtDesigner_Ressources,docs
- name: Test with pytest
run: |
pytest --cov=pymodaq --cov-report=xml -n auto
pytest --cov --cov-report=xml
- name: Upload coverage to codecov.io
uses: codecov/[email protected]
with:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/Testp311pyqt5_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: '3.11 PyQt5 Windows'

on: [push]

jobs:
call_workflow:
uses: ./.github/workflows/Testbase_win.yml
with:
python: '3.11'
qt5: 'pyqt5'
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: '3.9 PyQt6'
name: '3.11 PyQt6'

on: [push]

jobs:
call_workflow:
uses: ./.github/workflows/Testbase.yml
with:
python: '3.8'
python: '3.11'
qt5: 'pyqt6'
10 changes: 10 additions & 0 deletions .github/workflows/Testp311pyqt6_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: '3.11 PyQt6 Windows'

on: [push]

jobs:
call_workflow:
uses: ./.github/workflows/Testbase_win.yml
with:
python: '3.11'
qt5: 'pyqt6'
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: '3.8 PySide2'
name: '3.11 PySide6'

on: [push]

jobs:
call_workflow:
uses: ./.github/workflows/Testbase.yml
with:
python: '3.8'
qt5: 'pyside2'
python: '3.11'
qt5: 'pyside6'
10 changes: 10 additions & 0 deletions .github/workflows/Testp311pyside6_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: '3.11 Pyside6 Windows'

on: [push]

jobs:
call_workflow:
uses: ./.github/workflows/Testbase_win.yml
with:
python: '3.11'
qt5: 'pyside6'
10 changes: 0 additions & 10 deletions .github/workflows/Testp38pyqt5_win.yml

This file was deleted.

34 changes: 19 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
PyMoDAQ GUI
###########

.. image:: https://img.shields.io/pypi/v/_gui.svg
.. image:: https://img.shields.io/pypi/v/pymodaq_gui.svg
:target: https://pypi.org/project/pymodaq_gui/
:alt: Latest Version

.. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
:target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
:alt: Documentation Status

.. image:: https://codecov.io/gh/PyMoDAQ/pymodaq_gui/branch/0.0.x_dev/graph/badge.svg?token=IQNJRCQDM2
.. image:: https://codecov.io/gh/PyMoDAQ/pymodaq_gui/branch/5.0.x_dev/graph/badge.svg?token=IQNJRCQDM2
:target: https://codecov.io/gh/PyMoDAQ/PyMoDAQ

====== ========== ======= ======
Expand All @@ -19,32 +19,36 @@ Python Qt Backend OS Passed
3.9 Qt5 Linux |39Qt5|
3.10 Qt5 Linux |310Qt5|
3.11 Qt5 Linux |311Qt5|
3.8 Qt5 Windows |38Qt5win|
3.8 PySide2 Linux |38pyside|
3.9 Qt6 Linux |39Qt6|
3.11 Qt5 Windows |311Qt5win|
3.11 PyQt6 Linux |311pyqt6|
3.11 PyQt6 Windows |311pyqt6_win|
3.11 PySide6 Windows |311pyside6_win|
====== ========== ======= ======


.. |38Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyqt5.yml/badge.svg?branch=pymodaq-dev
.. |38Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyqt5.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyqt5.yml

.. |39Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp39pyqt5.yml/badge.svg?branch=pymodaq-dev
.. |39Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp39pyqt5.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp39pyqt5.yml

.. |310Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp310pyqt5.yml/badge.svg?branch=pymodaq-dev
.. |310Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp310pyqt5.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp310pyqt5.yml

.. |311Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt5.yml/badge.svg?branch=pymodaq-dev
.. |311Qt5| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt5.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt5.yml

.. |38Qt5win| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyqt5_win.yml/badge.svg?branch=pymodaq-dev
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyqt5_win.yml
.. |311Qt5win| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt5_win.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt5_win.yml

.. |38pyside| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyside2.yml/badge.svg?branch=pymodaq-dev
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp38pyside2.yml
.. |311pyqt6| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt6.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt6.yml

.. |39Qt6| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp39pyqt6.yml/badge.svg?branch=pymodaq-dev
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp39pyqt6.yml
.. |311pyqt6_win| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt6_win.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyqt6_win.yml

.. |311pyside6_win| image:: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyside6_win.yml/badge.svg
:target: https://github.com/PyMoDAQ/pymodaq_gui/actions/workflows/Testp311pyside6_win.yml



Expand Down
4 changes: 2 additions & 2 deletions src/pymodaq_gui/parameter/ioxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from xml.etree import ElementTree as ET
from collections import OrderedDict
from qtpy import QtGui
from qtpy.QtCore import QDateTime
from qtpy.QtCore import QDateTime, QTime
from pymodaq_gui.parameter import Parameter

from pyqtgraph.parametertree.Parameter import PARAM_TYPES, PARAM_NAMES
Expand Down Expand Up @@ -105,7 +105,7 @@ def add_text_to_elt(elt, param):
elif param_type == 'date_time':
text = str(param.value().toMSecsSinceEpoch())
elif param_type == 'date':
text = str(QDateTime(param.value()).toMSecsSinceEpoch())
text = str(QDateTime(param.value(), QTime()).toMSecsSinceEpoch())
elif param_type == 'table_view':
try:
data = dict(classname=param.value().__class__.__name__,
Expand Down
12 changes: 6 additions & 6 deletions src/pymodaq_gui/parameter/pymodaq_ptypes/itemselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ class ItemSelect(QtWidgets.QListWidget):
def __init__(self, hasCheckbox=True):
QtWidgets.QListWidget.__init__(self)
self.hasCheckbox = hasCheckbox # Boolean indicating if listwidget item uses checkbox ot not
self.selItems = [] # Dummy variable to keep track of click order
self.selItems = [] # Dummy variable to keep track of click order
self.itemDoubleClicked.connect(self.doubleClickSelection)

def doubleClickSelection(self,item:QtWidgets.QListWidgetItem):
def doubleClickSelection(self, item: QtWidgets.QListWidgetItem):
"""
Function to select item. The selection depends if the item uses checkbox or not.
"""
if self.hasCheckbox:
item.setCheckState(int(2*bool(not item.checkState())))

item.setCheckState(QtCore.Qt.Checked if item.checkState() == QtCore.Qt.Unchecked
else QtCore.Qt.Unchecked)

def get_value(self):
"""
Expand All @@ -71,7 +71,7 @@ def get_value(self):
# Clean up list with non existing entries
[self.selItems.remove(item) for item in self.selItems if item not in allitems]
for item in self.all_items():
if item.checkState() != 0: # Item is selected
if item.checkState() != QtCore.Qt.Unchecked: # Item is selected
if item.text() not in self.selItems: # if item not in list then add it
self.selItems.append(item.text())
else: # Item is not selected
Expand Down Expand Up @@ -101,7 +101,7 @@ def select_item(self, item: QtWidgets.QListWidgetItem, doSelect:bool = False):
Function to select item. The selection depends if the item uses checkbox or not.
"""
if self.hasCheckbox:
item.setCheckState(int(2*doSelect)) # 2=QtCore.Qt.Checked, 0=QtCore.Qt.Unchecked
item.setCheckState(QtCore.Qt.Checked if doSelect else QtCore.Qt.Unchecked) # 2=QtCore.Qt.Checked, 0=QtCore.Qt.Unchecked
else:
item.setSelected(doSelect)

Expand Down
2 changes: 1 addition & 1 deletion src/pymodaq_gui/parameter/pymodaq_ptypes/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def treeWidgetChanged(self):
# # (WidgetParameter should just natively support this style)
# WidgetParameterItem.treeWidgetChanged(self)
if self.treeWidget() is not None:
self.treeWidget().setFirstItemColumnSpanned(self.subItem, True)
self.subItem.setFirstColumnSpanned(True)
self.treeWidget().setItemWidget(self.subItem, 0, self.w)

# for now, these are copied from ParameterItem.treeWidgetChanged
Expand Down
10 changes: 6 additions & 4 deletions src/pymodaq_gui/plotting/navigator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys
import os

from pathlib import Path

import numpy as np
from qtpy import QtGui, QtWidgets, QtCore
from qtpy.QtCore import Qt, QObject, Slot, Signal
Expand All @@ -21,10 +23,10 @@
from pymodaq_gui.parameter.pymodaq_ptypes.pixmap import PixmapCheckData


local_path = get_set_local_dir()
navigator_path = os.path.join(local_path, 'navigator_temp_files')
if not os.path.isdir(navigator_path):
os.makedirs(navigator_path)
local_path = get_set_local_dir(user=True)
# navigator_path = local_path.joinpath('navigator_temp_files')
# if not navigator_path.is_dir():
# navigator_path.mkdir()

logger = set_logger(get_module_name(__file__))

Expand Down
3 changes: 2 additions & 1 deletion src/pymodaq_gui/qt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def set_qt_backend():
logger.warning(f"The chosen Qt backend ({config('qtbackend', 'backend')}) has not been installed...\n"
f"Trying another...")
backends = config('qtbackend', 'backends')
backends.pop(config('qtbackend', 'backend'))
backends.pop(backends.index(config('qtbackend', 'backend')))
for backend in backends:
if backend.lower() in [mod.lower() for mod in sys.modules]:
backend_present = True
config['qtbackend', 'backend'] = backend
break

if backend_present:
Expand Down

0 comments on commit 5a2cc3b

Please sign in to comment.