Next: 5. Keyboard Shortcuts Up: sciparam-manual Previous: 3. SciParam GUI
Subsections

4. Developer Documentation

4.1 Creating Parameters

4.1.1 Import of Parameter Classes

The package SciParam contains the following parameter classes:

SciParam supports accessing them in several ways, as shown here with StringParam:

This one is deprecated, except for saving keystrokes in interactive sessions:

Every parameter instance must have a name and can have a description, a unit, a default value, a current value and a comment. Additionally there are some boolean flags (required, notunknown, disabled) and method hooks (hook_isvalid, hook_isusual, hook_updated).

4.1.2 Import of Classes Range and Distribution

The parameter classes can build ranges and distributions from a string, therefore you don't need to import these classes very often. If you want to import them, use one of these methods:

This one is deprecated, except for saving keystrokes in interactive sessions:

4.1.3 Using Parameters with Ranges and Distributions

parameters = [
    StringParam('Name', 'a unique identifier', value='Silicon',
                required=1, maxlength=20, comment='A comment.'),
    IntParam('Atomic No', value=14, wrange='[1;260]', erange='[1;oo['
             description='Number in the periodic table of elements'),
    FloatParam('Atomic Mass', None, value=28.0855, erange='[0;oo['),
    ChoiceParam('Crystal', 'crystal structure',
                choices=[None, 'simple cubic', 'face centered cubic',
                         'body centered cubic', 'diamond cubic',
                         'tetragonal', 'orthorombic', 'monoclinc'],
                value='face centered cubic',
                default='face centered cubic', long=1),
    DistParam('Temperature', 'temperature of samples', '°C',
              value='17.5;3.7/normal', erange='[-273.15;oo['),
    ChoiceParam('Verified', 'Have these values been checked?',
                choices=ChoiceParam.yes_no, value=0, default=1),
]

4.2 Creating Dialogs and Notebooks

4.2.1 Import of Dialog Classes

The package SciParam.UI contains the following dialog classes:

SciParam supports accessing them in several ways:

This one is deprecated, except for saving keystrokes in interactive sessions:

4.2.2 Using Dialogs

Using a ParameterDialog works much like using any other dialog in wxPython. Additionally you have to specify a list of parameters and optionally a number of columns (defaults to one) to use:

 parameters = [parameter1, parameter2, parameter3]
 dialog = ParameterDialog(parent, -1, 'Dialog Title',
                          parameters, columns=2)
 if dialog.ShowModal() == wxID_OK:
     print "OK"
 else:
     print "Cancel"
 for par in dialog.get_parameters():
     print "%s = %s (%s)" % (par.name, par, par.value)
     print " comment = %s" % par.comment
 dialog.Destroy()

ParameterNotebookDialog takes a list of pages instead of parameters as argument. Each page is a 2-tuple consisting of page name and parameter list for this page:

 parameters1 = [parameter1, parameter2, parameter3]
 parameters2 = [parameter4, parameter5, parameter6]
 parameters3 = [parameter7, parameter8, parameter9]
 parameters = [('Page 1', page1),
               ('Page 2', page2),
               ('Page 3', page3)]
 dialog = ParameterNotebookDialog(parent, -1, 'Notebook Title',
                                  parameters, columns=2)
 if dialog.ShowModal() == wxID_OK:
     print "OK"
 else:
     print "Cancel"
 for par in dialog.get_parameters():
     print "%s = %s (%s)" % (par.name, par, par.value)
     print " comment = %s" % par.comment
 dialog.Destroy()


Next: 5. Keyboard Shortcuts Up: sciparam-manual Previous: 3. SciParam GUI

Thomas Arendsen Hein <thomas@intevation.de>