summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-08-15 16:53:54 -0700
committerGitHub <noreply@github.com>2017-08-15 16:53:54 -0700
commite67e4bd698dc99e83e181c8fd35e3029b8729879 (patch)
tree82d1f9db00cfff38c293ce65c72d2130463c3f33
parent3a58cab25b3ae57899cf317e7260aecdcfc11e62 (diff)
parent2d4e69871b6529686eb88bf28d6410204c660a87 (diff)
downloadcmd2-git-e67e4bd698dc99e83e181c8fd35e3029b8729879.tar.gz
Merge pull request #207 from python-cmd2/pygtk_bug
Added workaround for bug in Python 2 on Linux when pygtk is installed
-rwxr-xr-xcmd2.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd2.py b/cmd2.py
index c688be9d..09412ab5 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -46,6 +46,16 @@ from optparse import make_option
import pyparsing
import pyperclip
+# On some systems, pyperclip will import gtk for its clipboard functionality.
+# The following code is a workaround for gtk interfering with printing from a background
+# thread while the CLI thread is blocking in raw_input() in Python 2 on Linux.
+try:
+ # noinspection PyUnresolvedReferences
+ import gtk
+ gtk.set_interactive(0)
+except ImportError:
+ pass
+
# next(it) gets next item of iterator it. This is a replacement for calling it.next() in Python 2 and next(it) in Py3
from six import next