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

In reply to Tk::Gauge Module Borked? by beretboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.