Skip to content
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

Convert the codebase to PyQt6 #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion planetary_system_stacker/Test_programs/Info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import os
import platform
from PyQt5 import QtCore
from PyQt6 import QtCore
import psutil
import matplotlib
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sys import argv

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
from cv2 import NORM_MINMAX, normalize, cvtColor, COLOR_GRAY2RGB, circle, line
from numpy import uint8, uint16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# WARNING! All changes made in this file will be lost!


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets


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


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
Expand Down
4 changes: 2 additions & 2 deletions planetary_system_stacker/Test_programs/gui_with_label_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from sys import argv
from urllib import request

from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt6 import QtWidgets
from PyQt6.QtCore import Qt

from gui_with_label import Ui_Form

Expand Down
4 changes: 2 additions & 2 deletions planetary_system_stacker/Test_programs/list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from sys import argv

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtCore import Qt

from list_view_widget import Ui_ListViewWidget

Expand Down
3 changes: 1 addition & 2 deletions planetary_system_stacker/Test_programs/list_view_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets

class Ui_ListViewWidget(object):
def setupUi(self, ListViewWidget):
Expand Down Expand Up @@ -35,4 +35,3 @@ def retranslateUi(self, ListViewWidget):
ListViewWidget.setWindowTitle(_translate("ListViewWidget", "Frame"))
self.addButton.setText(_translate("ListViewWidget", "+"))
self.removeButton.setText(_translate("ListViewWidget", "-"))

2 changes: 1 addition & 1 deletion planetary_system_stacker/Test_programs/main_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from skimage import img_as_ubyte
from PyQt5 import QtWidgets
from PyQt6 import QtWidgets

from align_frames import AlignFrames
from alignment_points import AlignmentPoints
Expand Down
3 changes: 1 addition & 2 deletions planetary_system_stacker/Test_programs/spinbox_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Frame(object):
Expand All @@ -18,4 +18,3 @@ def setupUi(self, Frame):
self.spinBox = QtWidgets.QSpinBox(Frame)
self.spinBox.setGeometry(QtCore.QRect(9, 27, 131, 20))
self.spinBox.setObjectName("spinBox")

6 changes: 3 additions & 3 deletions planetary_system_stacker/Test_programs/spinbox_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from sys import argv
from time import sleep

from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow, QProxyStyle, QStyle
from PyQt6 import QtWidgets, QtCore
from PyQt6.QtWidgets import QApplication, QMainWindow, QProxyStyle, QStyle

class CustomStyle(QProxyStyle):
def styleHint(self, hint, option=None, widget=None, returnData=None):
Expand Down Expand Up @@ -33,4 +33,4 @@ def spinbox_changed(self):
app = QtWidgets.QApplication(argv)
window = SpinBoxTest()
window.show()
app.exec_()
app.exec_()
32 changes: 16 additions & 16 deletions planetary_system_stacker/alignment_point_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from sys import argv, exit
from time import time

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtGui import QUndoCommand
from numpy import uint8

from align_frames import AlignFrames
Expand Down Expand Up @@ -89,7 +90,7 @@ def mousePressEvent(self, event):
y = int(pos.y())

# The left button is pressed.
if event.button() == QtCore.Qt.LeftButton:
if event.button() == QtCore.Qt.MouseButton.LeftButton:
self.left_button_pressed = True

# Find the closest AP.
Expand All @@ -112,7 +113,7 @@ def mousePressEvent(self, event):
self.new_ap = True

# The right button is pressed.
elif event.button() == QtCore.Qt.RightButton:
elif event.button() == QtCore.Qt.MouseButton.RightButton:
self.right_button_pressed = True

# Remember the location and initialize an object which during mouse moving stores
Expand All @@ -135,7 +136,7 @@ def mouseReleaseEvent(self, event):
y = int(pos.y())

# The left button is released.
if event.button() == QtCore.Qt.LeftButton:
if event.button() == QtCore.Qt.MouseButton.LeftButton:
self.left_button_pressed = False

# An existing AP was moved, replace it with the moved one.
Expand All @@ -151,7 +152,7 @@ def mouseReleaseEvent(self, event):
self.new_ap = False

# The right button is released.
elif event.button() == QtCore.Qt.RightButton:
elif event.button() == QtCore.Qt.MouseButton.RightButton:
self.right_button_pressed = False

# If the mouse was not moved much between press and release, a single AP is deleted.
Expand Down Expand Up @@ -244,9 +245,9 @@ def keyPressEvent(self, event):

# This is a workaround: Instead of "93" it should read "QtCore.Qt.Key_Plus", but that
# returns 43 instead.
if event.key() == 93 and event.modifiers() & QtCore.Qt.ControlModifier:
if event.key() == 93 and event.modifiers() & QtCore.Qt.KeyModifier.ControlModifier:
self.change_ap_size(1)
elif event.key() == QtCore.Qt.Key_Minus and event.modifiers() & QtCore.Qt.ControlModifier:
elif event.key() == QtCore.Qt.Key.Key_Minus and event.modifiers() & QtCore.Qt.KeyModifier.ControlModifier:
self.change_ap_size(-1)

def change_ap_size(self, direction):
Expand Down Expand Up @@ -300,7 +301,7 @@ def __init__(self, ap):
self.patch_x_low = ap["patch_x_low"]
self.patch_x_high = ap["patch_x_high"]
self.pen_boundary = QtGui.QPen(self.color_boundary)
self.pen_boundary.setStyle(0)
self.pen_boundary.setStyle(QtCore.Qt.PenStyle.SolidLine)
self.width_x = self.patch_x_high - self.patch_x_low
self.width_x_external = self.width_x + self.pen_boundary.width()
self.width_y = self.patch_y_high - self.patch_y_low
Expand Down Expand Up @@ -372,7 +373,7 @@ def __init__(self, image, alignment_points):
self.image = image

# Initialize the undo stack.
self.undoStack = QtWidgets.QUndoStack(self)
self.undoStack = QtGui.QUndoStack(self)

# Initialize the alignment point object.
self.aps = alignment_points
Expand Down Expand Up @@ -402,9 +403,9 @@ def keyPressEvent(self, event):
"""

# If the control key is pressed, switch to "no drag mode".
if event.key() == QtCore.Qt.Key_Z and event.modifiers() & QtCore.Qt.ControlModifier:
if event.key() == QtCore.Qt.Key.Key_Z and event.modifiers() & QtCore.Qt.KeyModifier.ControlModifier:
self.undoStack.undo()
elif event.key() == QtCore.Qt.Key_Y and event.modifiers() & QtCore.Qt.ControlModifier:
elif event.key() == QtCore.Qt.Key.Key_Y and event.modifiers() & QtCore.Qt.KeyModifier.ControlModifier:
self.undoStack.redo()
else:
super(AlignmentPointEditor, self).keyPressEvent(event)
Expand Down Expand Up @@ -454,7 +455,7 @@ def replace_alignment_point(self, ap_old, ap_new):
self.undoStack.push(command)


class CommandCreateApGrid(QtWidgets.QUndoCommand):
class CommandCreateApGrid(QUndoCommand):
"""
Undoable command to replace all existing APs with a new AP grid.
"""
Expand Down Expand Up @@ -499,7 +500,7 @@ def undo(self):
self.photo_editor.setFocus()


class CommandAdd(QtWidgets.QUndoCommand):
class CommandAdd(QUndoCommand):
"""
Undoable command to add an AP to the AP list.
"""
Expand All @@ -523,7 +524,7 @@ def undo(self):
self.photo_editor.setFocus()


class CommandRemove(QtWidgets.QUndoCommand):
class CommandRemove(QUndoCommand):
"""
Undoable command to remove an AP from the AP list.
"""
Expand All @@ -548,7 +549,7 @@ def undo(self):
self.photo_editor.setFocus()


class CommandReplace(QtWidgets.QUndoCommand):
class CommandReplace(QUndoCommand):
"""
Undoable command to replace an AP on the AP list with another one.
"""
Expand Down Expand Up @@ -821,4 +822,3 @@ def done(self):
AlignmentPoints.set_reference_box(ap, align_frames.mean_frame)
print("Buffers allocated for " + str(count_updates) + " alignment points.")
exit()

Loading