A
A
Alexander Karpov2016-10-14 16:32:02
linux
Alexander Karpov, 2016-10-14 16:32:02

Why can't I get data from the clipboard in linux?

I can't get the contents of the PRIMARY buffer, I do something like this:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
cb = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
print(cb)

But nothing comes out. I am getting an error:
<Gtk.Clipboard object at 0x7ff6031c1d38 (GtkClipboard at 0x27541b0)>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Karpov, 2016-10-14
@Inkognitoss

Ready. Understood. Sorry to bother you.
Works like this:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk

clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)
original = clipboard.wait_for_text()
print(original)

I had to drink half a bottle of cider and read the code here https://python-gtk-3-tutorial.readthedocs.io/en/la...

H
hatiko, 2016-10-14
@hatiko

Do you have bare (server) Linux? Is the clipboard daemon running (the desktop version already has everything)?
Do third party apps see the clipboard? For example, https://wiki.archlinux.org/index.php/clipboard
May help https://habrahabr.ru/post/48954/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question