chaco.examples.demo.advanced.data_stream module¶
Visualization of simulated live data stream
Shows how Chaco and Traits can be used to easily build a data acquisition and visualization system.
Two frames are opened: one has the plot and allows configuration of various plot properties, and one which simulates controls for the hardware device from which the data is being acquired; in this case, it is a mockup random number generator whose mean and standard deviation can be controlled by the user.
-
class
chaco.examples.demo.advanced.data_stream.
Controller
¶ Bases:
traits.has_traits.HasTraits
-
timer_tick
(*args)¶ Callback function that should get called based on a timer tick. This will generate a new random data point and set it on the .data array of our viewer object.
-
-
class
chaco.examples.demo.advanced.data_stream.
Demo
¶ Bases:
traits.has_traits.HasTraits
-
configure_traits
(*args, **kws)¶ Creates and displays a dialog box for editing values of trait attributes, as if it were a complete, self-contained GUI application.
This method is intended for use in applications that do not normally have a GUI. Control does not resume in the calling application until the user closes the dialog box.
The method attempts to open and unpickle the contents of filename before displaying the dialog box. When editing is complete, the method attempts to pickle the updated contents of the object back to filename. If the file referenced by filename does not exist, the object is not modified before displaying the dialog box. If filename is unspecified or None, no pickling or unpickling occurs.
If edit is True (the default), a dialog box for editing the current object is displayed. If edit is False or None, no dialog box is displayed. You can use
edit=False
if you want the object to be restored from the contents of filename, without being modified by the user.- Parameters
filename (str) –
The name (including path) of a file that contains a pickled representation of the current object. When this parameter is specified, the method reads the corresponding file (if it exists) to restore the saved values of the object’s traits before displaying them. If the user confirms the dialog box (by clicking OK), the new values are written to the file. If this parameter is not specified, the values are loaded from the in-memory object, and are not persisted when the dialog box is closed.
Deprecated since version 6.0.0.
view (View or str) – A View object (or its name) that defines a user interface for editing trait attribute values of the current object. If the view is defined as an attribute on this class, use the name of the attribute. Otherwise, use a reference to the view object. If this attribute is not specified, the View object returned by trait_view() is used.
kind (str) – The type of user interface window to create. See the traitsui.view.kind_trait trait for values and their meanings. If kind is unspecified or None, the kind attribute of the View object is used.
edit (bool) –
Indicates whether to display a user interface. If filename specifies an existing file, setting edit to False loads the saved values from that file into the object without requiring user interaction.
Deprecated since version 6.2.0.
context (object or dictionary) – A single object or a dictionary of string/object pairs, whose trait attributes are to be edited. If not specified, the current object is used
handler (Handler) – A handler object used for event handling in the dialog box. If None, the default handler for Traits UI is used.
id (str) – A unique ID for persisting preferences about this user interface, such as size and position. If not specified, no user preferences are saved.
scrollable (bool) – Indicates whether the dialog box should be scrollable. When set to True, scroll bars appear on the dialog box if it is not large enough to display all of the items in the view at one time.
- Returns
- Return type
True on success.
-
edit_traits
(*args, **kws)¶ Displays a user interface window for editing trait attribute values.
- Parameters
view (View or string) – A View object (or its name) that defines a user interface for editing trait attribute values of the current object. If the view is defined as an attribute on this class, use the name of the attribute. Otherwise, use a reference to the view object. If this attribute is not specified, the View object returned by trait_view() is used.
parent (toolkit control) – The reference to a user interface component to use as the parent window for the object’s UI window.
kind (str) – The type of user interface window to create. See the traitsui.view.kind_trait trait for values and their meanings. If kind is unspecified or None, the kind attribute of the View object is used.
context (object or dictionary) – A single object or a dictionary of string/object pairs, whose trait attributes are to be edited. If not specified, the current object is used.
handler (Handler) – A handler object used for event handling in the dialog box. If None, the default handler for Traits UI is used.
id (str) – A unique ID for persisting preferences about this user interface, such as size and position. If not specified, no user preferences are saved.
scrollable (bool) – Indicates whether the dialog box should be scrollable. When set to True, scroll bars appear on the dialog box if it is not large enough to display all of the items in the view at one time.
- Returns
- Return type
A UI object.
-
-
class
chaco.examples.demo.advanced.data_stream.
DemoHandler
¶ Bases:
traitsui.handler.Handler
-
closed
(info, is_ok)¶ Handles a dialog-based user interface being closed by the user. Overridden here to stop the timer once the window is destroyed.
-
-
class
chaco.examples.demo.advanced.data_stream.
Viewer
¶ Bases:
traits.has_traits.HasTraits
This class just contains the two data arrays that will be updated by the Controller. The visualization/editor for this class is a Chaco plot.