The
Tk::Gauge module generates all manner of gee-whiz analog graphs. Sadly, as far as I can tell, this is all it's doing at the moment. Repeated attemps to have it draw a needle on said graphs have failed. Having run several of
the example scripts to no avail, I asked monks on the CB and
bart confirmed my results.
What I've found is that if I try to graph my own needle, using Tk::Canvas (of which Tk::Gauge is a MegaWidget) methods, the line is drawn "behind" the Gauge. I expect this is what's happening to the lines the module draws as well.
So the question is, how do I bring lines I draw to the foreground, and is the Tk::Gauge module really broken?
Example code can be found in the link above, and below I will include my code that draws a line "behind" the gauge (based on the thermometer example).
#!/usr/local/bin/perl -w
use Tk;
use Tk::Gauge;
use strict;
use warnings;
my $mw = MainWindow->new;
our($temperature);
my $thermo = $mw->Gauge(
-from => -20,
-to => 40,
-huboutline => 'red',
-majorticklabelskip => [-20,40],
-minortickinterval => 5,
-finetickinterval => 1,
-style => 'pieslice',
-margin => 20,
-bandwidth => 5,
-bands => [
{
-minimum => -20,
-maximum => -5,
-arccolor => '#aa00aa',
},
{
-minimum => -5,
-maximum => 5,
-arccolor => '#0000ff',
},
{
-minimum => 5,
-maximum => 15,
-arccolor => '#00ff00',
},
{
-minimum => 15,
-maximum => 25,
-arccolor => '#ffff00',
},
{
-minimum => 25,
-maximum => 35,
-arccolor => '#ff8800',
},
{
-minimum => 35,
-maximum => 40,
-arccolor => '#ff0000',
},
],
-needles =>[
{
-arrowshape => [0,0,0],
-radius => 60,
-variable => \$temperature,
-color => 'black',
-width => 2,
-showvalue => 1,
-format => '%.1f C',
},
],
)->pack;
$mw->after( 1000, sub{ $temperature = 18.2 } );
$thermo->createLine(0,0,200,200, -width => 5); # Line should go right
+across gauge!
MainLoop;
"Sanity is the playground of the unimaginative"
-Unknown
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.