Skip to content

Commit bfb2fe6

Browse files
authored
Merge pull request #70 from AdaptiveParticles/patch_qt
Update Qt usage to accommodate newer versions
2 parents 72e8ccd + 4a4983d commit bfb2fe6

File tree

7 files changed

+51
-36
lines changed

7 files changed

+51
-36
lines changed

.github/workflows/build-deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ jobs:
6767
- name: Submodule recursive
6868
run: git submodule update --init --recursive
6969

70+
- name: Update vcpkg
71+
run: |
72+
cd ${{ env.VCPKG_ROOT }}
73+
git checkout master
74+
7075
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
7176
- uses: lukka/get-cmake@latest
7277
# Restore both vcpkg and its artifacts from the GitHub cache service.

.github/workflows/deploy-docs.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
- name: Submodule recursive
4141
run: git submodule update --init --recursive
4242

43+
- name: Update vcpkg
44+
run: |
45+
cd ${{ env.VCPKG_ROOT }}
46+
git checkout master
47+
4348
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
4449
- uses: lukka/get-cmake@latest
4550
# Restore both vcpkg and its artifacts from the GitHub cache service.
@@ -117,11 +122,11 @@ jobs:
117122
- name: Get version
118123
id: get_version
119124
run: |
120-
echo ::set-output name=VERSION_TAG::${GITHUB_REF#refs/tags/}
125+
echo "VERSION_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
121126
122127
- name: Deploy documentation
123128
if: ${{ (env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == 'develop') }}
124-
uses: JamesIves/github-pages-deploy-action@v4.3.3
129+
uses: JamesIves/github-pages-deploy-action@v4
125130
with:
126131
branch: gh-pages # The branch the action should deploy to.
127132
folder: docs/build/html # The folder the action should deploy.

.github/workflows/quick-test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ jobs:
4545
- name: Submodule recursive
4646
run: git submodule update --init --recursive
4747

48+
- name: Update vcpkg
49+
run: |
50+
cd ${{ env.VCPKG_ROOT }}
51+
git checkout master
52+
4853
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
4954
- uses: lukka/get-cmake@latest
5055
# Restore both vcpkg and its artifacts from the GitHub cache service.
@@ -115,7 +120,7 @@ jobs:
115120
pytest -vv --cov-report xml --cov=pyapr
116121
117122
- name: Upload coverage report
118-
uses: codecov/codecov-action@v2
123+
uses: codecov/codecov-action@v3
119124

120125
- name: Build documentation
121126
run: |

pyapr/utils/filegui.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import pyqtgraph.Qt as Qt
1+
from pyqtgraph.Qt import QtCore, QtWidgets
22
import pyqtgraph as pg
33
import matplotlib.pyplot as plt
44
import numpy as np
55

66

7-
class DoubleSlider(Qt.QtWidgets.QSlider):
7+
class DoubleSlider(QtWidgets.QSlider):
88
"""
99
Extends QSlider to allow floating-point values
1010
@@ -13,7 +13,7 @@ class DoubleSlider(Qt.QtWidgets.QSlider):
1313
"""
1414

1515
# create a signal that we can connect to if necessary
16-
doubleValueChanged = Qt.QtCore.pyqtSignal(float)
16+
doubleValueChanged = QtCore.pyqtSignal(float)
1717

1818
def __init__(self, decimals=2, *args, **kwargs):
1919
super(DoubleSlider, self).__init__(*args, **kwargs)
@@ -51,10 +51,10 @@ def __init__(self, window, label_name, decimals=0):
5151

5252
self.decimals = decimals
5353

54-
self.slider = DoubleSlider(decimals, Qt.QtCore.Qt.Horizontal, window)
55-
self.maxBox = Qt.QtWidgets.QDoubleSpinBox(window, decimals=self.decimals)
54+
self.slider = DoubleSlider(decimals, QtCore.Qt.Horizontal, window)
55+
self.maxBox = QtWidgets.QDoubleSpinBox(window, decimals=self.decimals)
5656

57-
self.label = Qt.QtWidgets.QLabel(window)
57+
self.label = QtWidgets.QLabel(window)
5858

5959
self.maxBox.setMaximum(64000)
6060
self.maxBox.setValue(300)
@@ -95,13 +95,13 @@ def updateText(self):
9595
self.label.setText(text_str)
9696

9797

98-
class MainWindowImage(Qt.QtWidgets.QWidget):
98+
class MainWindowImage(QtWidgets.QWidget):
9999
def __init__(self, slider_decimals=0):
100100
super(MainWindowImage, self).__init__()
101101

102102
self.setMouseTracking(True)
103103

104-
self.layout = Qt.QtGui.QGridLayout()
104+
self.layout = QtWidgets.QGridLayout()
105105
self.setLayout(self.layout)
106106
self.layout.setSpacing(0)
107107

@@ -112,7 +112,7 @@ def __init__(self, slider_decimals=0):
112112
self.layout.addWidget(self.pg_win, 0, 0, 3, 1)
113113

114114
# add a slider
115-
self.slider = Qt.QtWidgets.QSlider(Qt.QtCore.Qt.Horizontal, self)
115+
self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self)
116116

117117
self.slider.valueChanged.connect(self.valuechange)
118118

@@ -129,27 +129,27 @@ def __init__(self, slider_decimals=0):
129129
self.hist.item.sigLevelsChanged.connect(self.histogram_updated)
130130

131131
# add a QLabel giving information on the current slice and the APR
132-
self.slice_info = Qt.QtGui.QLabel(self)
132+
self.slice_info = QtWidgets.QLabel(self)
133133

134134
self.slice_info.move(20, 20)
135135
self.slice_info.setFixedWidth(250)
136136

137137
# add a label for the current cursor position
138138

139-
self.cursor = Qt.QtGui.QLabel(self)
139+
self.cursor = QtWidgets.QLabel(self)
140140

141141
self.cursor.move(20, 40)
142142
self.cursor.setFixedWidth(250)
143143

144144
# add parameter tuning
145145

146146
# create push button
147-
self.exit_button = Qt.QtWidgets.QPushButton('Use Parameters', self)
147+
self.exit_button = QtWidgets.QPushButton('Use Parameters', self)
148148
self.exit_button.setFixedWidth(300)
149149
self.exit_button.move(300, 10)
150150
self.exit_button.clicked.connect(self.exitPressed)
151151

152-
self.max_label = Qt.QtWidgets.QLabel(self)
152+
self.max_label = QtWidgets.QLabel(self)
153153
self.max_label.setText("Slider Max")
154154
self.max_label.move(610, 50)
155155

@@ -278,11 +278,11 @@ def update_slice(self, new_view):
278278
self.updateSliceText(new_view)
279279

280280
def keyPressEvent(self, event):
281-
if event.key() == Qt.QtCore.Qt.Key_Left:
281+
if event.key() == QtCore.Qt.Key_Left:
282282
# back a frame
283283
self.update_slice(self.current_view - 1)
284284

285-
if event.key() == Qt.QtCore.Qt.Key_Right:
285+
if event.key() == QtCore.Qt.Key_Right:
286286
# forward a frame
287287
self.update_slice(self.current_view + 1)
288288

@@ -345,13 +345,13 @@ def set_image(self, img, converter):
345345

346346
self.hist.setImageItem(self.img_I)
347347

348-
self.img_I_ds.setRect(Qt.QtCore.QRectF(self.min_x, self.min_y, self.x_num_ds*2, self.y_num_ds*2))
349-
self.img_I.setRect(Qt.QtCore.QRectF(self.min_x, self.min_y, self.x_num, self.y_num))
348+
self.img_I_ds.setRect(QtCore.QRectF(self.min_x, self.min_y, self.x_num_ds*2, self.y_num_ds*2))
349+
self.img_I.setRect(QtCore.QRectF(self.min_x, self.min_y, self.x_num, self.y_num))
350350

351351
## Set up the z slider
352352
self.slider.setMinimum(0)
353353
self.slider.setMaximum(self.z_num - 1)
354-
self.slider.setTickPosition(Qt.QtWidgets.QSlider.TicksBothSides)
354+
self.slider.setTickPosition(QtWidgets.QSlider.TicksBothSides)
355355
self.slider.setGeometry(0.05 * self.full_size, 0.97 * self.full_size, 0.95 * self.full_size, 40)
356356

357357
self.setLUT('viridis')
@@ -367,30 +367,30 @@ def closeEvent(self, event):
367367
class InteractiveIO:
368368
def __init__(self):
369369
# class methods require a QApplication instance - this helps to avoid multiple instances...
370-
self.app = Qt.QtGui.QApplication.instance()
370+
self.app = QtWidgets.QApplication.instance()
371371
if self.app is None:
372-
self.app = Qt.QtGui.QApplication([])
372+
self.app = QtWidgets.QApplication([])
373373

374374
@staticmethod
375375
def get_tiff_file_name():
376376
print("Please select an input image file (TIFF)")
377-
file_name = Qt.QtGui.QFileDialog.getOpenFileName(None, "Open Tiff", "~", "(*.tif *.tiff)")
377+
file_name = QtWidgets.QFileDialog.getOpenFileName(None, "Open Tiff", "~", "(*.tif *.tiff)")
378378
return file_name[0]
379379

380380
@staticmethod
381381
def get_apr_file_name():
382382
print("Please select an input APR file (HDF5)")
383-
file_name = Qt.QtGui.QFileDialog.getOpenFileName(None, "Open APR", "", "(*.apr *.h5)")
383+
file_name = QtWidgets.QFileDialog.getOpenFileName(None, "Open APR", "", "(*.apr *.h5)")
384384
return file_name[0]
385385

386386
@staticmethod
387387
def save_apr_file_name(default_name='output.apr'):
388-
file_name = Qt.QtGui.QFileDialog.getSaveFileName(None, "Save APR", default_name, "(*.apr *.h5)")
388+
file_name = QtWidgets.QFileDialog.getSaveFileName(None, "Save APR", default_name, "(*.apr *.h5)")
389389
return file_name[0]
390390

391391
@staticmethod
392392
def save_tiff_file_name(default_name='output.tif'):
393-
file_name = Qt.QtGui.QFileDialog.getSaveFileName(None, "Save TIFF", default_name, "(*.tif *.tiff)")
393+
file_name = QtWidgets.QFileDialog.getSaveFileName(None, "Save TIFF", default_name, "(*.tif *.tiff)")
394394
return file_name[0]
395395

396396
def interactive_apr(self, converter, apr, img, slider_decimals=2):

pyapr/viewer/compressInteractive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
1+
from pyqtgraph.Qt import QtCore, QtWidgets
22
import pyqtgraph as pg
33
from _pyaprwrapper.data_containers import APR, ShortParticles
44
from _pyaprwrapper.viewer import compress_and_fill_slice
@@ -156,9 +156,9 @@ def interactive_compression(apr: APR,
156156
pg.setConfigOption('foreground', 'k')
157157
pg.setConfigOption('imageAxisOrder', 'row-major')
158158

159-
app = QtGui.QApplication.instance()
159+
app = QtWidgets.QApplication.instance()
160160
if app is None:
161-
app = QtGui.QApplication([])
161+
app = QtWidgets.QApplication([])
162162

163163
## Create window with GraphicsView widget
164164
win = CompressWindow()

pyapr/viewer/partsViewer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
1+
from pyqtgraph.Qt import QtCore, QtWidgets
22
from _pyaprwrapper.data_containers import APR, ByteParticles, ShortParticles, FloatParticles, LongParticles
33
from _pyaprwrapper.viewer import fill_slice, fill_slice_level, min_occupied_level
44
from ..utils import particles_to_type
@@ -364,9 +364,9 @@ def parts_viewer(apr: APR,
364364
Input particle intensity values.
365365
"""
366366
_check_input(apr, parts)
367-
app = QtGui.QApplication.instance()
367+
app = QtWidgets.QApplication.instance()
368368
if app is None:
369-
app = QtGui.QApplication([])
369+
app = QtWidgets.QApplication([])
370370

371371
pg.setConfigOption('background', 'w')
372372
pg.setConfigOption('foreground', 'k')

pyapr/viewer/raycastViewer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
1+
from pyqtgraph.Qt import QtCore, QtWidgets
22
import pyqtgraph as pg
33
from _pyaprwrapper.data_containers import APR, ByteParticles, ShortParticles, FloatParticles, LongParticles
44
from _pyaprwrapper.viewer import APRRaycaster
@@ -314,9 +314,9 @@ def raycast_viewer(apr: APR,
314314
pg.setConfigOption('foreground', 'k')
315315
pg.setConfigOption('imageAxisOrder', 'row-major')
316316

317-
app = QtGui.QApplication.instance()
317+
app = QtWidgets.QApplication.instance()
318318
if app is None:
319-
app = QtGui.QApplication([])
319+
app = QtWidgets.QApplication([])
320320

321321
# Create window with GraphicsView widget
322322
win = MainWindowImage()

0 commit comments

Comments
 (0)