Tk::Gauge

Tk::Gauge is a Perl module that allows to create a multitude of analog gauge widgets.
Download

Tk::Gauge Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Stephen O. Lidie
  • Publisher web site:
  • http://search.cpan.org/~lusol/Tk-Gauge-0.3/Tk/Gauge.pm

Tk::Gauge Tags


Tk::Gauge Description

Tk::Gauge is a Perl module that allows to create a multitude of analog gauge widgets. SYNOPSIS use Tk::Gauge; my $g = $mw->Gauge( -option => value );This widget creates an analog gauge. A gauge has various components: a radius highlighted by a circumference, one or more needles, a hub, three granularities of tick marks, one of which has a value label, a caption, title and specialized bands that visually compartmentalize the gauge.A gauge's appearance is specified by manipulating a set of approximately 60 options, all described below. Given this flexibility one may create instruments including, but not limited to, a 12 or 24 hour clock, CPU meter, voltmeter, fuel and temperature gauge, speedometer and tachometer.The following option/value pairs are supported (default value in parentheses):-background ('white')The gauge's background color.-bands (undef)This is the gauge's band(s) descriptor. A band demarcates a section of the gauge; for instance, a tachometer usually has a red band around a portion of its circumference indicating when the engine's RPM has exceeded "redline". The value of -bands must be an array reference, with each element of the array a hash reference having key/value pairs laying out the details of one band. Other than the actual key/value pairs, the format is identical to the -needles option, and you can see samples of that in the EXAMPLES section. Here are the -bands options and their default values: { -arccolor => 'white', -minimum => 0, -maximum => 100, -piecolor => 'white', -tag => '', }-arccolor is relevant if -bandstyle => 'band', while -piecolor is relevant if -bandstyle => 'pieslice'.-minimum must be >= -from and -maximum must be = 0. See the -to option for important additional details.-hubcolor ('#ef5bef5bef5b')Color of hub.-huboutline ('#ef5bef5bef5b')Color of hub outline.-hubplace ('overneedle')The hub is normally placed over the base of the needle(s), but you may specify 'underneedle' if desired.-hubradius (5)Radius of the hub.-majortickcolor ('black')Color of the major tick marks.-majortickinterval (10)A positive integer specifying the largest interval between gauge tick marks.-majorticklabelcolor ('black')Major tick marks can be labelled with an integer value of this color.-majorticklabelfont ('Helvetica-12')A standard Tk font specification.-majorticklabelformat ('%d')A standard C language (s)printf format specification.-majorticklabelpad (10)Padding distance between the major tick label and the gauge's circumference.-majorticklabelplace ('inside')Major tick label values are normally placed inside the gauge's circumference. Specify 'outside' to place them outside the circumference.-majorticklabelscale (1)This is a multiplier that converts a gauge value to a major tick label value.-majorticklabelskip (undef)This must be an array reference - the array elements enumerate major tick label values that should NOT be displayed. These are unscaled values.-majorticklength (10)Pixel length of major tick marks.-majortickthickness (1)Pixel width of major tick marks.-margin (10)A margin surrounding all four sides of the gauge, measured in pixels.-minortickcolor ('black')Color of the minor tick marks.-minortickinterval (undef)A positive integer specifying the middle interval between gauge tick marks.-minorticklength (5)Pixel length of minor tick marks.-minortickthickness (1)Pixel width of minor tick marks.-needles ( )This is the gauge's needle(s) descriptor. A needle points to a specific gauge value, from -from to -to, by rotating around the hub of the gauge. The value of -needles must be an array reference, with each element of the array a hash reference having key/value pairs laying out the details of one needle. You can see samples of the -needles option in the EXAMPLES section. Here are the -needles options and their default values: { -arrowshape => , -color => 'black', -command => undef, -format => '%d', -radius => 96, -showvalue => 0, -tag => '', -title => '', -titlecolor => 'black', -titlefont =>'Helvetica-12', -titleplace => 'south', -variable => my $var, -width => 5, }-arrowshape describes the shape of a needle's arrow - you can model various arrow shapes by running the widget Canvas demonstration An editor for arrowheads on Canvas lines.-color is the needle's color.-command is a Perl/Tk callback that's invoked whenever the needle's -variable changes. The callback should return a true or false value: the needle is only moved if the callback returns true.-format is a standard C langauge (s)printf format specification used if -showvalue => 1 to display the needle's current value.-radius is the needle's radius.-showvalue, if true, displays the needle's current value at its tip, just outside the gauge's circumference.-tag is a string that allows you to provide one custom tag for the needle.-title is the needle's title.-titlecolor is the needle's title color.-titleplace specifies where the title is displayed relative to the hub, either 'north' or 'south'.-variable is a reference to the variable that holds the needle's current value. When the variable is written the needle moves, subject to the return value from the needle's -command callback.-width is the needle's width.-needlepad (0)The padding between the tip of a gauge's longest needle and the major tick labels.-outline ('black')The gauge's outline color.-outlinewidth (2)The pixel width of the gauge outline.-start (225)Specifies the beginning of the angular range occupied by the gauge's arc. The value is given in units of degrees measured counterclockwise from the 3-o'clock position; it may be either positive or negative.-style ('chord')A gauge is a Canvas arc item, so the -style option specifies the overall appearance of the widget. Beside the default 'chord', other possible values are 'pieslice' and 'arc'. See the Canvas documentation for more details.-to (100)The -to option seems obvious enough: it's the gauge's final value, and must be a positive integer > than -from. But this option is more complex, as it's intimately related to the fine, minor and major tick mark intervals, the major tick mark label scale value, and to the overall efficiency of the gauge.For efficiency you want to make the difference between -to and -from as small as possible. So, looping from 1 to 80 is fine, but a loop from 1 to 8,000 will be very slow and impact the startup time of your application.Now comes the hard part: specifying -from and -to to play nicely with your tick marks, of which there are three species: major, minor and fine. Essentially, since -from and -to must be positive integers, and the major, minor and fine tick intervals must be positive integers, your job is to find the integral Lowest Common Denominator (iLCD) amongst them all, and to set -majorticklabelscale accordingly.For instance, suppose you want to make a tachometer to display RPM from zero to 8,000. Do not chose -from => 0 and -to -> 8000! Slow city. If your major tick interval unit is RPM/1000, choose 1 .. 8 instead. Well, maybe.Now suppose you require a minor tick every 500 RPM. Since any tick interval must be a positive integer, make -to 80, the major tick interval 10, and the minor tick interval 5.Now suppose your PHB requires a third fine tick interval every 250 RPM. Since any tick interval must be a positive integer, make -to 800, the major tick interval 100, the minor tick interval 50, and the new, fine tick interval, 25. Finally, set the major tick label scale value to 0.01 so the displayed units are 0 .. 8. Whew.But wait, that's not the iLCD - we can divide everything by 5. So make -to 160, the major tick interval 20, the minor tick interval 10, and the new fine tick interval, 5. Finally, set the major tick label scale value to 0.05. Double whew!More simply: my $iLCD = 50; # integral Lowest Common Denominator -finetickinterval => 250 / $iLCD -from => 0 -majortickinterval => 1000 / $iLCD -majorticklabelscale => $iLCD / 1000 -minortickinterval => 500 / $iLCDAnd to scale an actual RPM value: $rpm = 1800 / $iLCD. Requirements: · Perl


Tk::Gauge Related Software