Tutorial: Creating your own CIG Modules


Create a New File

  • create a file, such as
     cigNameOfYourModule.py 
  • in the file header the imports of two cig modules is required
     from cigModule import * from cigPEPage import * 
  • the cigPEPage includes all the gui classes whereas the cigModule includes all module related things as for instance the PropertyItems

Adding a Panel

  • every panels requires 2 class definitions, one derived form the ProjectEditorPage to handle the GUI elements and one derived from the Module to handle the project elements/items
class YourModulePage(ProjectEditorPage):
  """The description of the page - the GUI layout"""

  def __init__(self, parent,values,defaults=[],onChange=None):

    #Initialize the standard fields (in this case the epsilon array)
    #This creates edit buttons for all arrays and text entries for the rest
    ProjectEditorPage.__init__(self,parent,values,defaults,onChange)

  def getPassiveItem(self,v,default,onChange):
    if v=='p':
      return ButtonProperty(self,'Run',onChange=self.run)
      print self

  def getPropertyItem(self,v,default,onChange,i):
    if v=='command':
      return SelectProperty(self, v, 'PCEVSolve', ['PCEVSolve','PCquadEVsolve'], onChange)
    else:
      return PropertyItem(self,v,default, onChange)

class YourModule(Module):
  """ The module describing the binary and how to use it"""

  def __init__(self):
    Module.__init__(self,['command','p'],['PCEVsolve','5'])

  def setProject(self,p):
    Module.setProject(self,p)
    self.project.setDontSave('command')

  def makePage(self,item,onChange):
    """Creates an instance of the YourModulePage Class - defined above"""
    self.page=YourModulePage(item,self.getNames(),defaults=self.getDefaults(),onChange=onChange,run=self.run)
    return self.page

Adding the Module in the cigNavigator

Topic revision: r1 - 08 Sep 2023, KerstenSchmidt
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Concepts? Send feedback