Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Tk::Gauge errors

by Khen1950fx (Canon)
on Aug 06, 2012 at 04:43 UTC ( #985597=note: print w/ replies, xml ) Need Help??


in reply to Tk::Gauge errors

Take a closer look at your first subroutine. Make sure that you declare your variables. So, fixed:

sub button3_sub { my $mh = ( 35 + ( 29 - 1 ) * 6 ); my $cur = $mh; }
As for the rest, I couldn't reproduce your problem. This worked for me.
#!/usr/bin/perl use strict; use autodie; use warnings; use Tk; use Tk::Table; use Tk::Gauge; my $mw = MainWindow->new; $mw->geometry("75x75"); $mw->title("Gauge testing"); my $button = $mw->Button( -text => "Null", -command => \&button3_sub ) ->pack( -anchor => 'center' ); my ( $alpha, $alphaone, $beta, $betaone, $mh, $output_text, $gaugevar, + $cur ); sub button3_sub { my $mh = ( 35 + ( 29 - 1 ) * 6 ); my $cur = $mh; my $hw = $mw->Toplevel; $hw->geometry("650x450"); $hw->title('Health Track (!!!WARNING:DO NOT EXIT THIS WINDOW UNTIL + DONE)'); my $hf = $hw->Frame( -background => 'white' ) ->pack( -ipadx => 250, -fill => 'both', -expand => 'yes' ); my $left_frame = $hf->Frame( -background => 'white' ) ->pack( -side => 'left', -fill => 'y' ); my $right_frame = $hf->Frame( -background => 'white' ) ->pack( -ipadx => 150, -fill => 'y', -anchor => 'n', -expand => +1 ); $betaone = $left_frame->Entry( -background => "green", )->pack( -anchor => +'nw' ); my $beta_button = $left_frame->Button( -text => "Alpha Null", -command => \&update +_output ) ->pack( -anchor => 'nw' ); $alphaone = $left_frame->Entry( -background => "red", )->pack( -anchor => 'n +w' ); my $alpha_button = $left_frame->Button( -text => "Alpha Null", -command => \&update +_output ) ->pack( -anchor => 'nw' ); $output_text = $left_frame->Text( -height => 5, -width => 15 )->pack( -expand = +> 0, ); my $gauge = $right_frame->Gauge( -background => 'white', -bands => [ { -piecolor => 'green', -minimum => 50, -maximum => 100, -tag => 'Healthy', }, { -piecolor => 'yellow', -minimum => 25, -maximum => 50, -tag => 'Bloodied', }, { -piecolor => 'red', -minimum => 0, -maximum => 25, -tag => 'Critical', } ], -bandplace => 'underticks', -bandstyle => 'pieslice', -bandwidth => 0, -caption => 'Current Value', -captioncolor => 'black', -extent => -180, -from => 0, -hubcolor => 'black', -huboutline => 'blue', -hubradius => 15, -majortickinterval => 10, -majorticklabelplace => 'outside', -finetickinterval => 1, -minortickinterval => 5, -margin => 40, -needles => [ { -arrowshape => [ 12, 23, 6 ], -color => 'black', -command => undef, -format => '%d', -radius => 196, -showvalue => 1, -tag => 'null', -title => 'null', -titlecolor => 'white', -titlefont => 'Helvetica-12', -titleplace => 'south', -variable => \$gaugevar, -width => 5, } ], -start => 180, -to => 100, )->pack( -fill => 'both', -expand => 1 ); } sub gaugebutton1_sub { $gaugevar = ( $cur / $mh ) * 100; } sub update_output { my $beta = $betaone->get(); my $alpja = $alphaone->get(); if ( $alpha eq "" ) { $alpha = 0; } if ( $beta eq "" ) { $beta = 0; } $cur = $cur + $beta - $alpha; if ( $cur gt $mh ) { $cur = $mh; } if ( $cur lt 0 ) { $cur = 0; } my $output = "Current value:\n$cur"; $output_text->delete( '0.0', 'end' ); $output_text->insert( "end", $output ); $betaone->delete( '0.0', 'end' ); $alphaone->delete( '0.0', 'end' ); $gaugevar = ( $cur / $mh ) * 100; } MainLoop;


Comment on Re: Tk::Gauge errors
Select or Download Code
Re^2: Tk::Gauge errors
by Anonymous Monk on Aug 06, 2012 at 07:21 UTC

    Even with the fixed code you provided, I'm still getting the exact same error messages. Could it be a system-specific error? Beyond that, any ideas on how to possibly fix it? I recently compiled 5.16.0 on my computer, so if I insert 'require 5.16.0' after the Tk modules, I get an entirely different error of:

    Perl v5.16.0 required--this is only v5.12.4, stopped at gaugetest2 lin +e 10.

    If I can fix that, is there a chance it'd fix the errors I'm getting?

      Yes, that would fix it, chances are that one of the modules has a use v5.16.0 declaration, so anything less will crash it

      --linuxkid


      imrunningoutofideas.co.cc

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2015-07-03 11:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls