[PATCH] Tk::ProgressBar -anchor

[PATCH] Tk::ProgressBar -anchor

Post by slave » Thu, 04 Dec 2003 05:22:34


In Tk::ProgressBar -anchor => "w" and -anchor => "e" work correctly
by beginning the progress bar from the left resp. right side. "n" and
"s" seem to cause the progress bar to start from the wrong side ---
here's a patch:

#### Patch data follows ####
diff -up '/usr/local/dist/cpan/build/Tk-804.025_beta6/Tk/ProgressBar.pm' '/tmp/Tk-804.025_beta6/Tk/ProgressBar.pm'
Index: ./Tk/ProgressBar.pm
--- ./Tk/ProgressBar.pm Sun Aug 24 10:50:05 2003
+++ ./Tk/ProgressBar.pm Tue Dec 2 19:06:00 2003
@@ -86,7 +86,7 @@ sub _arrange {
my $from = $c->{Configure}{'-from'};
my $to = $c->{Configure}{'-to'};
my $horz = $c->{Configure}{'-anchor'} =~ /[ew]/i ? 1 : 0;
- my $dir = $c->{Configure}{'-anchor'} =~ /[ne]/i ? -1 : 1;
+ my $dir = $c->{Configure}{'-anchor'} =~ /[se]/i ? -1 : 1;

my($minv,$maxv) = $from < $to ? ($from,$to) : ($to,$from);

#### End of Patch data ####



--
__o Slaven Rezic
_`\<,_ slaven <at> rezic <dot> de
__(_)/ (_)____
______________________________________________________________________________
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to XXXX@XXXXX.COM
 
 
 

[PATCH] Tk::ProgressBar -anchor

Post by Nick Ing-S » Mon, 08 Dec 2003 00:49:49

< XXXX@XXXXX.COM > writes:

Applied. Can you or Steve, or indeed anyone sort out the progress bar
widget demo? It seems only one of many bars moves.



-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to XXXX@XXXXX.COM

 
 
 

[PATCH] Tk::ProgressBar -anchor

Post by Ala Qumsie » Mon, 08 Dec 2003 04:53:39


I believe it's a restriction of Tk::ProgressBar that different objects
can not share the same -variable.
Anyhow, I hacked progress.pl to fix this. It is pasted below.
For future reference, what is the best way to generate patches? Any
special options to give to patch()?

--Ala

# ProgressBar - display various progress bars.

use strict;
use Tk;
use Tk::ProgressBar;
use Tk::Scale;

my $mw = MainWindow->new;

my $status_var = 0;
my @status_var;

my($fromv,$tov) = (0,100);
foreach my $loop (0..1) {
my $res = 0;
my $blks = 10;
my @p = qw(top bottom left right);
foreach my $dir (qw(n s w e)) {
$mw->ProgressBar(
-borderwidth => 2,
-relief => 'sunken',
-width => 20,
-padx => 2,
-pady => 2,
-variable => \$status_var[@status_var],
-colors => [0 => 'green', 50 => 'yellow' , 80 => 'red'],
-resolution => $res,
-blocks => $blks,
-anchor => $dir,
-from => $fromv,
-to => $tov
)->pack(
-padx => 10,
-pady => 10,
-side => pop(@p),
-fill => 'both',
-expand => 1
);
$blks = abs($blks - ($res * 2));
$res = abs(5 - $res);
}
($fromv,$tov) = ($tov,$fromv);
}

$_ = 0 for @status_var;

$mw->Scale(-from => 0, -to => 100, -variable => \$status_var,
-command => sub {
$_ = $status_var for @status_var;
})->pack;

MainLoop;
 
 
 

[PATCH] Tk::ProgressBar -anchor

Post by Slaven Rez » Mon, 08 Dec 2003 10:12:22

Nick Ing-Simmons < XXXX@XXXXX.COM > writes:


I changed the code to use Tk::Trace, and now it seems to work.

Regards,
Slaven

--- Tk-804.025_beta7-XXX/Tk/ProgressBar.pm Wed Dec 3 20:54:25 2003
+++ Tk-804.025_beta7-perl5.8.2d/Tk/ProgressBar.pm Sun Dec 7 00:28:23 2003
@@ -5,6 +5,7 @@ $VERSION = '4.008'; # $Id: //depot/Tkutf

use Tk;
use Tk::Canvas;
+use Tk::Trace;
use Carp;
use strict;

@@ -296,20 +297,20 @@ sub value {

sub variable {
my $c = shift;
- my $val = \$c->{'-variable'};
- my $old = $$val;
+ my $oldvarref = $c->{'-variable'};
+ my $oldval = $$oldvarref if $oldvarref;
if(@_) {
- my $value = shift;
- if (ref $old)
+ my $varref = shift;
+ if ($oldvarref)
{
- $c->{'-value'} = $$old;
- untie $$old if tied($$old);
+ $c->traceVdeleta($oldvarref);
}
- tie $$value,'Tk::Configure',$c,'-value';
- $$val = $value;
+ $c->{'-variable'} = $varref;
+ $c->traceVariable($varref, 'w', sub { $c->value($_[1]) });
+ $$varref = $oldval;
_layoutRequest($c,2);
}
- $old;
+ $oldval;
}

sub Destroyed


--
Slaven Rezic - XXXX@XXXXX.COM

Tk-AppMaster: a perl/Tk module launcher designed for handhelds
http://www.yqcomputer.com/
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to XXXX@XXXXX.COM