title: NameError: global name 'gtk' is not defined
body: <p>I noticed that the 'gtk' is not defined and I couldn't figure out what it meant despite me managing to import PYGTK when it runs. Below is the code:</p>
  
  <pre><code>import sys
  
  importStatus = False
  
  try:
      from gtk import *
      importStatus = True
  
  except ImportError:
      print "PyGTK module does not exist. Can't launch GUI !"
      print "Please download and install GTK and PyGTK."
      importStatus = False
  
  if importStatus:
  
      class gtkGUI():
  
          def __init__(self):
              print "gtkGUI imported"
  
          def startGUI(self):
              print "GUI Started"
              self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
              return None
  </code></pre>
  
  <p>Below is the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "mainGUI.py", line 14, in &lt;module&gt;
      gtk.startGUI()
    File "..../gtkGUI.py", line 25, in startGUI
      gtk.main()
  NameError: global name 'gtk' is not defined
  </code></pre>
  
  <p>How should I solve this error ? Thanks.</p>