title: manipulate python variable inside a GTK action listener
body: <p>I'm trying to an action listener that is attached to a checkbox button.  My goal is to toggle the variable value ( 0 or 1 ) whenever the checkbox is checked/unchecked.  </p>
  
  <p>I come from a C background and am fairly new to python.  I've also been reading up on global variable but I cannot seem to grasp it.</p>
  
  <p>I will do an example in C first : </p>
  
  <pre><code>//#includes
  
  int test; //i could say public int test but it is public by default
  
  int foo()
  {
      test = 1;
      return test;
  }
  void main()
  {
     test = 0;
     print (foo);
  }
  </code></pre>
  
  <p>Some example python code is below. </p>
  
  <pre><code>class someRandomClass: 
  
      def on_checkbutton1_toggled(self, widget, data=None):
          if test == 0:
              test = 1
          if test == 1:
              test = 0
  
      def __init__(self):
          global test
          test = 0
  
  if __name__ == "__main__":
      main = someRandomClass()
      gtk.main()
  </code></pre>
  
  <p>Executing this python code and clicking on the checkbox throws an
      UnboundLocalError: local variable 'test' referenced before assignment</p>
  
  <p>I've tried creating the global variable outside of a function but still inside the class - the same method as the example C code.</p>