The display
module: 1D and 2D live displays¶
Warning
the display module is incomplete!!!! Work in progress.
The camdisp.CameraDisplay, andor.LiveDisplay and pxlfly
Live display of 2D data (e.g. images) and 1D data (e.g. spectra) for MicroscoPy
This classes are not meant to be used directly but subclassed for specific
purpose/hardware. In particular, LivePlot
must be extended with
a get_data()
method that returns the data to be plotted.
Widgets¶
Extra widgets are added to LivePlot with the widgets keywords, for examples:
widgets = [[w1,w2,w3], # one sublist per row
[w4], # widgets in sublist go in column
[w5,w6]]
will add six widgets (in three rows) below the main figure.
w1, w2, ... are not the widgets themselves, but functions that will be called by the LivePlot constructor, and must take exactly two arguments:
- a Tkinter object used as parent for the new widget (so the widget knows where to go)
- a reference to the LivePlot object (so the widget can interact with the application)
In addition we may want the widget to interact objects outside the LivePlot. This can be achieved thus:
def create_widget_X(*args, **kwargs):
def inner(parent, display):
return Widget_X(parent, [display], *args, **kwargs)
return inner
and then w1 above would be:
widgets = [[create_widget_X(cam), ..], ...] #
-
class
microscopy.display.
CustomToolbar
(canvas_, parent_, toggle)[source]¶ matplotlib toolbar with extra buttons for: 1. toggle live display 2. That’s all!
-
class
microscopy.display.
LivePlot
(ntracks, npoints, data_func=None, master=None, widgets=None)[source]¶ Provides a window to display 1D data (eg profiles across images or when in Single-Track/FVB acquisition mode).
- To use it you must either
- Provide a function to the data_func keyword argument, or
- Sub-class LivePlot and define a get_data() method.
Both data_func and get_data must return a 2D array od dimensions (ntracks, npoints).
- In addition, the following methods can be overriden if necessary:
- init_plot
- if_new_data_ready
- title
All tracks will be displayed in the same plot. Use start() to update the plot automatically (every 100ms by default, settable via the delay property).
Create a pyplot window and initialise the plot with zeros.
Parameters: - ntracks – number of lines to display
- npoints – line length
- master – Tkinter parent object (will create a Toplevel if provided, otherwise a new Tkinter instance)
- data_func – function that return data as a numpy array of shape (ntracks, npoints).
Alternative to overriding
get_data()
- widgets – a nested list of optional widgets to add to the plot.
-
microscopy.display.
status_widget
(status_var=None, **kwargs)[source]¶ Return a function that can be passed to
LivePlot
to add aStatusWidget
-
microscopy.display.
exposure_widget
(cam, **kwargs)[source]¶ Return a function that can be passed to
LivePlot
to add anExposureWidget
-
class
microscopy.display.
ExposureWidget
(master, cam, label_on_top=True)[source]¶ Frame with an Entry that sets the exposure of the camera.
Parameters: - master – the widget’s parent
- cam – the camera (any object with a settable
exposure
property) - label_on_top (bool) – whether to display the label aboveor left of the widget
-
microscopy.display.
autorefresh_widget
(**kwargs)[source]¶ Return a function that can be passed to
LivePlot
to add anAutoRefreshWidgetWidget
.
-
class
microscopy.display.
AutoRefreshWidget
(master, display)[source]¶ A Frame with an Button that toggle the display autorefresh state.
Parameters: - master – the widget’s parent
- disp – the camera display (any object with a settable
autorefresh
property)
-
microscopy.display.
scale_widget
(**kwargs)[source]¶ Return a function that can be passed to
LivePlot
to add anVerticalScaleWidget
-
class
microscopy.display.
VerticalScaleWidget
(master, disp, label_on_top=True)[source]¶ Frame with a linear/log menu and vertical offset
Parameters: - master – the widget’s parent
- disp – the camera display (any object with a settable
transform
property) - label_on_top (bool) – whether to display the label aboveor left of the widget