Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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: http://developer.ubuntu.com/resources/app-developer-cookbook/multimedia/creating-a-simple-media-player/

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'
share|improve this question
    
"Didn't work" is somewhat the most useless thing to say. What happened when you did a "import gtk" at the top? Do you get another traceback? Some other error? –  Timo Jun 15 '12 at 18:59
    
I answered that comment by editing the question. –  Agmenor Jun 16 '12 at 2:30

2 Answers 2

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
snip

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

/snip

share|improve this answer
    
Skimming through that page, I see alot of references to just gtk and gtk.gdk, so this is probably not the case. –  Timo Jun 15 '12 at 19:01
    
@Timo fair point, see the edit –  hbdgaf Jun 15 '12 at 19:06
up vote 2 down vote accepted

I replaced "gtk.RESPONSE_OK" with "Gtk.ResponseType.OK"

Now everything is working correctly.

Found it here: http://python-gtk-3-tutorial.readthedocs.org/en/latest/dialogs.html

share|improve this answer
    
it seems like this is exactly what i originally suggested in my answer –  hbdgaf Jun 16 '12 at 12:02
    
Thank you sumit_gt. Please accept your own answer with the check sign. Aking1012, I share sumit_gt's likely opinion that your answer was not detailed enough for us beginners. –  Agmenor Jun 17 '12 at 1:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.