/ . / CGLtk / Histogram.py / MarkedHistogram
Histogram with color-indication markers
MarkedHistogram shows a histogram of a data set and an optional
label for the numeric range of the data set. Color markers can
be placed on the histogram by the user and moved interactively,
either with the mouse or by typing in a particular data value.
A color well is used to control the color of the "current" marker
(the one most recently selected with the mouse). Markers can
either be vertical bars or squares. Vertical bars can only be
moved left/right whereas squares can also be moved up/down.
Squares are also connected from left to right by line segments.
A row of associated widgets (such as the marker color well) is
placed below the histogram. User-specified widgets can also be
placed in this row.
Individual markers are grouped into HistogramMarkers instances,
and several HistogramMarkers instances can be associated with
a single histogram, though only one instance is active/shown at
a time.
MarkedHistogram has the following options:
[Options noted as init options can only be specified at
widget creation. Others can be changed later with the
config() method.]
- colorwell
- controls whether a color well is offered in
the user interface for changing marker colors.
default: True
- datasource
- either a string or a 3-tuple. If a string, then
no histogram is displayed and instead the string is
displayed in the histogram area as a text message.
The first 2 components of a 3-tuple should be the
minimum and maximum values of the histogram, The
third component should either be an array of numbers
(i.e. the histogram) or a callback function that
takes as its single argument the number of bins to
histogram into and that returns a histogram array.
default:
no data
- labelmargin
- [init option] if a label is associated with
the widget (i.e. labelpos is not None) then this
is the distance between the label component and the
rest of the megawidget.
default: 0
- labelpos
- [init option] where the megawidget label should
be placed. Some combination of
nsew . Use the
label_text option to specify the label text.
default: None
- layout
- [init option] how to organize the megawidget layout.
Choices are
single , top , and below . single
should be used when you are using a single histogram
in your GUI, or histograms that aren't arrayed
vertically. top and below should be used for
histograms that are laid out in a vertical array
(top for the top-most one, and below for all
others). Certain repeated elements will be omitted
in below histograms (e.g. some widget labels).
default: single
maxlabel/minlabel [init options] show the max/min histogram
values as labels below the histogram on the right/left.
If neither is True, then the range will be shown in a
single label widget below the histogram.
default: False
- redrawdelay
- amount of time (in seconds) to delay between
needing to redraw and actually starting to redraw.
Used to avoid multiple (possibly slow) redraws during
a resize.
default: 0.25
- scaling
- how to scale the vertical height of the histogram.
Either
logarithmic or linear .
default: logarithmic
- selectcallback
- [init option] function to call when the
"current" marker changes. The function receives 4
argments: previous active marker set/marker,
new active marker set/marker. The marker set can
be None to indicate no active marker set and the
marker can be None if no marker was/is current.
- showmarkerhelp
- [init option] whether to show the help
text over the histogram describing how to add/delete
markers.
default: True
- statusline
- function to use to output messages (such as
warning when trying to add more markers than allowed).
The function should take a single string argument.
default: None
- valuelabel
- [init option] label to use next to the
entry widget describing the current marker value.
default:
Value
- valuewidth
- width of the current marker value entry widget.
default: 6
- widgetreserve
- [init option] number of columns to reserve
for user widgets on the left side of the below-
histogram row of widgets.
default: 0
The dynamic group Markers can be used to specify default
values for options for use during HistogramMarkers construction
(e.g. Markers_connectcolor = red ). Options for specific instances
can be provided to the addmarkers() method as keyword arguments
(without the Markers_ prefix).
A MarkedHistogram instance has the following components:
- canvas
- the canvas used to draw the histgram/markers
- markerhelp
- only created if
showmarkerhelp is True and
layout is not below . The label above the
histogram displaying the help text describing how
to add/delete markers.
- minlabel/maxlabel
- labels used if
minlabel /maxlabel
are True
- nodatalabel
- the label used when the
datasource option
is a string
- widgetframe
- the frame used to contain the below-histogram
widgets. If
widgetreserve is not zero, you can
grid your own widgets into the left of this frame
used the reserved columns. You can always grid into
the right of this frame by using the frame's grid_size
method to find the last used column. Widgets are always gridded into row 1. If layout is
single , labels should also be gridded into row 1.
If layout is top , labels should be gridded into
row 0. If layout is below , labels should be omitted.
Methods
|
|
|
activate
|
activate ( self, markers )
Make the given set of markers the currently active set
Any previously-active set will be hidden.
Exceptions
|
|
ValueError, "activate() called with bad value"
|
|
|
currentmarkerinfo
|
currentmarkerinfo ( self )
Identify the marker currently selected by the user.
Returns a HistogramMarkers instance and a marker.
The instance will be None if no marker set has been
activated. The marker will be None if no marker has
been selected by the user.
|
|
deletemarkers
|
deletemarkers ( self, markers )
Delete the given set of markers.
If the markers were active, there will be no active set
of markers afterward.
|
|
__init__
|
__init__ (
self,
parent=None,
**kw,
)
|
|
addmarkers
|
addmarkers (
self,
activate=True,
**kw,
)
Create and return a new set of markers.
If activate is true, the new set will also become
the active set. Other keyword arguments will be passed
to the HistogramMarkers constructor.
|
|
|