Dump X clipboard data with GTK + or PyGTK

How to paste HTML data from clipboard X using PyGTK / GTK +?

I will need something like xclip , but with the ability to output clipboard data as HTML, and not just like plain text. I use PyGTK, but I'm not afraid of simple GTK + in C.

I read GtkClipboard and PyGTK gtk.Clipboard , and I found this question , but I need a small example to get started.

+3
source share
1 answer

Found. I used something like this:

clipboard = gtk.Clipboard()
target = "text/html"
clipboard.wait_for_contents(target)
clipboard.request_contents(target, dump_clipboard_callback)

And then the callback function can just retrieve the data:

def dump_clipboard_callback(clipboard, selection_data, data=None):
    print selection_data.data
+1

Source: https://habr.com/ru/post/1734663/


All Articles