Version 1 of Meter Widget

Updated 2006-10-10 11:50:43

Hardware conttrol panels historically have used several types of meters. Tcl/Tk widgets have already been written for what I would call 'angular meters'. That is a meter whose needle shows the value of the data it is monitoring through it's angle. A more common meter in the control panels where I work is a 'vertical' meter. Think of this as a vertical rectangle with a tick mark scalen and a needle that shows the value of the data it is monitoring by its height in the rectangle.

Here's a snit::widget that is my first cut at implementing a 'vertical' meter (still a few edge issues with tick marks):

 #
 #    This software is Copyright by the Board of Trustees of Michigan
 #    State University (c) Copyright 2005.
 #
 #    You may use this software under the terms of the GNU public license
 #    (GPL).  The terms of this license are described at:
 #
 #     http://www.gnu.org/licenses/gpl.txt
 #
 #     Author:
 #             Ron Fox
 #            NSCL
 #            Michigan State University
 #            East Lansing, MI 48824-1321
 #

 #  Implements a 'meter' megawidget.  A meter is a
 #  box with a needle that goes up and down between
 #  two possible limits.
 #
 # This is drawn in a canvas as follows:
 #    +-------+
 #    |       |
 #    |  <----|
 #    | ...
 #    +-------+
 #
 #
 # OPTIONS:
 #    -from        - Value represented by the lower limit of the meter.  (dynamic)
 #    -to          - Value represented by the upper limit of the meter.  (dynamic)
 #    -height      - Height of the meter.                                (static)
 #    -width       - Width of the meter.                                 (static)
 #    -variable    - Variable the meter will track.                      (dynamic)
 #    -majorticks  - Interval between major (labelled) ticks.            (dynamic)
 #    -minorticks  - Number of minor ticks drawn between major ticks.    (dynamic)
 #
 # Methods:
 #    set value    - Set the meter to a specific value (if -variable is defined it is modified).
 #    get          - Returns the current value of the meter.

 package provide meter 1.0
 package require Tk
 package require snit


 namespace eval controlwidget {
    namespace export meter
 }