title: Python: How to correctly use external functions
body: <p>This is something I've seen a fair bit of documentation on but I can't get an exact answer to this specific gap in my knowledge and I keep running into walls because of it, nothing seems to really cover it on this level:</p>
  
  <p>I have a few windows, all of them should be draggable, so I'm building a utilities file. In this file I have this:</p>
  
  <pre><code>def mouseMoveEvent(self, event):
      if self.moving: self.move(event.globalPos()-self.offset)
  
  def mousePressEvent(self, event):
      if event.button() == QtCore.Qt.LeftButton:
          self.moving = True; self.offset = event.pos()
  
  
  def mouseReleaseEvent(self, event):
      if event.button() == QtCore.Qt.LeftButton:
          self.moving = False
  </code></pre>
  
  <p>And this will work if I put it into a single file (and don't call from another one) with the actual window.</p>
  
  <p>The question is, how do I call to this from another file (the one that has the UI window)?</p>
  
  <p>I am calling to it by</p>
  
  <pre><code> from utils import *
  </code></pre>
  
  <p>So technically those functions are all accessible simply by typing</p>
  
  <pre><code>mouseReleaseEvent(x,x)
  </code></pre>
  
  <p>But I need the UI to import those functions, so in the main file after putting up the 'from utils import *' I type:</p>
  
  <pre><code>self.moving = False
  </code></pre>
  
  <p>But that errors no matter what I do. So the question is what is the proper way to enclose the functions listed first (first code block) so that I can call to them from within my UI file?</p>
  
  <p>Here is my UI code:</p>
  
  <pre><code>    #!/usr/bin/env python
  
      import sys
      import os
      from PyQt4 import QtCore, QtGui
      from vibotCss import css
      from viUtils import *
  
      class viBadOSUI(QtGui.QDialog):
          def __init__(self):
              QtGui.QDialog.__init__(self)
              #setup window
              self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
              self.resize(300, 150)
              center(self)
              self.setMouseTracking(True)
  
  
  
              #additional code
              self.show()
              self.setStyleSheet(css)
  
  
  
      app = QtGui.QApplication(sys.argv)
      window = viBadOSUI()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>I have large gaps in my Python knowledge due to learning and using it solely from within Autodesk Maya for a long time - I am trying to bridge said gaps now. Thank you for any help.</p>