The package SciParam contains the following parameter classes:
SciParam supports accessing them in several ways, as shown here with StringParam:
import SciParam param = SciParam.StringParam('Name')
import SciParam.parameter param = SciParam.parameter.StringParam('Name')
from SciParam import StringParam param = StringParam('Name')
This one is deprecated, except for saving keystrokes in interactive sessions:
from SciParam import * param = StringParam('Name')
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).
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:
import SciParam range1 = SciParam.Range() dist1 = SciParam.Distribution()
import SciParam.range import SciParam.distribution range1 = SciParam.range.Range() dist1 = SciParam.distribution.Distribution()
from SciParam import Range, Distribution range1 = Range() dist1 = Distribution()
This one is deprecated, except for saving keystrokes in interactive sessions:
from SciParam import * range1 = Range() dist1 = Distribution()
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), ]
The package SciParam.UI contains the following dialog classes:
SciParam supports accessing them in several ways:
import SciParam.UI dialog = SciParam.UI.ParameterDialog(...) notebook = SciParam.UI.ParameterNotebookDialog(...)
from SciParam.UI.dialog import ParameterDialog from SciParam.UI.notebook import ParameterNotebookDialog dialog = ParameterDialog(...) notebook = ParameterNotebookDialog(...)
from SciParam.UI import ParameterDialog, ParameterNotebookDialog dialog = ParameterDialog(...) notebook = ParameterNotebookDialog(...)
This one is deprecated, except for saving keystrokes in interactive sessions:
from SciParam.UI import * dialog = ParameterDialog(...) notebook = ParameterNotebookDialog(...)
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()
Thomas Arendsen Hein <thomas@intevation.de>