Python and gtk3 onChange clipboard

With PyGTK 2, I could add a function that will execute when the contents of the clipboard change. View Python GTK3 Communications Documentation I cannot find any description of this functionality.

Can someone tell me โ€œbest practiceโ€ for this?

EDIT

Gtk2 does the following work:

import gtk def test(*args): print "Clipboard changed" clip = gtk.Clipboard() clip.connect('owner-change',test) 

When upgrading to Gtk3

 from gi.repository import Gtk, Gdk def test(*args): print "Clipboard changed" clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clip.Connect('owner-change',test) 

Python accepts a connection to a signal, but my function is never executed.

+6
source share
1 answer
 from gi.repository import Gtk, Gdk def test(*args): print "Clipboard changed" clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clip.connect('owner-change',test) Gtk.main() 

works for me.

+2
source

All Articles