Ubuntu – Facing problem with “gtk.RESPONSE_OK” in the simple-player quickly tutorial


I am fairly new to both quickly and Python. I am facing several problems while learning to use quickly from the following tutorial on the Ubuntu developers site:

The following error I'm unable to understand:

Traceback (most recent call last):
  File "/home/sumit/Sumit/simple-player/simple_player/SimplePlayerWindow.py", line 36, in on_openbutton_clicked
    if response==gtk.RESPONSE_OK:
NameError: global name 'gtk' is not defined

I realize that I am supposed to import something, so I tried to add import gtk which it didn't work and it gave the following error:

  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk

I have followed every step of the tutorials so far. But there is no mention of any other imports other that "prompts" and "os". Please help.

Contribution of Agmenor, facing the same problem:

I also tried to replace the text if response == gtk.RESPONSE_OK: by if response == Gtk.RESPONSE_OK: (notice the capital G). This gives another error:

AttributeError: 'gi.repository.Gtk' object has no attribute 'RESPONSE_OK'

Best Answer

  • The current quickly toolkit on 12.04 uses Gtk from gi.repository not the older gtk.
    The tutorial has not been updated for this change.

    This may be a/your sticking point.

    Output cat SimplePlayerWindow.py

    from gi.repository import Gtk # pylint: disable=E0611
    import logging
    logger = logging.getLogger('simple_player')


  • Related Question