Skip to content

Commit

Permalink
Move to GTK+ version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Bryant committed Nov 20, 2017
1 parent 2f11f63 commit 46076e7
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pyperclip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
sudo apt-get install xclip
sudo apt-get install xsel
Otherwise on Linux, you will need the gtk or PyQt5/PyQt4 modules installed.
Otherwise on Linux, you will need the gi or PyQt5/PyQt4 modules installed.
gtk and PyQt4 modules are not available for Python 3,
PyQt4 modules are not available for Python 3,
and this module does not work with PyGObject yet.
Note: There seem sto be a way to get gtk on Python 3, according to:
https://askubuntu.com/questions/697397/python3-is-not-supporting-gtk-module
Cygwin is currently not supported.
Security Note: This module runs programs with these names:
Expand Down Expand Up @@ -130,17 +127,17 @@ def paste_osx_pyobjc():


def init_gtk_clipboard():
global gtk
import gtk
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

def copy_gtk(text):
global cb
cb = gtk.Clipboard()
cb.set_text(text)
cb.set_text(text, -1)
cb.store()

def paste_gtk():
clipboardContents = gtk.Clipboard().wait_for_text()
clipboardContents = cb.wait_for_text()
# for python 2, returns None if the clipboard is blank.
if clipboardContents is None:
return ''
Expand Down Expand Up @@ -481,7 +478,7 @@ def determine_clipboard():
# Setup for the LINUX platform:
if HAS_DISPLAY:
try:
import gtk # check if gtk is installed
import gi # check if gi is installed
except ImportError:
pass # We want to fail fast for all non-ImportError exceptions.
else:
Expand Down

0 comments on commit 46076e7

Please sign in to comment.