Skip to content

Commit dae99db

Browse files
committed
upgrade pyside2 to pyside6
1 parent d340108 commit dae99db

File tree

6 files changed

+96
-61
lines changed

6 files changed

+96
-61
lines changed

deepethogram/gui/custom_widgets.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from typing import Union
88

99
import numpy as np
10-
from PySide2 import QtCore, QtGui, QtWidgets
11-
from PySide2.QtCore import Signal, Slot
10+
from PySide6 import QtCore, QtGui, QtWidgets
11+
from PySide6.QtCore import Signal, Slot
1212

1313
from deepethogram.file_io import VideoReader
1414

@@ -19,7 +19,7 @@
1919

2020

2121
def numpy_to_qpixmap(image: np.ndarray) -> QtGui.QPixmap:
22-
if image.dtype == np.float:
22+
if image.dtype == np.float64 or image.dtype == np.float32:
2323
image = float_to_uint8(image)
2424
H, W, C = int(image.shape[0]), int(image.shape[1]), int(image.shape[2])
2525
if C == 4:
@@ -33,7 +33,7 @@ def numpy_to_qpixmap(image: np.ndarray) -> QtGui.QPixmap:
3333

3434

3535
def float_to_uint8(image: np.ndarray) -> np.ndarray:
36-
if image.dtype == np.float:
36+
if image.dtype == np.float64 or image.dtype == np.float32:
3737
image = (image * 255).clip(min=0, max=255).astype(np.uint8)
3838
return image
3939

@@ -650,7 +650,7 @@ def initialize(
650650
button = self._make_button(behavior, i)
651651
self.buttons.append(button)
652652
layout.addWidget(button, 0, alignment=QtCore.Qt.AlignTop)
653-
layout.setMargin(0)
653+
layout.setContentsMargins(0, 0, 0, 0)
654654
layout.setSpacing(0)
655655
self.layout = layout
656656
self.setLayout(self.layout)
@@ -788,7 +788,7 @@ def add_behavior(self, behavior: str):
788788

789789
self.label._add_row()
790790
if i < 10:
791-
self.toggle_shortcuts.append(QtWidgets.QShortcut(QtGui.QKeySequence(str(i)), self))
791+
self.toggle_shortcuts.append(QtGui.QShortcut(QtGui.QKeySequence(str(i)), self))
792792
self.toggle_shortcuts[i].activated.connect(self.buttons.buttons[i].click)
793793

794794

@@ -875,10 +875,10 @@ def __init__(self):
875875
fixed=False,
876876
)
877877

878-
next_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Right"), self)
878+
next_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Right"), self)
879879
next_shortcut.activated.connect(partial(self.label.label.change_view_dx, 1))
880880
# next_shortcut.activated.connect(partial(self.label.change_view_dx, 1))
881-
back_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Left"), self)
881+
back_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Left"), self)
882882
back_shortcut.activated.connect(partial(self.label.label.change_view_dx, -1))
883883

884884
self.setCentralWidget(self.label)
@@ -897,4 +897,4 @@ def sizeHint(self):
897897
testing.initialize(behaviors=["background", "a", "b", "c", "d", "e"], n_timepoints=15000, debug=True)
898898
testing.update()
899899
testing.show()
900-
app.exec_()
900+
app.exec()

deepethogram/gui/main.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import numpy as np
1010
import pandas as pd
1111
from omegaconf import DictConfig, OmegaConf
12-
from PySide2 import QtCore, QtGui, QtWidgets
13-
from PySide2.QtCore import Slot
14-
from PySide2.QtWidgets import QFileDialog, QInputDialog, QMainWindow
12+
from PySide6 import QtCore, QtGui, QtWidgets
13+
from PySide6.QtCore import Slot
14+
from PySide6.QtWidgets import QFileDialog, QInputDialog, QMainWindow
1515

1616
from deepethogram import configuration, projects, utils
1717
from deepethogram.file_io import VideoReader
@@ -63,37 +63,37 @@ def __init__(self, cfg: DictConfig):
6363

6464
# scroll down to Standard Shorcuts to find what the keys are called:
6565
# https://doc.qt.io/qt-5/qkeysequence.html
66-
next_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Right"), self)
66+
next_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Right"), self)
6767
# partial functions create a new, separate function with certain default arguments
6868
next_shortcut.activated.connect(partial(self.move_n_frames, 1))
6969
next_shortcut.activated.connect(self.user_did_something)
7070

71-
up_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Up"), self)
71+
up_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Up"), self)
7272
up_shortcut.activated.connect(partial(self.move_n_frames, -cfg.vertical_arrow_jump))
7373
up_shortcut.activated.connect(self.user_did_something)
7474

75-
down_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Down"), self)
75+
down_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Down"), self)
7676
down_shortcut.activated.connect(partial(self.move_n_frames, cfg.vertical_arrow_jump))
7777
down_shortcut.activated.connect(self.user_did_something)
7878

79-
back_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Left"), self)
79+
back_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Left"), self)
8080
back_shortcut.activated.connect(partial(self.move_n_frames, -1))
8181
back_shortcut.activated.connect(self.user_did_something)
8282

83-
jumpleft_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Left"), self)
83+
jumpleft_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+Left"), self)
8484
jumpleft_shortcut.activated.connect(partial(self.move_n_frames, -cfg.control_arrow_jump))
8585
jumpleft_shortcut.activated.connect(self.user_did_something)
8686

87-
jumpright_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Right"), self)
87+
jumpright_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+Right"), self)
8888
jumpright_shortcut.activated.connect(partial(self.move_n_frames, cfg.control_arrow_jump))
8989
jumpright_shortcut.activated.connect(self.user_did_something)
9090

9191
self.ui.actionSave_Project.triggered.connect(self.save)
92-
save_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+S"), self)
92+
save_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+S"), self)
9393
save_shortcut.activated.connect(self.save)
94-
finalize_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+F"), self)
94+
finalize_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self)
9595
finalize_shortcut.activated.connect(self.finalize)
96-
open_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+O"), self)
96+
open_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+O"), self)
9797
open_shortcut.activated.connect(self.load_project)
9898
self.ui.finalize_labels.clicked.connect(self.finalize)
9999
self.ui.exportPredictions.clicked.connect(self.export_predictions)
@@ -109,7 +109,7 @@ def __init__(self, cfg: DictConfig):
109109
self.latent_name = None
110110
self.thresholds = None
111111
for i in range(10):
112-
self.toggle_shortcuts.append(QtWidgets.QShortcut(QtGui.QKeySequence(str(i)), self))
112+
self.toggle_shortcuts.append(QtGui.QShortcut(QtGui.QKeySequence(str(i)), self))
113113
tmp_func = partial(self.respond_to_keypress, i)
114114
self.toggle_shortcuts[i].activated.connect(tmp_func)
115115
self.toggle_shortcuts[i].activated.connect(self.user_did_something)
@@ -394,7 +394,7 @@ def generate_featureextractor_inference_args(self):
394394
keys.append(key)
395395
no_outputs.append(record["output"] is None)
396396
form = ShouldRunInference(keys, no_outputs)
397-
ret = form.exec_()
397+
ret = form.exec()
398398
if not ret:
399399
return
400400
should_infer = form.get_outputs()
@@ -518,7 +518,7 @@ def generate_sequence_inference_args(self):
518518
if has_latents[i]:
519519
keys_with_features.append(key)
520520
form = ShouldRunInference(keys_with_features, no_sequence_outputs)
521-
ret = form.exec_()
521+
ret = form.exec()
522522
if not ret:
523523
return
524524
should_infer = form.get_outputs()
@@ -617,7 +617,7 @@ def run_overnight(self):
617617

618618
def _new_project(self):
619619
form = CreateProject()
620-
ret = form.exec_()
620+
ret = form.exec()
621621
if not ret:
622622
return
623623
project_name = form.project_box.text()
@@ -1183,7 +1183,7 @@ def run() -> None:
11831183
window.resize(1024, 768)
11841184
window.show()
11851185

1186-
sys.exit(app.exec_())
1186+
sys.exit(app.exec())
11871187

11881188

11891189
def entry() -> None:

deepethogram/gui/mainwindow.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# WARNING! All changes made in this file will be lost!
1010

11-
from PySide2 import QtCore, QtWidgets
11+
from PySide6 import QtCore, QtGui, QtWidgets
1212

1313

1414
class Ui_MainWindow(object):
@@ -186,41 +186,41 @@ def setupUi(self, MainWindow):
186186
self.statusBar = QtWidgets.QStatusBar(MainWindow)
187187
self.statusBar.setObjectName("statusBar")
188188
MainWindow.setStatusBar(self.statusBar)
189-
self.actionNew_Project = QtWidgets.QAction(MainWindow)
189+
self.actionNew_Project = QtGui.QAction(MainWindow)
190190
self.actionNew_Project.setObjectName("actionNew_Project")
191-
self.actionSave_Project = QtWidgets.QAction(MainWindow)
191+
self.actionSave_Project = QtGui.QAction(MainWindow)
192192
self.actionSave_Project.setEnabled(False)
193193
self.actionSave_Project.setObjectName("actionSave_Project")
194-
self.actionAdd = QtWidgets.QAction(MainWindow)
194+
self.actionAdd = QtGui.QAction(MainWindow)
195195
self.actionAdd.setEnabled(False)
196196
self.actionAdd.setObjectName("actionAdd")
197-
self.actionRemove = QtWidgets.QAction(MainWindow)
197+
self.actionRemove = QtGui.QAction(MainWindow)
198198
self.actionRemove.setEnabled(False)
199199
self.actionRemove.setObjectName("actionRemove")
200-
self.actionStyle = QtWidgets.QAction(MainWindow)
200+
self.actionStyle = QtGui.QAction(MainWindow)
201201
self.actionStyle.setObjectName("actionStyle")
202-
self.actionOpen = QtWidgets.QAction(MainWindow)
202+
self.actionOpen = QtGui.QAction(MainWindow)
203203
self.actionOpen.setEnabled(False)
204204
self.actionOpen.setObjectName("actionOpen")
205-
self.actionEdit_list = QtWidgets.QAction(MainWindow)
205+
self.actionEdit_list = QtGui.QAction(MainWindow)
206206
self.actionEdit_list.setObjectName("actionEdit_list")
207-
self.actionNext = QtWidgets.QAction(MainWindow)
207+
self.actionNext = QtGui.QAction(MainWindow)
208208
self.actionNext.setObjectName("actionNext")
209-
self.actionPrevious = QtWidgets.QAction(MainWindow)
209+
self.actionPrevious = QtGui.QAction(MainWindow)
210210
self.actionPrevious.setObjectName("actionPrevious")
211-
self.actionOpen_Project = QtWidgets.QAction(MainWindow)
211+
self.actionOpen_Project = QtGui.QAction(MainWindow)
212212
self.actionOpen_Project.setObjectName("actionOpen_Project")
213-
self.importLabels = QtWidgets.QAction(MainWindow)
213+
self.importLabels = QtGui.QAction(MainWindow)
214214
self.importLabels.setObjectName("importLabels")
215-
self.actionAdd_videos = QtWidgets.QAction(MainWindow)
215+
self.actionAdd_videos = QtGui.QAction(MainWindow)
216216
self.actionAdd_videos.setObjectName("actionAdd_videos")
217-
self.classifierInference = QtWidgets.QAction(MainWindow)
217+
self.classifierInference = QtGui.QAction(MainWindow)
218218
self.classifierInference.setCheckable(True)
219219
self.classifierInference.setObjectName("classifierInference")
220-
self.actionOvernight = QtWidgets.QAction(MainWindow)
220+
self.actionOvernight = QtGui.QAction(MainWindow)
221221
self.actionOvernight.setCheckable(True)
222222
self.actionOvernight.setObjectName("actionOvernight")
223-
self.actionAdd_multiple = QtWidgets.QAction(MainWindow)
223+
self.actionAdd_multiple = QtGui.QAction(MainWindow)
224224
self.actionAdd_multiple.setObjectName("actionAdd_multiple")
225225
self.menuDeepEthogram.addAction(self.actionNew_Project)
226226
self.menuDeepEthogram.addAction(self.actionSave_Project)

deepethogram/gui/menus_and_popups.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pathlib
22
import warnings
33

4-
from PySide2 import QtCore, QtWidgets
4+
from PySide6 import QtCore, QtWidgets
55

66

77
def simple_popup_question(parent, message: str):
@@ -25,7 +25,7 @@ def overwrite_or_not(parent):
2525
)
2626
overwrite = msgBox.addButton("Overwrite", QtWidgets.QMessageBox.YesRole)
2727
unlabeled = msgBox.addButton("Only import unlabeled", QtWidgets.QMessageBox.NoRole)
28-
msgBox.exec_()
28+
msgBox.exec()
2929
if msgBox.clickedButton() is overwrite:
3030
return True
3131
elif msgBox.clickedButton() is unlabeled:
@@ -46,7 +46,7 @@ def __init__(self, parent=None):
4646
)
4747
msgBox.addButton(QtWidgets.QPushButton("Overwrite"), QtWidgets.QMessageBox.YesRole)
4848
msgBox.addButton(QtWidgets.QPushButton("Only import unlabeled"), QtWidgets.QMessageBox.NoRole)
49-
msgBox.exec_()
49+
msgBox.exec()
5050

5151

5252
class CreateProject(QtWidgets.QDialog):
@@ -148,8 +148,8 @@ def get_outputs(self):
148148
form = ShouldRunInference(
149149
["M134_20141203_v001", "M134_20141203_v002", "M134_20141203_v004"] * num, [True, True, False] * num
150150
)
151-
ret = form.exec_()
151+
ret = form.exec()
152152
if ret:
153153
print(form.get_outputs())
154-
# ret = app.exec_()
154+
# ret = app.exec()
155155
# print(ret)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "deepethogram"
7-
version = "0.2.0"
7+
version = "0.3.0"
88
description = "Temporal action detection for biology"
99
readme = "README.md"
1010
authors = [
@@ -25,7 +25,7 @@ dependencies = [
2525
"opencv-python-headless",
2626
"opencv-transforms",
2727
"pandas<1.4",
28-
"PySide2==5.13.2",
28+
"PySide6>=6.6.0",
2929
"scikit-learn<1.1",
3030
"scipy<1.8",
3131
"tqdm",
@@ -51,7 +51,7 @@ packages = ["deepethogram"]
5151

5252
[tool.ruff]
5353
# Python version compatibility
54-
target-version = "py37"
54+
target-version = "py38"
5555

5656
# Same as Black.
5757
line-length = 120

0 commit comments

Comments
 (0)