Show More
@@ -59,21 +59,21 b' def set_qt_api(gui):' | |||||
59 | loaded = loaded_api() |
|
59 | loaded = loaded_api() | |
60 |
|
60 | |||
61 | qt_env2gui = { |
|
61 | qt_env2gui = { | |
62 |
QT_API_PYSIDE: |
|
62 | QT_API_PYSIDE: "qt4", | |
63 |
QT_API_PYQTv1: |
|
63 | QT_API_PYQTv1: "qt4", | |
64 |
QT_API_PYQT: |
|
64 | QT_API_PYQT: "qt4", | |
65 |
QT_API_PYSIDE2: |
|
65 | QT_API_PYSIDE2: "qt5", | |
66 |
QT_API_PYQT5: |
|
66 | QT_API_PYQT5: "qt5", | |
67 |
QT_API_PYSIDE6: |
|
67 | QT_API_PYSIDE6: "qt6", | |
68 |
QT_API_PYQT6: |
|
68 | QT_API_PYQT6: "qt6", | |
69 | } |
|
69 | } | |
70 |
if loaded is not None and gui != |
|
70 | if loaded is not None and gui != "qt": | |
71 | if qt_env2gui[loaded] != gui: |
|
71 | if qt_env2gui[loaded] != gui: | |
72 | raise ImportError( |
|
72 | raise ImportError( | |
73 |
f |
|
73 | f"Cannot switch Qt versions for this session; must use {qt_env2gui[loaded]}." | |
74 | ) |
|
74 | ) | |
75 |
|
75 | |||
76 |
if qt_api is not None and gui != |
|
76 | if qt_api is not None and gui != "qt": | |
77 | if qt_env2gui[qt_api] != gui: |
|
77 | if qt_env2gui[qt_api] != gui: | |
78 | print( |
|
78 | print( | |
79 | f'Request for "{gui}" will be ignored because `QT_API` ' |
|
79 | f'Request for "{gui}" will be ignored because `QT_API` ' |
@@ -12,14 +12,14 b' guis_avail = []' | |||||
12 | def _get_qt_vers(): |
|
12 | def _get_qt_vers(): | |
13 | """If any version of Qt is available, this will populate `guis_avail` with 'qt' and 'qtx'. Due |
|
13 | """If any version of Qt is available, this will populate `guis_avail` with 'qt' and 'qtx'. Due | |
14 | to the import mechanism, we can't import multiple versions of Qt in one session.""" |
|
14 | to the import mechanism, we can't import multiple versions of Qt in one session.""" | |
15 |
for gui in [ |
|
15 | for gui in ["qt", "qt6", "qt5", "qt4"]: | |
16 |
print(f |
|
16 | print(f"Trying {gui}") | |
17 | try: |
|
17 | try: | |
18 | set_qt_api(gui) |
|
18 | set_qt_api(gui) | |
19 | importlib.import_module("IPython.terminal.pt_inputhooks.qt") |
|
19 | importlib.import_module("IPython.terminal.pt_inputhooks.qt") | |
20 | guis_avail.append(gui) |
|
20 | guis_avail.append(gui) | |
21 |
if |
|
21 | if "QT_API" in os.environ.keys(): | |
22 |
del os.environ[ |
|
22 | del os.environ["QT_API"] | |
23 | except ImportError: |
|
23 | except ImportError: | |
24 | pass # that version of Qt isn't available. |
|
24 | pass # that version of Qt isn't available. | |
25 | except RuntimeError: |
|
25 | except RuntimeError: | |
@@ -29,7 +29,9 b' def _get_qt_vers():' | |||||
29 | _get_qt_vers() |
|
29 | _get_qt_vers() | |
30 |
|
30 | |||
31 |
|
31 | |||
32 | @pytest.mark.skipif(len(guis_avail) == 0, reason='No viable version of PyQt or PySide installed.') |
|
32 | @pytest.mark.skipif( | |
|
33 | len(guis_avail) == 0, reason="No viable version of PyQt or PySide installed." | |||
|
34 | ) | |||
33 | def test_inputhook_qt(): |
|
35 | def test_inputhook_qt(): | |
34 | gui = guis_avail[0] |
|
36 | gui = guis_avail[0] | |
35 |
|
37 | |||
@@ -37,7 +39,7 b' def test_inputhook_qt():' | |||||
37 | get_inputhook_name_and_func(gui) |
|
39 | get_inputhook_name_and_func(gui) | |
38 |
|
40 | |||
39 | # ...and now we're stuck with this version of Qt for good; can't switch. |
|
41 | # ...and now we're stuck with this version of Qt for good; can't switch. | |
40 |
for not_gui in [ |
|
42 | for not_gui in ["qt6", "qt5", "qt4"]: | |
41 | if not_gui not in guis_avail: |
|
43 | if not_gui not in guis_avail: | |
42 | break |
|
44 | break | |
43 |
|
45 | |||
@@ -45,4 +47,4 b' def test_inputhook_qt():' | |||||
45 | get_inputhook_name_and_func(not_gui) |
|
47 | get_inputhook_name_and_func(not_gui) | |
46 |
|
48 | |||
47 | # A gui of 'qt' means "best available", or in this case, the last one that was used. |
|
49 | # A gui of 'qt' means "best available", or in this case, the last one that was used. | |
48 |
get_inputhook_name_and_func( |
|
50 | get_inputhook_name_and_func("qt") |
General Comments 0
You need to be logged in to leave comments.
Login now