gui – graphical components and frontends to pario objects

Modules for graphical manipulation of objects in pario.

paredit – edit Parameters objects

Editor for Parameters objects.

Examples

Create a Parameters object to edit

>>> import pario.parameters
>>> p = pario.parameters.Parameters()
>>> p._set('velocity', 5, 'm/s', doc='out speed')

Easiest way to use paredit is through the _edit() method

>>> p._edit()   

The same functionality is provided with pario.paredit.paredit():

>>> paredit(p)  
class pario.paredit.ArrayWidget(name, value)[source]

A button for opening a dialog for editing an array.

class pario.paredit.BoolWidget(name, value)[source]

A QCheckBox for editing bools.

class pario.paredit.LineWidget(name, value)[source]

A QLineEdit for editing floats, ints and strings.

class pario.paredit.OneOfWidget(name, value, possibilities, widget=<class 'PyQt4.QtGui.QRadioButton'>, value_wrap=32)[source]

A set of radioboxes for selecting one of several possibilities. possibilities should be a comma-separated list of possible values or of the form “0=first option, 1=second option”.

If value_wrap is not None, it must be an integer determing the maximum width of the value field (by word-wrapping).

class pario.paredit.ParEdit(par, parent=None, names=None, group=None, title='Parameters', header=True, callback=None)[source]

A class that allows graphical editing of model parameter.

See paredit() for a description of the arguments.

setpar()[source]

Set parameters to new values.

update()[source]

Update dialog from parameters.

validatepar()

Returns True is all parameter are valid. Otherwise the cursor is set to the invalid parameter and False is returned.

class pario.paredit.SumOfWidget(name, value, possibilities)[source]

A set of checkboxes for selecting one or more of several possibilities. possibilities should be of the form “0=first flag, 1=second flag”.

pario.paredit.paredit(par, dialog=None, names=None, group=None, title='Parameters', header=True, callback=None, wait=True)[source]

Creates a parameter dialog and updates par.

Parameters :

par : Parameters instance

Parameters instance to edit.

dialog : None | ParEdit instance

If given, the existing dialog is made visible and raised. instead of creating a new dialog.

names : None | sequence of strings

If given, include only parameters included in names.

group : None | string

If given, include only parameters of this group.

title : string

Dialog title.

header : bool

Whether to add a header.

callback : None | callable(par, done)

A callback function that is called when the dialog is closed or the apply button is pressed. callable will be called with two arguments:

par:updated parameter instance
done:a boolean that is true if the dialog is closed

wait : bool

If True, this function does not return before the dialog is closed.

Returns :

QtGui.QDialog instance

arrayedit2 – edit numpy arrays

Graphical editor for 1D record or 2D ordinary numpy arrays.

Examples

>>> a = np.random.rand(5, 3)
>>> anew = arrayedit(a)   
>>> b = np.rec.fromarrays([
...         [1, 2, 3, 4],
...         ['a', 'dd', '12', 'a b c'],
...         [1.1, 2, 3, 4], 
...     ], names='time(s),label,diameter')
>>> bnew = arrayedit(b)   
class pario.arrayedit2.ArrayEdit(arr, parent=None, names=None, formats='%s', editable=True, resizable=True)[source]

A class that allows graphical editing of a numpy (field) array.

Parameters :

arr : numpy array

A numpy array (either be a 1d record array or a 2d ordinary array) or an instance of a ArrayModelBase subclass.

parent : None | window

Parent window.

names : None | sequence of strings

Column names.

formats : string

Column display formats.

editable : bool

Whether array can be edited.

resizable : bool

Whether array can be resized.

Attributes

error(message) Signal emitted on invalid assignments and other errors.
newData(arr) Signal emitted when the underlying array is replaced. This signal will only be emitted if resizable is true.
adjustTableSize()[source]

Adjust table size.

onAppendRows()[source]

Append as many rows as are selected.

onCellMenu(point)[source]

Show context menu in cells.

onColumnFormula()[source]

Update formula for current column.

onColumnMenu(point)[source]

Show context menu for column header.

onCopy()[source]

Copy selected cell to clipboard

onFillColumn()[source]

Fill column with the value at the mouse position.

onFillLinear()[source]

Fill column with the value at the mouse position.

onFillLogarithmic()[source]

Fill column with the value at the mouse position.

onFormatColumn()[source]

Update display format of current column.

onLinear()[source]

Set column marked to a linear continuation of the two first items.

onLogarithmic()[source]

Set column col to a logarithmic continuation of the two first items.

onOpen()[source]

Replace array with a new from file.

onPaste()[source]

Paste from clipboard to selected cells

onPlot(checked=None, cmd='plot')[source]

Plots selected columns in a new matplotlib window.

onRowMenu(point)[source]

Show context menu for row header.

onSave()[source]

Replace array with a new from file.

onShowPlotBar(show=False)[source]

Whether to show the plotbar.

onShowToolTip(enable=False)[source]

Whether to show unformatted data in tooltip.

setupUI()[source]

Sets up GUI.

class pario.arrayedit2.ArrayEditDialog(arr, parent=None, title='Array', names=None, formats='%s', editable=True, resizable=True)[source]

A class that allows graphical editing of a numpy (field) array.

Parameters :

arr : numpy array | ArrayModel

A numpy array (either be a 1d record array or a 2d ordinary array) or an instance of a ArrayModelBase subclass.

parent : None | window

Parent window.

title : string

Dialog title.

names : None | sequence of strings

Column names.

formats : string

Column display formats.

editable : bool

Whether array can be edited.

resizable : bool

Whether array can be resized.

Attributes

error(message) Signal emitted on invalid assignments and other errors.
newData(arr) Signal emitted when the underlying array is replaced. This signal will only be emitted if resizable is true.
getArray()[source]

Returns current array.

onNewSizeHint(width, height)[source]

Resize dialog when table is suggesting a new size.

class pario.arrayedit2.MyTableView(parent=None, maxScreenFraction=0.8, tableMargin=7)[source]

A QTableView subclass with an improved sizeHint().

Parameters :

parent : widget

Parent widget

maxScreenFraction : float

Maximal fraction of screen size in width and heigh that will be suggested.

tableMargin : int

Additional margin to add in width and height (pixels).

sizeHint()[source]

Reimplemented sizeHint()

class pario.arrayedit2.NewColumnDialog(parent=None)[source]

A dialog that asks for name and data type for a new column.

static getInfo(parent=None)[source]

Popup dialog and return (name, type, format, ok).

pario.arrayedit2.arrayedit(arr, dialog=None, title='Array editor', names=None, formats='%s', editable=True, resizable=False, wait=True)[source]

Creates a dialog for editing a numpy array.

Parameters :

arr : numpy array

A numpy array (either be a 1d record array or a 2d ordinary array).

dialog : None | ArrayEditDialog instance

If given, the existing dialog is made visible and raised.

title : string

Dialog title.

names : None | sequence of strings

Column names.

formats : string

Column display formats.

editable : bool

Whether array can be edited.

resizable : bool

Whether array can be resized.

wait : bool

If True, this function does not return before the dialog is closed. Note, if you set wait to False, you will have to connect to the newData() signal if the array is resizable. Otherwise will all changes after resizing be lost.

Returns :

If wait is True, the updated array is returned. Otherwise the

dialog is returned.

chemistryedit – edit Chemistry objects

An graphical editor element and particle content.