Skip to content

Commit e359dd2

Browse files
Remove fixes for MNE < 1.0 (#236)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 184157a commit e359dd2

File tree

2 files changed

+5
-84
lines changed

2 files changed

+5
-84
lines changed

mne_qt_browser/_fixes.py

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,21 @@
11
# -*- coding: utf-8 -*-
2-
"""Backports for MNE versions (mostly)."""
2+
"""Backports for older installations."""
33

44
# Author: Martin Schulz <[email protected]>
55
#
66
# License: BSD-3-Clause
77

8-
import platform
9-
import sys
108
from contextlib import contextmanager
119

1210
from mne.utils import logger
1311

14-
###############################################################################
15-
# MNE 1.0+
16-
try:
17-
from mne.viz.backends._utils import _qt_raise_window
18-
except ImportError:
19-
20-
def _qt_raise_window(win):
21-
try:
22-
from matplotlib import rcParams
23-
24-
raise_window = rcParams["figure.raise_window"]
25-
except ImportError:
26-
raise_window = True
27-
if raise_window:
28-
win.activateWindow()
29-
win.raise_()
30-
31-
32-
try:
33-
from mne.viz.backends._utils import _init_mne_qtapp
34-
except ImportError:
35-
from mne.viz.backends._utils import _init_qt_resources
36-
37-
def _init_mne_qtapp(enable_icon=True, pg_app=False):
38-
"""Get QApplication-instance for MNE-Python.
39-
40-
Parameter
41-
---------
42-
enable_icon: bool
43-
If to set an MNE-icon for the app.
44-
pg_app: bool
45-
If to create the QApplication with pyqtgraph. For an until know
46-
undiscovered reason the pyqtgraph-browser won't show without
47-
mkQApp from pyqtgraph.
48-
49-
Returns
50-
-------
51-
app: ``qtpy.QtWidgets.QApplication``
52-
Instance of QApplication.
53-
"""
54-
from qtpy.QtGui import QIcon
55-
from qtpy.QtWidgets import QApplication
56-
57-
app_name = "MNE-Python"
58-
organization_name = "MNE"
59-
60-
# Fix from cbrnr/mnelab for app name in menu bar
61-
if sys.platform.startswith("darwin"):
62-
try:
63-
# set bundle name on macOS (app name shown in the menu bar)
64-
from Foundation import NSBundle
65-
66-
bundle = NSBundle.mainBundle()
67-
info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
68-
info["CFBundleName"] = app_name
69-
except ModuleNotFoundError:
70-
pass
71-
72-
if pg_app:
73-
from pyqtgraph import mkQApp
74-
75-
app = mkQApp(app_name)
76-
else:
77-
app = QApplication.instance() or QApplication(sys.argv or [app_name])
78-
app.setApplicationName(app_name)
79-
app.setOrganizationName(organization_name)
80-
81-
if enable_icon:
82-
# Set icon
83-
_init_qt_resources()
84-
kind = "bigsur-" if platform.mac_ver()[0] >= "10.16" else ""
85-
app.setWindowIcon(QIcon(f":/mne-{kind}icon.png"))
86-
87-
return app
88-
89-
90-
###############################################################################
9112
# pytestqt
9213
try:
9314
from pytestqt.exceptions import capture_exceptions
9415
except ImportError:
9516
logger.debug(
96-
"If pytest-qt is not installed, the errors from inside "
97-
"the Qt-loop will be occluded and it will be harder "
98-
"to trace back the cause."
17+
"If pytest-qt is not installed, errors from inside the event loop will be "
18+
"occluded and it will be harder to trace back the cause."
9919
)
10020

10121
@contextmanager

mne_qt_browser/_pg_figure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from mne.utils import _check_option, _to_rgb, get_config, logger, sizeof_fmt, warn
4444
from mne.viz import plot_sensors
4545
from mne.viz._figure import BrowserBase
46+
from mne.viz.backends._utils import _init_mne_qtapp, _qt_raise_window
4647
from mne.viz.utils import _figure_agg, _merge_annotations, _simplify_float
4748
from pyqtgraph import (
4849
AxisItem,
@@ -126,7 +127,7 @@
126127
from scipy.stats import zscore
127128

128129
from . import _browser_instances
129-
from ._fixes import _init_mne_qtapp, _qt_raise_window, capture_exceptions
130+
from ._fixes import capture_exceptions
130131

131132
name = "pyqtgraph"
132133

0 commit comments

Comments
 (0)