GTK+ 3.0 Clipboard doesn't paste anything to my clipboard

时间:2016-08-31 18:10:04

标签: python tkinter gtk

I've been using this script for testing.

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
board = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
board.set_text("hello there", -1)
board.store()

It does erase anything I have in my clipboard, but it doesn't add "hello there". It just leaves empty my clipboard. It seems like other people who have used this script say that it works, so I'm not really sure about what could be causing this.

I've used this as my resource.

Edit: This also happens to me with tkinter, so I believe that it might not be exclusive to GTK. It's probably client-side.

Tkinter code I've used to test:

from tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append('i can has clipboardz?')
r.destroy()

1 个答案:

答案 0 :(得分:0)

我得到了它的工作,有点。看起来我已经能够在没有GTK抱怨的情况下导入xerox library,并且它有效。它仍然不是最好的解决方案,但至少它是一个解决方案。