def run_widget(myclass): """ run a qt app using myclass as the main widget. This funtion calls sys.exit(). """ from PyQt4.QtGui import QApplication a = QApplication(sys.argv) a.setStartDragDistance(8) w = myclass() w.show() sys.exit(a.exec_())