Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

displaying text into a progressbar
Hello, how can I display text in the middle of the progressbar. I'd like to
display the current value of the progress bar in percent. I created a text
widget into a progress bar widget but this solution is not satisfiable to
me.

In this solution the text widget has (of course) its own color. It would
be better if the text widget would have the color of the progressbar
widget.

The best way would be an text option for the progressbar or a corresponding
method. But I assume there isn't one.

--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/m2/

Report this thread to moderator Post Follow-up to this message
Old Post
Andre Bartsch
11-26-04 02:02 PM


Re: displaying text into a progressbar
On Fri, 26 Nov 2004 11:26:05 +0100, "Andre Bartsch"
<andre.bartsch@siemens.com> wrote:

>Hello, how can I display text in the middle of the progressbar. I'd like to
>display the current value of the progress bar in percent. I created a text
>widget into a progress bar widget but this solution is not satisfiable to
>me.
>
>In this solution the text widget has (of course) its own color. It would
>be better if the text widget would have the color of the progressbar
>widget.
>
>The best way would be an text option for the progressbar or a corresponding
>method. But I assume there isn't one.

Your best bet is just to put a label above or below the actual
progressbar, and display the text percentage. If you pack them right
they will look like a composite widget. :-)  Or you could try to
make a Derived widget, it shouldn't be too hard.

Look at Tk::ActivityBar, it is already a Derived Progressbar, you could
hack it to include a Label in it.

Otherwise:

#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::ProgressBar;

my $mw = MainWindow->new();

my $pf = $mw->Frame()->pack();

my $p = $pf->ProgressBar(
-troughcolor => 'black',
-fg       => 'lightgreen',
-blocks   => 1,
-width    => 20,
-length   => 200,
-from     => 0,
-to       => 100,
-variable => \( my $foo ),
)->pack(-side =>'right');

my $l1 = $pf->Label(-text => '%',
-bg       => 'black',
-fg       => 'green',
)->pack(-side => 'right');

my $l2 = $pf->Label(-textvariable => \$foo,
-bg       => 'black',
-fg       => 'green',
-width => 3,
)->pack(-side => 'right');

$mw->Button( -text => 'Quit',
-command => sub { exit }
)->pack;


$foo = 0;
$mw->repeat( 100, sub { $foo = ( $foo + 1 ) % 100 } );

MainLoop;
__END__


--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html

Report this thread to moderator Post Follow-up to this message
Old Post
zentara
11-26-04 09:08 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:43 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.