pashanoid has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Gauge; #use Tk::Canvas; use utf8; my $mw = MainWindow->new; $mw->geometry("600x400"); $mw->configure( -background=>'black' ); $mw->title("map voltmeter"); $mw->optionAdd("*font", "*utf-8"); my $Vdc; $Vdc = 125; my $voltmeter = $mw->Gauge( -highlightbackground => 'black', -highlightcolor => 'black', -highlightthickness => 0, -background => 'black', -start => -180, -extent => -180, -style => 'arc',#'pieslice', -margin => '35', -outlinewidth => 3, -outline => '#10f0f0', -from => 90, -to => 150, -huboutline => '#10f0f0', -hubcolor => '#688898', -hubradius => 7, -hubplace => 'overneedle', -majortickcolor => '#10f0f0', -majortickthickness => 3, -majortickinterval => 10, -minortickinterval => '2', -minortickthickness => 3, -minortickcolor => '#10f0f0', -majorticklabelscale => 10.0 / 100.0, #12.0 / 60.0, -bands => [ { -tag=>'fatred', -arccolor => 'orangered2', -minimum => 140 +, -maximum => 150, -bandwidth => 9, }, ], -bandwidth => 9, -needles => [ { -arrowshape => [ 6, 6, 0 ], -color => 'orangered2', -command => undef, -command => undef, -format => '%d', #-radius => 206, -tag => '', #-titlecolor => 'blue', #-titlefont => 'Helvetica-42', -radius => 190, -variable => \$Vdc, -showvalue => 0, -width => 3, }, ] , -needlepad => 25, )->place(-x => 50, -y => 50); my $Vdc_lcd; #my $label_text = "МАП SIN\nЭНЕ +056;ЕРГИЯ"; $mw->Label(-text => 'МАП SIN', -font => [-family => 'nimbus sans l', -size => '12', -weight => 'b +old'], -foreground=> '#688898', -background => 'black', )->place( -x => 263, -y => 210 ); $mw->Label( -text => 'Энергия', -font => [-family => 'nimbus sans l', -size => '11', -weight => 'b +old'], -foreground=> '#688898', -background => 'black', )->place( -x => 266, -y => 245 ); $mw->Label( -textvariable => \$Vdc_lcd, -font => ['Helvetica','20'], -foreground=> '#10f0f0', -background => 'black')->place(-x => 5, -y => 5); #$mw -> repeat(500, sub{&movement}); $mw -> repeat(500, sub{&movement}); MainLoop; sub movement { my $range = 10; my $random_number = int(rand($range)); if ($random_number >= 5){ $Vdc++; } else { $Vdc--; } $Vdc = 125 if ($Vdc >=150 || $Vdc <=1); #for gauge purposes $Vdc_lcd = $Vdc/10; $Vdc_lcd = sprintf("%2.1f", $Vdc_lcd); $Vdc_lcd = $Vdc_lcd.' B'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: client wants a pretty gauge from Tk::Gauge
by Sinistral (Monsignor) on May 31, 2011 at 20:18 UTC | |
by pashanoid (Scribe) on May 31, 2011 at 20:37 UTC | |
by zentara (Cardinal) on Jun 01, 2011 at 14:02 UTC |