Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Tk::Gauge Module Borked?

by beretboy (Chaplain)
on Jul 06, 2005 at 15:22 UTC ( #472852=perlquestion: print w/ replies, xml ) Need Help??
beretboy has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Tk::Gauge Module Borked?
Download Code
Re: Tk::Gauge Module Borked?
by zentara (Archbishop) on Jul 06, 2005 at 16:59 UTC
    I don't know what exactly your problem is with Tk::Gauge, but does it have anything to do with
    Failed to AUTOLOAD 'Tk::Gauge::traceVdelete'
    If so, there is something in the source about that, a supplied diff file must be applied to Trace.pm, and it states it will be included in the next Tk release. Without the patch, the lines won't move.

    As far as your question about raising the line, it is usually done with tags like

    $thermo->createLine(0,0,200,200, -width => 5, -tags => ['topline'], ); # Line should go right across gauge! $thermo->raise('topline','gauge'); #where 'gauge' is supposed to be an advertised tag , but # it dosn't seem to work.
    So I guess I have to agree with you, the module is not ready for widespread use yet.

    I'm not really a human, but I play one on earth. flash japh
Re: Tk::Gauge Module Borked?
by beretboy (Chaplain) on Jul 06, 2005 at 17:12 UTC
    Yeah, I've been trying:

    $thermo->raise('needle', 'gauge');

    Both of which are advertised tags, neither of which work! Also, why doesn't this work?

    $thermo->raise('needle', 'all');


    "Sanity is the playground of the unimaginative" -Unknown
Re: Tk::Gauge Module Borked?
by Anonymous Monk on Jul 06, 2005 at 17:40 UTC
    Apply the Tk::Trace patch supplied in the Tk::Gauge package - needles will then work!

    S. Lidie

    janitored by ybiC: Linkified CPAN module name

Re: Tk::Gauge Module Borked?
by Anonymous Monk on Jul 06, 2005 at 17:52 UTC
Re: Tk::Gauge Module Borked?
by beretboy (Chaplain) on Jul 06, 2005 at 18:37 UTC
    Thank you Mr. Lidie! (The above anonymous monk is the author of the module, who I emailed earlier)


    "Sanity is the playground of the unimaginative" -Unknown
Re: Tk::Gauge Module Borked?
by zentara (Archbishop) on Jul 09, 2005 at 15:17 UTC
    Hi again, I was trying to figure out why the needles didn't show up in the Tk::Gauge examples, (and your code above). Anyways, it seems that Tk::Trace needs to be pre-loaded into Tk, before you load Tk. This is shown, but poorly described in the perldoc for Tk::Trace. Also see Simple Tk Gauge.

    Anyways, change the top of your script to this, and see the needle appear( on linux anyways).

    #!/usr/local/bin/perl -w package Tk; use Tk::Trace; package main; use Tk; use Tk::Gauge; use strict; use warnings; ...... .......

    I'm not really a human, but I play one on earth. flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://472852]
Approved by talexb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2014-09-30 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (368 votes), past polls