Get The Primary Buffer Content Using GTK and Python

That is it, just the three following lines:


import gtk
clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
print clipboard.wait_for_text()

More information about what are the interned strings and objects from gtk.gdk.Atom, it is here. Another interesting script in Python that deals with primary buffer is this one made to monitor the primary buffer. Another one is made to copy from the clipboard itself, it is here. Another one is a complete example how to make a textbox with Copy, Cut, and Paste features using PyGTK.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: