Table Of Contents

Previous topic

terapy package reference

Next topic

terapy.files package

This Page

terapy.core package

Submodules

terapy.core.button module

Run/Stop button

class terapy.core.button.RunButton(parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=4, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidator *' at 0x103542368> >, name=u'button')

Bases: wx._controls.BitmapButton

Graphical run/stop button with toggle function

Switch(state=True)

Switch between run and stop states (run = True, stop = False)

Parameters:
state - state (bool, run = True, stop = False)

terapy.core.choice module

Choice widget

class terapy.core.choice.ChoicePopup(parent, id=-1, value='', choices=[], pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidator *' at 0x103542368> >, name='')

Bases: wx.combo.ComboCtrl

Implement choice widget, which unfolds programmatically

DestroyPopup()
GetSelection()
SetSelection(pos)
class terapy.core.choice.ListViewComboPopup(*args, **kwds)

Bases: wx._controls.ListCtrl, wx.combo.ComboPopup, wx.lib.mixins.listctrl.ListCtrlAutoWidthMixin

ListView combo popup

Create(parent)
GetControl()
GetSelection()
Init()
OnDismiss()
OnLeftDown(evt)
OnMotion(evt)
OnPopup()

terapy.core.dataman module

Container classes for measurement data.

class terapy.core.dataman.DataArray(shape=[], name='Current scan')

Data array container class Store data in an array of specified shape, with corresponding coordinate axes

Copy()

Create a copy of itself.

Output:
copy of itself (DataArray)
Decrement(dim)

Decrement position along selected scan dimension

Parameters:
dim - array dimension (int)
GetCoordinateValue()

Get value for current coordinate axis

Output:
coordinate value (float)
GetPosition(dim)

Get position counter along selected scan dimension

Parameters:
dim - array dimension (int)
Output:
position index (int)
GetValue()

Get array value at current scan position

Output:
value (float)
Increment(dim)

Increment position along selected scan dimension

Parameters:
dim - array dimension (int)
Rescale(new_labels, defaults=[])

Rescale data according to given axes settings.

Parameters:
new_labels - list of new labels+units (list of AxisInfos) defaults - default values if none are currently set (list of AxisInfos)
SetCoordinateValue(value)

Set value for current coordinate axis

Parameters:
value - value (float)
SetPosition(dim, pos)

Set position counter along selected scan dimension

Parameters:
dim - array dimension (int) pos - position index (int)
SetValue(value)

Set array value at current scan position

Parameters:
value - value (float)
class terapy.core.dataman.Measurement(name='', events=None)

Measurement container class Store several data arrays corresponding each to one measured quantity during a measurement sequence.

BuildDataTree()

Build data arrays from given measurement events

Decrement(narrays)

Decrement scan position for current scan dimension of selected data array

Parameters:
narray - array index (int)
DecrementScanDimension(narrays)

Decrement scan dimension of selected data arrays

Parameters:
narrays - list of array indices (list of int)
GetCoordinateValue(narrays)

Get value for current coordinate axis of selected data arrays

Parameters:
narrays - list of array indices (list of int)
Output:
list of values (list of float)
GetCurrentValue(narray)

Get value at current position in selected data array

Parameters:
narray - array index (int)
Output:
value (float)
GetScanDimension(narrays)

Get scan dimension of selected data arrays

Parameters:
narrays - list of array indices (list of int)
Output:
list of dimensions (list of int)
GetShapes(events=None, shape=[], opcount=[], axes=[])

Compute shapes of data arrays from given measurement events Result stored as self.shape

Parameters:
events - measurement events (SubTree). If None, takes self.events shape - shapes of previously processed arrays, used internally opcount - number of operations for previously processed arrays, used internally axes - axis devices of previously processed dimensions, used internally
Results:
self.shape - shape of data arrays for given measurement events self.opcount - number of operations for data arrays for given measurement events
Increment(narrays)

Increment scan position for current scan dimension of selected data array

Parameters:
narray - array index (int)
IncrementScanDimension(narrays)

Increment scan dimension of selected data arrays

Parameters:
narrays - list of array indices (list of int)
ResetCounter(narrays)

Reset scan position in selected arrays

Parameters:
narrays - array indices (list of int)
SetCoordinateValue(narrays, value)

Set value for current coordinate axis of selected data arrays

Parameters:
narrays - list of array indices (list of int) value - value (float)
SetCurrentValue(narray, value, inc=False, dec=False)

Set value for current position of selected data array

Parameters:
narray - array index (int) value - value (float) inc - increment index after (bool) dec - decrement index after (bool)
SetScanDimension(narrays, dim)

Set scan dimension of selected data arrays

Parameters:
narrays - list of array indices (list of int) dim - dimension (int)
SetScanPosition(narrays, pos)

Set scan position for current scan dimension of selected data array

Parameters:
narray - array index (int) pos - position (int)

terapy.core.dragdrop module

Drag and drop classes

class terapy.core.dragdrop.EventDragObject

Bases: terapy.core.dragdrop.GenericDragObject

ScanEvent drag object

class terapy.core.dragdrop.EventDrop(func)

Bases: terapy.core.dragdrop.GenericDrop

ScanEvent drop target

class terapy.core.dragdrop.FilterDragObject

Bases: terapy.core.dragdrop.GenericDragObject

Filter item drag object

class terapy.core.dragdrop.FilterDrop(func)

Bases: terapy.core.dragdrop.GenericDrop

Filter item drop target

class terapy.core.dragdrop.GenericDragObject(fmt='None')

Bases: wx._misc.PyDataObjectSimple

All-purpose drag object

GetData()
GetDataHere()
GetDataSize()
SetData(data)
class terapy.core.dragdrop.GenericDrop(func)

Bases: wx._misc.DropTarget

All-purpose drop target

OnData(x, y, d)
class terapy.core.dragdrop.HistoryDragObject

Bases: terapy.core.dragdrop.GenericDragObject

History item drag object

class terapy.core.dragdrop.HistoryDrop(func)

Bases: terapy.core.dragdrop.GenericDrop

History item drop target

terapy.core.history module

History handling classes and controls

class terapy.core.history.HistoryControl(parent=None)

Bases: wx._windows.Panel

History widget (list and control buttons)

ChangeColour(position)

Ask user to select colour of selected item.

Parameters:
position - item position (int)
ClearReference(inst=None)

Clear reference status of selected item.

Parameters:
inst - wx.Event or pubsub data (DataArray)
Delete(position)

Delete selected item.

Parameters:
position - item position (int)
Insert(arr, name='Current scan', pos=0)

Insert new item in given position.

Parameters:
arr - data array (DataArray) name - displayed name (str) pos - item position (int)
Move(disp)

Move selected item by given amount

Parameters:
disp - displacement (int, positive or negative)
OnEndDrag(x, y, data)

Actions following drop on control.

Parameters:

x,y - coordinates of drop action (int) data - dropped data (str)

Passing drag and drop data in wxpython is incovenient. Alternative used here: use GetFirstSelected and HitTest functions of wx.ListBox to determine what to move and where to put it
OnKeyPress(event=None)

Actions triggered by key press on control.

Parameters:
event - wx.Event
OnLeftClick(event=None)

Actions triggered by left click on list item.

Parameters:
event - wx.Event
OnLoad(event)

Actions triggered by load event.

Parameters:
event - wx.Event
OnPlotDeleted(event=None)

Actions triggered on item delete event.

Parameters:
event - wx.Event
OnRightClick(event=None)

Actions triggered by right click on list item.

Parameters:
event - wx.Event
OnSelect(event=None)

Actions triggered by double click on list item.

Parameters:
event - wx.Event
OnStartDrag(event=None)

Actions triggered by drag event.

Parameters:
event - wx.Event
Rename(event=None)

Rename selected item.

Parameters:
event - wx.Event
ResetColour(position)

Reset colour of selected item.

Parameters:
position - item position (int)
SaveAs(position)

Trigger save procedure for selected item.

Parameters:
position - item position (int)
SetCanvas(inst)

Set canvas reference from pubsub event.

Parameters:
inst - pubsub event data
SetColors(event=None)

Set colors of items in list from associate data arrays.

Parameters:
event - wx.Event
SetReference(inst)

Set selected item as reference.

Parameters:
inst - item position (int)
or pubsub data (DataArray)
SetWindow(inst)

Set main window reference from pubsub event.

Parameters:
inst - pubsub event data
TagAsReference(position, state=True)

Tag/Untag selected item as reference.

Parameters:
position - item position (int) state - state (bool)
class terapy.core.history.HistoryList(parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=4, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidator *' at 0x103542368> >, name=u'listCtrl')

Bases: wx._controls.ListCtrl, terapy.core.history.HistoryMixin, wx.lib.mixins.listctrl.ListCtrlAutoWidthMixin

List widget with history functions

class terapy.core.history.HistoryMixin

Bases: object

History list mix-in Add history functionalities to list widget

BroadcastArrays(inst=None)

Broadcast data associated to all list items through pubsub

Parameters:
inst - pubsub event data
ClearReference(idp)

Clear reference status for item at given position

Parameters:
idp - item position (int)
Output:
filter bank (FilterBank)
GetArrays()

Return data associated to all items

Output:
list of data (list)
GetIdPosition(idx)

Return item position associated with given item id.

Parameters:
idx - item id (int)
Output:
item position (int)
GetItemById(idx)

Return data associated with given item id.

Parameters:
idx - item id (int)
Output:
data (any type)
GetItemId(item)

Return item id associated with given data.

Parameters:
item - data (any type)
Output:
item id (int)
GetItemPyData(idp)

Return item associated to given position

Parameters:
idp - list position (int)
Output:
data (stored type)
GetReferenceBank(idp)

Get filter bank for which item at given position is reference

Parameters:
idp - item position (int)
Output:
filter bank (FilterBank)
IsReference(idp)

Tell if item at given position is used as reference

Parameters:
idp - item position (int)
Output:
True/False
OnDeleteAllItems(event=None)

Actions to be taken when all items are deleted

Parameters:
event - wx.Event
OnDeleteItem(event=None)

Actions to be taken when an item is deleted

Parameters:
event - wx.Event
SetItemPyData(idp, data)

Associate data to item

Parameters:
idp - list position (int) data - data to associate (any type)
SetReference(idp, bank=None)

Set item at given position as reference for given filter bank

Parameters:
idp - item position (int) bank - filter bank (FilterBank)

terapy.core.menus module

Functions for menu handling

terapy.core.menus.GetItemIds(menu)

Return list of menu item ids for given menu

Parameters:
menu - menu (wx.Menu)
Output:
menu item ids (list)

terapy.core.parsexml module

Functions for XML configuration file parsing

terapy.core.parsexml.ParseAttributes(attrs, recipient)

Convert XML attributes into object variables

Parameters:
attrs - XML attributes (xmldom key) recipient - class with appropriate class variables

terapy.core.splitter module

Implement proportional splitter window

class terapy.core.splitter.Splitter(parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=768, name=u'splitter', proportion=0.8)

Bases: wx._windows.SplitterWindow

Proportional splitter window from http://wiki.wxpython.org/ProportionalSplitterWindow

GetExpectedSashPosition()
OnPaint(event)
OnReSize(event)
OnSashChanged(event)
ResetSash()
SplitHorizontally(win1, win2)
SplitVertically(win1, win2)

terapy.core.threads module

Custom interface threads

class terapy.core.threads.ProgressThread(meas)

Bases: threading.Thread

Thread responsible for updating progress status during measurement.

progress()

Return associated measurement progress.

Output:
progress, in percent
run()

Run thread.

stop(inst=None)

Stop thread.

Parameters:
inst - pubsub event data
class terapy.core.threads.ScanThread(sequence, meas)

Bases: threading.Thread

Thread active during scan sequence.

run()

Run thread.

terapy.core.tooltip module

Custom tooltip widget

class terapy.core.tooltip.ToolTip(message='', header='', target=None)

Bases: wx.lib.agw.supertooltip.SuperToolTip

Attempt to handle lousy word wrapping occurring with Windows. SuperToolTip handles word wrap well, but other issues arise (i.e. lousy timing of show/hide vs mouse events)

terapy.core.treectrl module

Tree control with enhanced features and support classes.

class terapy.core.treectrl.SubTree(tree, itm=None)

Bases: terapy.core.treectrl.SubTreeItem

Subtree

AppendItem(item)

Append given item to subtree.

Parameters:
item - subtree (SubTree) or subtree item (SubTreeItem)
CountOccurrences(attr, value)

Count occurrences of given attribute with given value in subtree.

Parameters:
attr - attribute name (str) value - value (attribute value type)
Output:
number of occurrences (int)
GetAttributeTree(attr)

Get values of all subtree elements with given attribute.

Parameters:
attr - attribute name (str)
Output:
nested list of attribute values
GetDepth(d0=1)

Compute depth of subtree.

Parameters:
d0 - initial depth (int) - used internally
Output:
depth (int)
GetItem(pos)

Return item at given position in subtree children.

Parameters:
pos - position (int)
Output:
subtree (SubTree) or subtree item (SubTreeItem)
InsertItem(pos, item)

Insert given item in subtree at given position.

Parameters:
item - subtree (SubTree) or subtree item (SubTreeItem) pos - position (int)
IsDataInTree(data)

Tell if given data is in subtree.

Parameters:
data - data to be searched for
Output:
True/False
RemoveItem(pos)

Remove item in given position of subtree children.

Parameters:
pos - position (int)
class terapy.core.treectrl.SubTreeItem(tree, itm=None)

Subtree item

GetItemAttribute(attr)

Fetch value of given attribute name from stored item data.

Parameters:
attr - attribute name (str)
Output:
attribute value
IsDataInTree(data)

Check if given data is in current subtree item.

Parameters:
data - data (any type)
Output:
True/False
RestoreValue(itm)

Restore value of subtree item object into given item.

Parameters:
itm - tree item (wx.TreeItem)
StoreValue(itm)

Store value of given item in subtree item object.

Parameters:
itm - tree item (wx.TreeItem)
class terapy.core.treectrl.TreeCtrl(parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=8197, validator=<wx._core.Validator; proxy of <Swig Object of type 'wxValidator *' at 0x103542368> >, name=u'wxTreeCtrl')

Bases: wx._controls.TreeCtrl

Tree widget.

CreateItemSubTree(itm, subtree)

Create item subtree from given SubTree object.

Parameters:
itm - item (wx.TreeItem) subtree - subtree (SubTree)
FindItem(data, itm=None)

Find item within subtree of given item (root item if none given).

Parameters:
data - data to be found (any) itm - item (wx.TreeItem or None)
Output:
item (wx.TreeItem)
GetItemChildren(itm, cl=None)

Get children of given item.

Parameters:
itm - item (wx.TreeItem) cl - class, optional - if given, will return only items with data of given class type
Output:
item children (list)
GetItemSubTree(itm, cl=None)

Get subtree for given item.

Parameters:
itm - item (wx.TreeItem) cl - class, optional - if given, will return only items with data of given class type
Output:
item subtree (SubTree)
GetItemsData(itmlist)

Get data associated with items in given list.

Parameters:
itmlist - item list (list of wx.TreeItem)
Output:
item data list (list)
MoveItemDown(itm, cl=None)

Move given item one position downwards.

Parameters:
itm - item (wx.TreeItem) cl - class, optional - if given, will move only within items with data of given class type
MoveItemUp(itm, cl=None)

Move given item one position upwards.

Parameters:
itm - item (wx.TreeItem) cl - class, optional - if given, will move only within items with data of given class type

terapy.core.validator module

Custom data validators

class terapy.core.validator.IntegerValidator

Bases: terapy.core.validator.NumberValidator

Validator for integer numbers

Clone()
class terapy.core.validator.NumberValidator(floats=True, negative=True)

Bases: wx._core.PyValidator

Validator for numbers

Clone()
OnChar(event)
TransferFromWindow()
TransferToWindow()
Validate(win)
class terapy.core.validator.PositiveFloatValidator

Bases: terapy.core.validator.NumberValidator

Validator for positive floating point numbers

Clone()

Module contents

Miscellaneous classes and functions implementing several core (and not so core) functionalities of TeraPy.

terapy.core.check_py(fname)

Check that the given file name is a python script, compiled or not.

Parameters:
fname - file name (str)
Output:
True/False
terapy.core.parse_modules(package, dirname, cls)

Parse for modules of given class in given directory.

Parameters:
package - package prefix (str) dirname - directory name (str) cls - class type
Output:
module list (list of type cls)