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

MNT: Add support for QtPy #104

Merged
merged 43 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
db98b30
update
GuillaumeFavelier Apr 7, 2022
286434b
update
GuillaumeFavelier Apr 8, 2022
cc5fd4b
FIX: Working on Qt5
larsoner Apr 8, 2022
fd4f6b3
FIX: Simplify
larsoner Apr 8, 2022
02d4484
Merge remote-tracking branch 'upstream/main' into mnt/qtpy
larsoner Apr 8, 2022
b2b7eca
FIX: Names
larsoner Apr 8, 2022
522b54c
FIX: EGL
larsoner Apr 8, 2022
8814d0a
FIX: Install
larsoner Apr 8, 2022
2b9ac54
FIX: Avoid warning
larsoner Apr 8, 2022
a517b7d
Merge remote-tracking branch 'upstream/main' into mnt/qtpy
larsoner Apr 9, 2022
29762a1
Merge remote-tracking branch 'upstream/main' into mnt/qtpy
larsoner Apr 9, 2022
3bcb721
Merge remote-tracking branch 'upstream/main' into mnt/qtpy
larsoner Apr 9, 2022
7e4b58a
WIP: With no ABC
larsoner Apr 9, 2022
c625486
FIX: 3.10
larsoner Apr 9, 2022
c69231f
FIX: Add failing case
larsoner Apr 9, 2022
381feaf
FIX: Name
larsoner Apr 9, 2022
2fc8735
FIX: Inform
larsoner Apr 9, 2022
8490215
FIX: Later
larsoner Apr 9, 2022
5262d57
FIX: Use sibling
larsoner Apr 9, 2022
0c2695d
FIX: Missed
larsoner Apr 9, 2022
af99b2d
FIX: Just change MRO
larsoner Apr 9, 2022
440058d
FIX: Branch
larsoner Apr 9, 2022
9c2096b
STY: Flake
larsoner Apr 9, 2022
edc4c8e
FIX: Env
larsoner Apr 9, 2022
f3b377d
FIX: Keep ref for PySide6
larsoner Apr 9, 2022
18c2e34
FIX: PySide6
larsoner Apr 9, 2022
69a003f
FIX: Incl
larsoner Apr 9, 2022
43b78eb
FIX: Whoops
larsoner Apr 9, 2022
ce61b28
FIX: Test
larsoner Apr 9, 2022
905777c
FIX: Not kwarg
larsoner Apr 9, 2022
46e1f0d
FIX: Cast
larsoner Apr 9, 2022
7ab5f53
FIX: MEP
larsoner Apr 9, 2022
4977a87
FIX: Touch
larsoner Apr 9, 2022
5bae739
FIX: PySide6
larsoner Apr 9, 2022
67c8757
FIX: Simplify
larsoner Apr 9, 2022
0b00cca
FIX: Try
larsoner Apr 9, 2022
51a0107
TST: Wait ages
larsoner Apr 9, 2022
70aa717
FIX: Remove
larsoner Apr 9, 2022
23f84d2
FIX: Revert
larsoner Apr 9, 2022
a3a4ddc
FIX: Missed
larsoner Apr 9, 2022
a8f4a0a
TST: Test rebased MNE-Python PR
larsoner Apr 10, 2022
79272b8
TST: Ping again
larsoner Apr 10, 2022
f7d6276
MNT: Restore branch
larsoner Apr 11, 2022
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
75 changes: 38 additions & 37 deletions mne_qt_browser/_pg_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
from os.path import getsize

import numpy as np
from PyQt5.QtCore import (QEvent, QThread, Qt, pyqtSignal, QRectF, QLineF,
QPoint, QSettings)
from PyQt5.QtGui import (QFont, QIcon, QPixmap, QTransform,
QMouseEvent, QImage, QPainter, QPainterPath)
from PyQt5.QtTest import QTest
from PyQt5.QtWidgets import (QAction, QColorDialog, QComboBox, QDialog,
QDockWidget, QDoubleSpinBox, QFormLayout,
QGridLayout, QHBoxLayout, QInputDialog,
QLabel, QMainWindow, QMessageBox, QToolButton,
QPushButton, QScrollBar, QWidget, QMenu,
QStyleOptionSlider, QStyle, QActionGroup,
QApplication, QGraphicsView, QProgressBar,
QVBoxLayout, QLineEdit, QCheckBox, QScrollArea,
QGraphicsLineItem, QGraphicsScene, QTextEdit,
QSizePolicy, QSpinBox, QDesktopWidget, QSlider,
QWidgetAction, QRadioButton)
from qtpy.QtCore import (QEvent, QThread, Qt, Signal, QRectF, QLineF,
larsoner marked this conversation as resolved.
Show resolved Hide resolved
QPointF, QSettings)
from qtpy.QtGui import (QFont, QIcon, QPixmap, QTransform,
QMouseEvent, QImage, QPainter, QPainterPath)
from qtpy.QtTest import QTest
from qtpy.QtWidgets import (QAction, QColorDialog, QComboBox, QDialog,
QDockWidget, QDoubleSpinBox, QFormLayout,
QGridLayout, QHBoxLayout, QInputDialog,
QLabel, QMainWindow, QMessageBox, QToolButton,
QPushButton, QScrollBar, QWidget, QMenu,
QStyleOptionSlider, QStyle, QActionGroup,
QApplication, QGraphicsView, QProgressBar,
QVBoxLayout, QLineEdit, QCheckBox, QScrollArea,
QGraphicsLineItem, QGraphicsScene, QTextEdit,
QSizePolicy, QSpinBox, QSlider, QWidgetAction,
QRadioButton)
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
from matplotlib.colors import to_rgba_array
from pyqtgraph import (AxisItem, GraphicsView, InfLineLabel, InfiniteLine,
Expand Down Expand Up @@ -95,11 +95,11 @@ def _init_mne_qtapp(enable_icon=True, pg_app=False):

Returns
-------
app: ``PyQt5.QtWidgets.QApplication``
app: ``qtpy.QtWidgets.QApplication``
Instance of QApplication.
"""
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QIcon
from qtpy.QtWidgets import QApplication
from qtpy.QtGui import QIcon

app_name = 'MNE-Python'
organization_name = 'MNE'
Expand Down Expand Up @@ -799,7 +799,7 @@ def __init__(self, main):
self.bg_pxmp = None
self.bg_pxmp_item = None
# Set minimum Size to 1/10 of display size
min_h = int(QApplication.desktop().screenGeometry().height() / 10)
min_h = int(self.screen().geometry().height() / 10)
self.setMinimumSize(1, 1)
self.setFixedHeight(min_h)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
Expand Down Expand Up @@ -1086,9 +1086,9 @@ def resizeEvent(self, event):
"""Customize resize event."""
super().resizeEvent(event)
cnt_rect = self.contentsRect()
self.setSceneRect(QRectF(QPoint(0, 0),
QPoint(cnt_rect.width(),
cnt_rect.height())))
self.setSceneRect(QRectF(QPointF(0, 0),
QPointF(cnt_rect.width(),
cnt_rect.height())))
# Resize backgounrd
self._fit_bg_img()

Expand Down Expand Up @@ -1520,7 +1520,7 @@ def show(self, center=True):
if center:
# center dialog
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
cp = self.screen().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
self.activateWindow()
Expand Down Expand Up @@ -1789,7 +1789,7 @@ def __init__(self, main):
# Create widget
super().__init__(main, name='fig_selection',
title='Channel selection')
xpos = QApplication.desktop().screenGeometry().width() - 400
xpos = self.screen().geometry().width() - 400
self.setGeometry(xpos, 100, 400, 800)

layout = QVBoxLayout()
Expand Down Expand Up @@ -1956,9 +1956,9 @@ def closeEvent(self, event):
class AnnotRegion(LinearRegionItem):
"""Graphics-Oobject for Annotations."""

regionChangeFinished = pyqtSignal(object)
gotSelected = pyqtSignal(object)
removeRequested = pyqtSignal(object)
regionChangeFinished = Signal(object)
gotSelected = Signal(object)
removeRequested = Signal(object)

def __init__(self, mne, description, values):
super().__init__(values=values, orientation='vertical',
Expand Down Expand Up @@ -2490,9 +2490,9 @@ def mouseMoveEvent(self, ev):

class LoadThread(QThread):
"""A worker object for precomputing in a separate QThread."""
loadProgress = pyqtSignal(int)
processText = pyqtSignal(str)
loadingFinished = pyqtSignal()
loadProgress = Signal(int)
processText = Signal(str)
loadingFinished = Signal()

def __init__(self, browser):
super().__init__()
Expand Down Expand Up @@ -2610,7 +2610,7 @@ def _disconnect(sig):
class MNEQtBrowser(BrowserBase, QMainWindow, metaclass=_PGMetaClass):
"""A PyQtGraph-backend for 2D data browsing."""

gotClosed = pyqtSignal()
gotClosed = Signal()

def __init__(self, **kwargs):
self.backend_name = 'pyqtgraph'
Expand All @@ -2637,8 +2637,9 @@ def __init__(self, **kwargs):
QApplication.processEvents() # needs to happen for the theme to be set

# HiDPI stuff
desktop = QApplication.desktop()
dpi_ratio = desktop.physicalDpiY() / desktop.logicalDpiY()
desktop = self.screen()
dpi_ratio = \
desktop.physicalDotsPerInchY() / desktop.logicalDotsPerInchY()
logger.debug(f'Desktop DPI ratio: {dpi_ratio:0.3f}')

def _hidpi_mkPen(*args, **kwargs):
Expand Down Expand Up @@ -3890,10 +3891,10 @@ def _update_data(self):

def _get_zscore(self, data):
# Reshape data to reasonable size for display
if QApplication.desktop() is None:
if self.screen() is None:
max_pixel_width = 3840 # default=UHD
else:
max_pixel_width = QApplication.desktop().screenGeometry().width()
max_pixel_width = self.screen().geometry().width()
collapse_by = data.shape[1] // max_pixel_width
data = data[:, :max_pixel_width * collapse_by]
if collapse_by > 0:
Expand Down Expand Up @@ -4632,7 +4633,7 @@ def _setup_ipython(ipython=None):


def _qt_init_icons():
from PyQt5.QtGui import QIcon
from qtpy.QtGui import QIcon
icons_path = f"{Path(__file__).parent}/icons"
QIcon.setThemeSearchPaths([icons_path])
return icons_path
Expand Down
12 changes: 6 additions & 6 deletions mne_qt_browser/tests/test_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import numpy as np
import pytest
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication
from qtpy.QtCore import QTimer
from qtpy.QtWidgets import QApplication

import mne

Expand Down Expand Up @@ -174,8 +174,8 @@ def _check_epochs_version():
])
def test_scroll_speed_epochs_unicolor(raw_orig, benchmark_param, store,
pg_backend, request):
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication
from qtpy.QtCore import QTimer
from qtpy.QtWidgets import QApplication
_check_epochs_version()
_reinit_bm_values()

Expand Down Expand Up @@ -220,8 +220,8 @@ def test_scroll_speed_epochs_unicolor(raw_orig, benchmark_param, store,
])
def test_scroll_speed_epochs_multicolor(raw_orig, benchmark_param, store,
pg_backend, request):
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication
from qtpy.QtCore import QTimer
from qtpy.QtWidgets import QApplication
_check_epochs_version()
_reinit_bm_values()

Expand Down