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.

Possible Duplicate:
Facing problem with “gtk.RESPONSE_OK” in the simple-player quickly tutorial

I'm following along with this tutorial, but came to a stopping point where the program has an issue with the lineif response == gtk.RESPONSE_OK. This happens after clicking Open, then selecting a directory and clicking OK. The error message is "NameError: global name 'gtk' is not defined" So I researched it and found that apparently we need to import a couple things:

import pygtk
pygtk.require("2.0")
import gtk

If I add this to the SimpleMediaPlayerWindow.py, then the program won't run at all, giving an error message:

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
  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 thought all these things were installed and configured properly during the installation of quickly. Any suggestions?

On a side note, there are a few typos in the tutorial which may make it slightly difficult to follow. When deleting pre-existing containers from the window, it says "Navigate the list of children and delete label1" twice, but the second time it's actually referring to label2. "Find Horizontal Panes under the Containers tab..." actually should read "Find Paned under the Containers tab..." (maybe this changed with an updated version of glade). Lastly (so far), "Then add to your on_on_openbutton_clicked function" there's once too many on's in that function name.

share|improve this question
3  
Could you file bugs to have the tutorial fixed? bugs.launchpad.net/ubuntudeveloperportal/+filebug –  mhall119 May 19 '12 at 19:57
add comment

marked as duplicate by Tachyons, Ringtail, Jorge Castro, hhlp, Stephen Myall Nov 26 '12 at 11:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

You shouldn't be importing both gtk and pygtk, as they will cause conflicts with each other.

share|improve this answer
    
Thanks for the advice. I tried using "import gtk" which had the same error. Then I changed it to "import pygtk" and "pygtk.require("2.0")" which allowed the program to run, but when choosing a folder and clicking OK, I get this error message: "PlayerWindow.py", line 40, in on_openbutton_clicked if response == gtk.RESPONSE_OK: NameError: global name 'gtk' is not defined I haven't filed a bug for this because I would like someone to help me contribute to fixing the problems, not just wait for someone else to get some working code. –  linucksrox May 25 '12 at 0:28
add comment

I ran into the same problem and found that the correct syntax is not if response == gtk.RESPONSE_OK. It should be if response == Gtk.ResponseType.OK . This solved my problem and hope it will solve yours also. Reference: https://bugs.launchpad.net/ubuntu/+source/quickly/+bug/929572

share|improve this answer
add comment

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