Skip to content

Commit

Permalink
both pyqt5 and pyqt6 supported
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrolexa committed Jan 24, 2025
1 parent 9e3cf4b commit 3c4683c
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 45 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Changelog
All notable pypsbuilder changes.

## [2.6.1] - master
### Added
- Both PyQt5 and PyQt6 are supported and need to be specified as
extra option during installation

## [2.6.0] - 2025-01-23
Initial PyQt6 release

## [2.5.3] - 2024-12-18
Latest version using PyQt5
Latest version using PyQt5 only

## [2.5.0] - 2024-12-13
### Fixed
Expand Down
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ for Windows use PowerShell:
and install **pypsbuilder** using pip within the environment:
pip install pypsbuilder
pip install pypsbuilder[pyqt6]
Jupyter Lab could be also installed providing extra option:
Providing jupyter option, JupyterLab will be also installed:
pip install pypsbuilder[extra]
pip install pypsbuilder[pyqt6,jupyter]
## I'm using conda or mamba to manage environments
Expand All @@ -53,29 +53,23 @@ or
mamba activate pyps
and install with pip. Note that PyQt6 is not yet available in conda repositories,
so we need to use the 2.5.3 version:
so we need to use the pyqt5 version:
pip install pypsbuilder==2.5.3
pip install pypsbuilder[pyqt5]
#### Note for macOS
If you have environment created with conda/mamba install the pypsbuilder with:
pip install pypsbuilder==2.5.3 --no-deps
#### Install master version
You can install latest version from master branch on GitHub:
pip install https://github.com/ondrolexa/pypsbuilder/archive/master.zip
> [!NOTE]
> If you encounter errors during install, try to install without upgrading dependencies:
> ```
> pip install --no-deps pypsbuilder[pyqt5]
> ```
#### Upgrade existing installation
To upgrade an already installed **pypsbuilder** to the latest release:
pip install --upgrade pypsbuilder
or to latest master version:
or to the latest master version:
pip install --upgrade https://github.com/ondrolexa/pypsbuilder/archive/master.zip
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
dependencies = [
"numpy",
"matplotlib>=3.8",
"pyqt6",
"qtpy",
"scipy",
"scikit-image",
"networkx",
Expand All @@ -34,13 +34,12 @@ dependencies = [
]

[project.optional-dependencies]
extra = ["jupyterlab"]
pyqt5 = ["pyqt5"]
pyqt6 = ["pyqt6"]
jupyter = ["jupyterlab"]
tests = ["pytest", "pytest-cov"]
docs = ["sphinx", "sphinx_mdinclude", "sphinx_rtd_theme"]
dev = [
"pypsbuilder[extra,tests,docs]",
"black",
]
dev = ["pypsbuilder[pyqt6,jupyter,tests,docs]", "black"]

[project.urls]
Homepage = "https://github.com/ondrolexa/pypsbuilder"
Expand Down
2 changes: 1 addition & 1 deletion pypsbuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"get_tcapi",
)

__version__ = "2.6.0"
__version__ = "2.6.1"
__author__ = "Ondrej Lexa"
__copyright__ = "© Ondrej Lexa 2016-2025"
__email__ = "[email protected]"
25 changes: 11 additions & 14 deletions pypsbuilder/psbuilders.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import warnings

import importlib.resources as ires
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtCore import QT_VERSION_STR
from PyQt6.QtCore import PYQT_VERSION_STR
from qtpy import QtCore, QtGui, QtWidgets
from qtpy import QT_VERSION
from qtpy import API as QTPY_API


import numpy as np
import matplotlib
Expand Down Expand Up @@ -1347,7 +1348,7 @@ def add_userdefined(self, checked=True):
self.unimodel.appendRow(id_uni, uni)
self.uni_connect(id_uni, candidates)
self.changed = True
# self.unisel.select(idx, QtCore.QItemSelectionModel.ClearAndSelect | QtCore.QItemSelectionModel.Rows)
# self.unisel.select(idx, QtCore.QItemSelectionModel.SelectionFlag.ClearAndSelect | QtCore.QItemSelectionModel.SelectionFlag.Rows)
idx = self.unimodel.getIndexID(id_uni)
self.uniview.selectRow(idx.row())
self.uniview.scrollToBottom()
Expand Down Expand Up @@ -1950,8 +1951,7 @@ def builder_ui_settings(self):

def app_settings(self, write=False):
# Applicatiom settings
qtver = QtCore.PYQT_VERSION_STR.split(".")[0]
builder_settings = QtCore.QSettings("LX", f"ptbuilder pyqt{qtver}")
builder_settings = QtCore.QSettings("LX", f"ptbuilder {QTPY_API}{QT_VERSION.split(".")[0]}")
if write:
builder_settings.setValue("steps", self.spinSteps.value())
builder_settings.setValue("precision", self.spinPrec.value())
Expand Down Expand Up @@ -2713,7 +2713,7 @@ def do_calc(self, calcT, phases={}, out={}, run_tc=True):
self.unimodel.appendRow(id_uni, uni)
self.uniview.resizeColumnsToContents()
self.changed = True
# self.unisel.select(idx, QtCore.QItemSelectionModel.ClearAndSelect | QtCore.QItemSelectionModel.Rows)
# self.unisel.select(idx, QtCore.QItemSelectionModel.SelectionFlag.ClearAndSelect | QtCore.QItemSelectionModel.SelectionFlag.Rows)
idx = self.unimodel.getIndexID(id_uni)
self.uniview.selectRow(idx.row())
self.uniview.scrollToBottom()
Expand Down Expand Up @@ -3686,7 +3686,7 @@ def do_calc(self, calcT, phases={}, out={}, run_tc=True):
self.unimodel.appendRow(id_uni, uni)
self.uniview.resizeColumnsToContents()
self.changed = True
# self.unisel.select(idx, QtCore.QItemSelectionModel.ClearAndSelect | QtCore.QItemSelectionModel.Rows)
# self.unisel.select(idx, QtCore.QItemSelectionModel.SelectionFlag.ClearAndSelect | QtCore.QItemSelectionModel.SelectionFlag.Rows)
idx = self.unimodel.getIndexID(id_uni)
self.uniview.selectRow(idx.row())
self.uniview.scrollToBottom()
Expand Down Expand Up @@ -4682,7 +4682,7 @@ def do_calc(self, calcT, phases={}, out={}, run_tc=True):
self.unimodel.appendRow(id_uni, uni)
self.uniview.resizeColumnsToContents()
self.changed = True
# self.unisel.select(idx, QtCore.QItemSelectionModel.ClearAndSelect | QtCore.QItemSelectionModel.Rows)
# self.unisel.select(idx, QtCore.QItemSelectionModel.SelectionFlag.ClearAndSelect | QtCore.QItemSelectionModel.SelectionFlag.Rows)
idx = self.unimodel.getIndexID(id_uni)
self.uniview.selectRow(idx.row())
self.uniview.scrollToBottom()
Expand Down Expand Up @@ -4895,7 +4895,7 @@ def data(self, index, role=QtCore.Qt.ItemDataRole.DisplayRole):
return None
inv = self.ps.invpoints[self.invlist[index.row()]]
# highlight not finished invpoints - move to plot ???
# if role == QtCore.Qt.ForegroundRole:
# if role == QtCore.Qt.ItemDataRole.ForegroundRole:
# all_uni = inv.all_unilines()
# isnew1, id = self.ps.getiduni(UniLine(phases=all_uni[0][0], out=all_uni[0][1]))
# isnew2, id = self.ps.getiduni(UniLine(phases=all_uni[1][0], out=all_uni[1][1]))
Expand Down Expand Up @@ -5244,10 +5244,7 @@ def __init__(self, builder, version, copyright, parent=None):
author.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)

swinfo = QtWidgets.QLabel(
"Python:{} Qt:{} PyQt:{}".format(
sys.version.split()[0], QT_VERSION_STR, PYQT_VERSION_STR
)
)
f"Python:{sys.version.split()[0]} {QTPY_API} {QT_VERSION}")
swinfo.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)

github = QtWidgets.QLabel(
Expand Down
1 change: 1 addition & 0 deletions pypsbuilder/ui/compile_ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pyuic6 adduni.ui > ../ui_adduni.py
pyuic6 addinv.ui > ../ui_addinv.py
pyuic6 uniguess.ui > ../ui_uniguess.py

# do not forget to replace PyQt6 with qtpy in all generated .py files
2 changes: 1 addition & 1 deletion pypsbuilder/ui_addinv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets


class Ui_AddInv(object):
Expand Down
2 changes: 1 addition & 1 deletion pypsbuilder/ui_adduni.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets


class Ui_AddUni(object):
Expand Down
2 changes: 1 addition & 1 deletion pypsbuilder/ui_ptbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets


class Ui_PTBuilder(object):
Expand Down
2 changes: 1 addition & 1 deletion pypsbuilder/ui_pxbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets


class Ui_PXBuilder(object):
Expand Down
2 changes: 1 addition & 1 deletion pypsbuilder/ui_txbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets


class Ui_TXBuilder(object):
Expand Down
2 changes: 1 addition & 1 deletion pypsbuilder/ui_uniguess.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtGui, QtWidgets
from qtpy import QtCore, QtGui, QtWidgets


class Ui_UniGuess(object):
Expand Down

0 comments on commit 3c4683c

Please sign in to comment.