Skip to content

Commit e67e4bd

Browse files
authored
Merge pull request #207 from python-cmd2/pygtk_bug
Added workaround for bug in Python 2 on Linux when pygtk is installed
2 parents 3a58cab + 2d4e698 commit e67e4bd

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cmd2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
import pyparsing
4747
import pyperclip
4848

49+
# On some systems, pyperclip will import gtk for its clipboard functionality.
50+
# The following code is a workaround for gtk interfering with printing from a background
51+
# thread while the CLI thread is blocking in raw_input() in Python 2 on Linux.
52+
try:
53+
# noinspection PyUnresolvedReferences
54+
import gtk
55+
gtk.set_interactive(0)
56+
except ImportError:
57+
pass
58+
4959
# next(it) gets next item of iterator it. This is a replacement for calling it.next() in Python 2 and next(it) in Py3
5060
from six import next
5161

0 commit comments

Comments
 (0)