Show More
@@ -3,14 +3,36 b' import os' | |||
|
3 | 3 | |
|
4 | 4 | aliases = { |
|
5 | 5 | 'qt4': 'qt', |
|
6 | 'gtk2': 'gtk', | |
|
6 | 7 | } |
|
7 | 8 | |
|
9 | backends = [ | |
|
10 | 'qt', 'qt4', 'qt5', | |
|
11 | 'gtk', 'gtk2', 'gtk3', | |
|
12 | 'tk', | |
|
13 | 'wx', | |
|
14 | 'pyglet', 'glut', | |
|
15 | ] | |
|
16 | ||
|
17 | class UnknownBackend(KeyError): | |
|
18 | def __init__(self, name): | |
|
19 | self.name = name | |
|
20 | ||
|
21 | def __str__(self): | |
|
22 | return ("No event loop integration for {!r}. " | |
|
23 | "Supported event loops are: {}").format(self.name, | |
|
24 | ', '.join(backends)) | |
|
25 | ||
|
8 | 26 | def get_inputhook_func(gui): |
|
27 | if gui not in backends: | |
|
28 | raise UnknownBackend(gui) | |
|
29 | ||
|
9 | 30 | if gui in aliases: |
|
10 | 31 | return get_inputhook_func(aliases[gui]) |
|
11 | 32 | |
|
12 | 33 | if gui == 'qt5': |
|
13 | 34 | os.environ['QT_API'] = 'pyqt5' |
|
35 | gui = 'qt' | |
|
14 | 36 | |
|
15 | 37 | mod = importlib.import_module('IPython.terminal.pt_inputhooks.'+gui) |
|
16 | 38 | return mod.inputhook |
General Comments 0
You need to be logged in to leave comments.
Login now