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.
You shouldn't be importing both gtk and pygtk, as they will cause conflicts with each other.
I ran into the same problem and found that the correct syntax is not
if response == gtk.RESPONSE_OK
. It should beif 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