In Python 2, with what's installed in my machine (Ubuntu 12.10), I can do
import gtk
cb = gtk.clipboard_get()
content = cb.wait_for_text()
to get the text from the clipboard.
In Python3, however, I was supposed to do the same with the Gtk.Clipboard() object, but I get thrown some errors that seem to be related to widgets and things like that, but my application has no GUI and is not supposed to. Am I on the right track?
>>> from gi.repository import Gtk
>>> cb = Gtk.Clipboard()
>>> content = cb.wait_for_text()
/usr/lib/python3/dist-packages/gi/types.py:47: Warning: g_object_get_data: assertion `G_IS_OBJECT (object)' failed
return info.invoke(*args, **kwargs)
(.:10935): Gdk-CRITICAL **: gdk_display_get_default_screen: assertion `GDK_IS_DISPLAY (display)' failed
(.:10935): Gtk-CRITICAL **: gtk_invisible_new_for_screen: assertion `GDK_IS_SCREEN (screen)' failed
/usr/lib/python3/dist-packages/gi/types.py:47: Warning: invalid (NULL) pointer instance
return info.invoke(*args, **kwargs)
/usr/lib/python3/dist-packages/gi/types.py:47: Warning: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
return info.invoke(*args, **kwargs)
(.:10935): Gtk-CRITICAL **: gtk_widget_add_events: assertion `GTK_IS_WIDGET (widget)' failed
/usr/lib/python3/dist-packages/gi/types.py:47: Warning: g_object_set_data: assertion `G_IS_OBJECT (object)' failed
return info.invoke(*args, **kwargs)
/usr/lib/python3/dist-packages/gi/types.py:47: Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed
return info.invoke(*args, **kwargs)
(.:10935): Gdk-CRITICAL **: gdk_display_get_default_screen: assertion `GDK_IS_DISPLAY (display)' failed
(.:10935): Gtk-CRITICAL **: gtk_invisible_new_for_screen: assertion `GDK_IS_SCREEN (screen)' failed
(.:10935): Gtk-CRITICAL **: gtk_widget_add_events: assertion `GTK_IS_WIDGET (widget)' failed
(.:10935): Gtk-CRITICAL **: gtk_widget_get_window: assertion `GTK_IS_WIDGET (widget)' failed
(.:10935): Gtk-CRITICAL **: gtk_selection_convert: assertion `GTK_IS_WIDGET (widget)' failed