title: Using self in a Python class (in Nuke making a GUI)
body: <p>So this first part shouldn't matter too much to the code, but just fyi for anyone who knows it, I'm writing this inside of The Foundry's 'Nuke'. Creating a pythonPanel GUI.</p>
  
  <p>So when I'm creating my panel, it starts:</p>
  
  <pre><code>class notePanel(nukescripts.PythonPanel):
      def __init__(self):
          nukescripts.PythonPanel.__init__(self, 'Note Panel', 'com.ohufx.notePanel')
  </code></pre>
  
  <p>With the <strong>init</strong>(self): part.</p>
  
  <p>When I'm adding knobs, or UI controls, to this panel, I use sometihng like:</p>
  
  <pre><code>    self.proj = nuke.String_Knob('proj', 'Project:', os.environ['SHOW'])
      self.addKnob(self.proj)
      self.proj.setFlag(nuke.STARTLINE)
  </code></pre>
  
  <p>Which works fine. Also, when I'm creating scripts that run in the panel I do something like:</p>
  
  <pre><code>def launchSGPage(self):
      pr = self.proj.value()
      sh = self.shot.value()
      url = shotgun.getURL(pr,sh)
      webbrowser.get('/usr/bin/google-chrome %s').open(url)
  </code></pre>
  
  <p>Also using self, which works great.</p>
  
  <p>My problem is that in my first step, when I'm adding knobs (Like the string knob I created) and I want to make one of my functions (Like the launchSGPage above) the script that runs on a specific button, if I do this:</p>
  
  <pre><code>    self.sgpage = nuke.PyScript_Knob('sgpage', 'Open SG page', 'self.launchSGPage()')
  </code></pre>
  
  <p>the self.launchSGPage() gives me an error. For some reason self isnt working in this context, and so far the only way ive gotten this to work is by naming me panel when I add it to the ui (in this case I named it nPanel) and using its name to call my function, like this below:</p>
  
  <pre><code>def addnotePanel():
      global nPanel
      nPanel = notePanel()
      return nPanel.addToPane()
  </code></pre>
  
  <p>and so my script button would look like:</p>
  
  <pre><code>    self.sgpage = nuke.PyScript_Knob('sgpage', 'Open SG page', 'nPanel.launchSGPage()')
  </code></pre>
  
  <p>This works for all intents and purposes but just seems... dirty and unclean to me. I'm not sure what, but something tells me theres something wrong with this. Can anyone clear up for me a BETTER way to link to my functions in this class rather than by a global variable name?</p>