Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98d6a30

Browse files
authored
Merge pull request #21142 from tacaswell/mac_qt_ctrl
Mac qt ctrl
2 parents d9cbcae + 2b3c39f commit 98d6a30

File tree

2 files changed

+57
-42
lines changed

2 files changed

+57
-42
lines changed

.github/workflows/tests.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,37 +171,38 @@ jobs:
171171
# (sometimes, the install appears to be successful but shared
172172
# libraries cannot be loaded at runtime, so an actual import is a
173173
# better check).
174-
if [[ "${{ runner.os }}" != 'macOS' ]]; then
175-
# PyGObject, pycairo, and cariocffi do not install on OSX 10.12.
176-
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
177-
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
178-
echo 'PyGObject is available' ||
179-
echo 'PyGObject is not available'
174+
# PyGObject, pycairo, and cariocffi do not install on OSX 10.12.
175+
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
176+
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
177+
echo 'PyGObject is available' ||
178+
echo 'PyGObject is not available'
180179
181-
# There are no functioning wheels available for OSX 10.12 (as of
182-
# Sept 2020) for either pyqt5 (there are only wheels for 10.13+) or
183-
# pyside2 (the latest version (5.13.2) with 10.12 wheels has a
184-
# fatal to us bug, it was fixed in 5.14.0 which has 10.13 wheels)
185-
python -mpip install --upgrade pyqt5${{ matrix.pyqt5-ver }} &&
186-
python -c 'import PyQt5.QtCore' &&
187-
echo 'PyQt5 is available' ||
188-
echo 'PyQt5 is not available'
180+
# There are no functioning wheels available for OSX 10.12 (as of
181+
# Sept 2020) for either pyqt5 (there are only wheels for 10.13+) or
182+
# pyside2 (the latest version (5.13.2) with 10.12 wheels has a
183+
# fatal to us bug, it was fixed in 5.14.0 which has 10.13 wheels)
184+
python -mpip install --upgrade pyqt5${{ matrix.pyqt5-ver }} &&
185+
python -c 'import PyQt5.QtCore' &&
186+
echo 'PyQt5 is available' ||
187+
echo 'PyQt5 is not available'
188+
if [[ "${{ runner.os }}" != 'macOS' ]]; then
189189
python -mpip install --upgrade pyside2 &&
190190
python -c 'import PySide2.QtCore' &&
191191
echo 'PySide2 is available' ||
192192
echo 'PySide2 is not available'
193-
# Qt6 crashes on Github's ubuntu 18.04 runner.
194-
if [[ "${{ matrix.os }}" = ubuntu-20.04 ]]; then
195-
python -mpip install --upgrade pyqt6 &&
196-
python -c 'import PyQt6.QtCore' &&
197-
echo 'PyQt6 is available' ||
198-
echo 'PyQt6 is not available'
199-
python -mpip install --upgrade pyside6 &&
200-
python -c 'import PySide6.QtCore' &&
201-
echo 'PySide6 is available' ||
202-
echo 'PySide6 is not available'
203-
fi
204193
fi
194+
# Qt6 crashes on Github's ubuntu 18.04 runner.
195+
if [[ "${{ matrix.os }}" = ubuntu-20.04 ]]; then
196+
python -mpip install --upgrade pyqt6 &&
197+
python -c 'import PyQt6.QtCore' &&
198+
echo 'PyQt6 is available' ||
199+
echo 'PyQt6 is not available'
200+
python -mpip install --upgrade pyside6 &&
201+
python -c 'import PySide6.QtCore' &&
202+
echo 'PySide6 is available' ||
203+
echo 'PySide6 is not available'
204+
fi
205+
205206
python -mpip install --upgrade \
206207
-f "https://extras.wxpython.org/wxPython4/extras/linux/gtk3/${{ matrix.os }}" \
207208
wxPython &&

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def test_other_signal_before_sigint(qt_core, platform_simulate_ctrl_c,
9393
def custom_sigpipe_handler(signum, frame):
9494
nonlocal sigcld_caught
9595
sigcld_caught = True
96-
signal.signal(signal.SIGCLD, custom_sigpipe_handler)
96+
signal.signal(signal.SIGCHLD, custom_sigpipe_handler)
9797

9898
def fire_other_signal():
99-
os.kill(os.getpid(), signal.SIGCLD)
99+
os.kill(os.getpid(), signal.SIGCHLD)
100100

101101
def fire_sigint():
102102
platform_simulate_ctrl_c()
@@ -166,24 +166,33 @@ def custom_handler(signum, frame):
166166

167167

168168
@pytest.mark.parametrize(
169-
'qt_key, qt_mods, answer',
169+
"qt_key, qt_mods, answer",
170170
[
171-
('Key_A', ['ShiftModifier'], 'A'),
172-
('Key_A', [], 'a'),
173-
('Key_A', ['ControlModifier'], 'ctrl+a'),
174-
('Key_Aacute', ['ShiftModifier'],
175-
'\N{LATIN CAPITAL LETTER A WITH ACUTE}'),
176-
('Key_Aacute', [],
177-
'\N{LATIN SMALL LETTER A WITH ACUTE}'),
178-
('Key_Control', ['AltModifier'], 'alt+control'),
179-
('Key_Alt', ['ControlModifier'], 'ctrl+alt'),
180-
('Key_Aacute', ['ControlModifier', 'AltModifier', 'MetaModifier'],
181-
'ctrl+alt+meta+\N{LATIN SMALL LETTER A WITH ACUTE}'),
171+
("Key_A", ["ShiftModifier"], "A"),
172+
("Key_A", [], "a"),
173+
("Key_A", ["ControlModifier"], ("ctrl+a")),
174+
(
175+
"Key_Aacute",
176+
["ShiftModifier"],
177+
"\N{LATIN CAPITAL LETTER A WITH ACUTE}",
178+
),
179+
("Key_Aacute", [], "\N{LATIN SMALL LETTER A WITH ACUTE}"),
180+
("Key_Control", ["AltModifier"], ("alt+control")),
181+
("Key_Alt", ["ControlModifier"], "ctrl+alt"),
182+
(
183+
"Key_Aacute",
184+
["ControlModifier", "AltModifier", "MetaModifier"],
185+
("ctrl+alt+meta+\N{LATIN SMALL LETTER A WITH ACUTE}"),
186+
),
182187
# We do not currently map the media keys, this may change in the
183188
# future. This means the callback will never fire
184-
('Key_Play', [], None),
185-
('Key_Backspace', [], 'backspace'),
186-
('Key_Backspace', ['ControlModifier'], 'ctrl+backspace'),
189+
("Key_Play", [], None),
190+
("Key_Backspace", [], "backspace"),
191+
(
192+
"Key_Backspace",
193+
["ControlModifier"],
194+
"ctrl+backspace",
195+
),
187196
],
188197
ids=[
189198
'shift',
@@ -216,6 +225,11 @@ def test_correct_key(backend, qt_core, qt_key, qt_mods, answer):
216225
Assert sent and caught keys are the same.
217226
"""
218227
from matplotlib.backends.qt_compat import _enum, _to_int
228+
229+
if sys.platform == "darwin" and answer is not None:
230+
answer = answer.replace("ctrl", "cmd")
231+
answer = answer.replace("control", "cmd")
232+
answer = answer.replace("meta", "ctrl")
219233
result = None
220234
qt_mod = _enum("QtCore.Qt.KeyboardModifier").NoModifier
221235
for mod in qt_mods:

0 commit comments

Comments
 (0)