Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:45:43+00:00 2026-06-14T06:45:43+00:00

In Python 2, with what’s installed in my machine (Ubuntu 12.10), I can do

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:45:45+00:00Added an answer on June 14, 2026 at 6:45 am

    You aren’t just dealing with Python 2 and Python 3 — in fact that is irrelevant in this case. What does matter is that the first example is using PyGTK which is GTK2 and the second is using PyGObject which is GTK3.

    Since GTK3 is using gobject introspection with Python, some of the magic that was manually maintained in PyGTK is not there. If you look at the C API for the Clipboard you will see that Gtk.Clipboard.get() has a required argument to identify the clipboard. This is explained in the reference for gtk_clipboard_get_for_display().

    To make a long story short, the correct code in GTK3 is more like this:

    from gi.repository import Gtk, Gdk
    cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    content = cb.wait_for_text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python noobie here. I can get in to work as normal when I use
Python beginner here. I have a text file that is sorted into columns: fields
Python allows aliasing of imports, through ...as <ALIAS> clauses in the import statement, like
Python does not print traceback messages from exceptions raised in daemon threads. For example,
Python allows to call a static method not only from a class, but also
Python's arbitrary precision decimals are lovely, but I can't seem to find a way
Python is pretty clean, and I can code neat apps quickly. But I notice
Python: How to get the caller's method name in the called method? Assume I
Python is installed in a directory all users have full access to, but when
Python 2 and 3, are the bytecode (pyo & pyc) backward compatible? can i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.