Utility Classes¶
-
class
ilastik.utility.
bind
[source]¶ Behaves like functools.partial, but discards any extra parameters it gets when called. Also, bind objects can be compared for equality and hashed.
bind objects are immutable.
Inspired by boost::bind (C++).
-
__init__
()¶ x.__init__(...) initializes x; see help(type(x)) for signature
-
-
class
ilastik.utility.
SimpleSignal
[source]¶ A simple python-only signal class for implementing the observer pattern. For familarity, mimics a SUBSET of the pyqt signal interface. Not threadsafe. No fine-grained unsubcribe mechanism.
-
class
ilastik.utility.
OperatorSubView
(op, index)[source]¶ An adapter class that makes a specific lane of a multi-image operator look like a single image operator.
If the adapted operator is an OperatorWrapper, then the view provides all of the members of the inner operator at the specified index, except that the slot members will refer to the OperatorWrapper’s slots (i.e. the OUTER slots).
If the adapted operator is NOT an OperatorWrapper, then the view provides all the members of the adapted operator, except that ALL MULTISLOT members will be replaced with a reference to the subslot for the specified index. Non-multislot members will not be replaced.
-
class
ilastik.utility.
MultiLaneOperatorABC
[source]¶ This abstract base class specifies the interface to which all top-level applet operators must adhere. The distinguishing characteristic of a top-level operator is the fact that they must be capable of supporting multiple images via multi-slots that are indexed by image lane number.
Image lanes of the top-level operator are added, removed, and accessed via the
addLane
,removeLane
, andgetLane
functions.Note
Most applets can simply inherit from the
StandardApplet
base class, which will automatically adapt single-lane top-level operators to satisfy this interface.-
addLane
(laneIndex)[source]¶ Add an image lane. Called by the workflow when the user has added a new image to the pipeline.
- Postcondition: The operator must be fully prepared to accept a new image.
- All input and output slots that are used by the image lane must be resized. Any internal operators that are part of the lane must be expanded).
Note
Multi-slots that are connected together are auto-resized to stay in sync. To resize a network of connected multi-slots (including OperatorWrapper inputs and outputs), it is generally sufficient to resize only one of the multi-slots. The others will auto-resize to adjust. See lazyflow documentation for details. If your operator has any slots that are NOT connected to the rest of the inputs or outputs, then be sure to resize it explicitly in this function.
-
-
class
ilastik.utility.
OpMultiLaneWrapper
(operatorClass, operator_args=None, operator_kwargs=None, parent=None, graph=None, promotedSlotNames=None, broadcastingSlotNames=None)[source]¶ An extension of the
OperatorWrapper
that provides the functions needed to satisfyMultiLaneOperatorABC
. SeeOperatorWrapper
class documentation for details on that class.-
addLane
(laneIndex)[source]¶ Add an image lane to this object. Simply inserts a new inner operator into the base
OperatorWrapper
.
-
GUI Utilities¶
QT can be finicky about calling certain functions from non-GUI threads. These two utility classes provide mechanisms for forcing code to be called from within the GUI thread.
-
class
ilastik.utility.gui.
ThunkEventHandler
(parent)[source]¶ GUI objects can instantiate an instance of this class and then start using it to post
ThunkEvents
, which execute a given callable in the GUI event loop. The callable will NOT be called synchronously. It will be called when the QT event system eventually passes the event to the GUI object’s event filters.In the following example,
C.setCaption()
can be called from ANY thread safely. The widget’s text will ONLY be updated in the main thread, at some point in the future.class C(QObject): def __init__(self, parent): QObject.__init__(self, parent=parent) self.thunkEventHandler = ThunkEventHandler(self) def setCaption(self, text): self.thunkEventHandler.post( self.mywidget.setText, text )
-
__init__
(parent)[source]¶ Create a ThunkEventHandler that installs itself in the event loop for
parent
.
-
-
ilastik.utility.gui.
threadRouted
(func)¶ Decorator that routes calls to the given member function into the object’s parent thread. If a member function
f
is decorated with@threadRouted
, all calls tof
will execute in the GUI thread. The calling thread will block whilef
is executing, so the call will appear synchronous. This mechanism is slow, and should only be used for functions that MUST execute in the GUI thread.Note
Objects that use the @threadRouted decorator MUST have a
ThreadRouter
member calledself.threadRouter
-
class
ilastik.utility.gui.
ThreadRouter
(parent)[source]¶ Create an instance of this class called ‘threadRouter’ to enable the
@threadRouted
decorator for methods of your object.-
__init__
(parent)[source]¶ Construct a threadRouter object. You must call it
self.threadRouter
.Parameters: parent – The parent object, which whose thread will be used for all @threadRouted
functions.
-