Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
import gtk

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

/usr/lib/python2.7/dist-packages/gobject/ 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/ 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/ 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

marked as duplicate by Tachyons, Ringtail, Jorge Castro, hhlp, stephenmyall 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.

Could you file bugs to have the tutorial fixed? – mhall119 May 19 '12 at 19:57
up vote 2 down vote accepted

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:

share|improve this answer

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: "", 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

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