Package pyforms :: Package gui :: Module appmanager |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.gui.appmanager

     1  import sys, glob, os
     2  from PyQt4 import uic
     3  from PyQt4 import QtGui, QtCore
     4  import pyforms.Utils.tools as tools
     5
     6 -class Container(object):
     7 -        def __init__(self, ClassObject):
     8                  self._algorithm = ClassObject()
     9                  self._algorithm.initForm()
    10                  form_path = os.path.join(tools.get_object_class_path( Container ), 'mainWindow.ui')
    11                  self._form = uic.loadUi( form_path )
    12                  self._form.verticalLayout.addWidget( self._algorithm )
    13                  self._form.verticalLayout.setMargin(10)
    14                  self._form.verticalLayout.setSpacing(0)
    15                  self._form.actionExit.triggered.connect( self.actionExit_triggered )
    16                  self._form.show()
    17                  self._form.setWindowTitle( self._algorithm.title )
    18                  self._form.actionStop.setEnabled(False)
    19                  self._form.actionStop.triggered.connect( self.actionStop_triggered )
    20
    21                  try:
    22                          getattr(self._algorithm, 'execute')
    23                          self._form.actionRun.triggered.connect( self.actionRun_triggered )
    24                  except:
    25                          self._form.menuAlgorithm.setEnabled(False)
    26                          self._form.actionRun.setEnabled(False)
    27                          self._form.menuAlgorithm.setVisible(False)
    28                          self._form.actionRun.setVisible(False)
    29
    30
    31 -        def actionExit_triggered(self): exit()
    32 -        def actionRun_triggered(self):
    33                  self._algorithm.stop = False
    34                  self._form.actionRun.setEnabled(False)
    35                  self._form.actionStop.setEnabled(True)
    36                  self._algorithm.execute()
    37
    38 -        def actionStop_triggered(self):
    39                  self._algorithm.stop = True
    40                  self._form.actionRun.setEnabled(True)
    41                  self._form.actionStop.setEnabled(False)
    42
    43 -def startApp(ClassObject):
    44          app = QtGui.QApplication(sys.argv)
    45          container = Container(ClassObject)
    46          app.exec_()
    47