Update clipboard Qt-bindings for flexiblity and Python3 compatibility… · pandas-dev/pandas@412988e (original) (raw)
`@@ -18,7 +18,8 @@
`
18
18
`On Linux, install xclip or xsel via package manager. For example, in Debian:
`
19
19
`sudo apt-get install xclip
`
20
20
``
21
``
`-
Otherwise on Linux, you will need the gtk or PyQt4 modules installed.
`
``
21
`+
Otherwise on Linux, you will need the gtk, qtpy or PyQt modules installed.
`
``
22
`+
qtpy also requires a python-qt-bindings module: PyQt4, PyQt5, PySide, PySide2
`
22
23
``
23
24
`gtk and PyQt4 modules are not available for Python 3,
`
24
25
`and this module does not work with PyGObject yet.
`
`@@ -34,9 +35,9 @@
`
34
35
`init_klipper_clipboard, init_no_clipboard)
`
35
36
`from .windows import init_windows_clipboard
`
36
37
``
37
``
`` -
import PyQt4
sys.exit()s if DISPLAY is not in the environment.
``
``
38
`` +
import qtpy
sys.exit()s if DISPLAY is not in the environment.
``
38
39
`# Thus, we need to detect the presence of $DISPLAY manually
`
39
``
`-
and not load PyQt4 if it is absent.
`
``
40
`+
and not load qtpy if it is absent.
`
40
41
`HAS_DISPLAY = os.getenv("DISPLAY", False)
`
41
42
`CHECK_CMD = "where" if platform.system() == "Windows" else "which"
`
42
43
``
`@@ -68,9 +69,23 @@ def determine_clipboard():
`
68
69
`return init_gtk_clipboard()
`
69
70
``
70
71
`try:
`
71
``
`-
Check if PyQt4 is installed
`
72
``
`-
import PyQt4 # noqa
`
``
72
`+
qtpy is a small abstraction layer that lets you write
`
``
73
`+
applications using a single api call to either PyQt or PySide
`
``
74
`+
https://pypi.python.org/pypi/QtPy
`
``
75
`+
import qtpy # noqa
`
73
76
`except ImportError:
`
``
77
`+
If qtpy isn't installed, fall back on importing PyQt5, or PyQt5
`
``
78
`+
try:
`
``
79
`+
import PyQt5 # noqa
`
``
80
`+
except ImportError:
`
``
81
`+
try:
`
``
82
`+
import PyQt4 # noqa
`
``
83
`+
except ImportError:
`
``
84
`+
pass # fail fast for all non-ImportError exceptions.
`
``
85
`+
else:
`
``
86
`+
return init_qt_clipboard()
`
``
87
`+
else:
`
``
88
`+
return init_qt_clipboard()
`
74
89
`pass
`
75
90
`else:
`
76
91
`return init_qt_clipboard()
`