Home > Archive > PerlTk > April 2004 > How to define "-text" for two Labels in one mega-widget
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to define "-text" for two Labels in one mega-widget
|
|
| Shahriar 2004-04-16, 8:37 am |
| Hi All,
I have a simple widget, one frame with two labels in it (Label1, Label2)
I need to be able to set the "-text" for each one separately. When I try
to define "-text1" & "-text2" using ConfigSpec I get an error and every
thing
dies. How can I get this done without resorting to methods. I would like to
be -"text1" and "-text2" in the new widget.
Thanks,
-shahriar
| |
| Slaven Rezic 2004-04-17, 6:31 pm |
| "Shahriar" <shahriar_mokhtarzad@pacbell.net> writes:
> Hi All,
>
> I have a simple widget, one frame with two labels in it (Label1, Label2)
> I need to be able to set the "-text" for each one separately. When I try
> to define "-text1" & "-text2" using ConfigSpec I get an error and every
> thing
> dies. How can I get this done without resorting to methods. I would like to
> be -"text1" and "-text2" in the new widget.
>
Can you show some sample code? The general solution looks like this:
$cw->ConfigSpecs(
...
-option => [ { -optionX=>$w1, },
dbname dbclass default ],
...
);
Regards,
Slaven
--
Slaven Rezic - slaven@rezic.de
Visualize XML files in a Tk text widget:
http://search.cpan.org/search?mode=...y=Tk::XMLViewer
| |
| Shahriar 2004-04-18, 2:30 am |
| Hi Slaven,
Here is the code I was palying with. The two Label widgets ($lu & $ll) I
would like to
be able to configure both with configure unlike what I currently have ($ll
can be set via
configure but $lu is a method). The more general question I have is; If I am
using a particular
widget several times in a mega widget, Hoe can I configure them via
"configure" (How do I write the
"ConfigSpec" method.
================================== sample code
package ProgDlg;
$VERSION = "0.01" ;
use Tk::widgets qw/Frame ProgressBar Label/;
use base qw/Tk::Frame/;
use strict;
Construct Tk::Widget 'ProgDlg';
sub ClassInit {
my( $class, $mw ) = @_;
$class->SUPER::ClassInit( $mw );
}
sub Populate {
my( $self, $args ) = @_;
$self->SUPER::Populate($args);
my $c = $self->Frame->pack( -side => 'top',
-padx => 10,
-pady => 5,
-expand => 1,
-fill => 'x'
);
my $lu = $c->Label( -anchor => 'w'
)->pack( -side => 'top',
-pady => 5,
-padx => 10,
-expand => 1,
-fill => 'x'
);
my $p = $c->ProgressBar->pack( -side => 'top',
-expand => 1,
-fill => 'x'
);
my $ll = $c->Label->pack( -side => 'left',
-pady => 5,
);
$self->Advertise( 'progressbar' => $p );
$self->Advertise( 'titlebar' => $lu );
$self->ConfigSpecs
(
-title => [ qw/METHOD title Title/ ],
-text => [$ll, qw/text Text/ ],
-from => [$p, qw/from From 0/ ],
-to => [$p, qw/to To 100/ ],
-width => [$p, qw/width Width/ ],
-length => [$p, qw/length Length 200/ ],
-blocks => [$p, qw/blocks Blocks 0/ ],
-gap => [$p, qw/gap Gap/ ],
-relief => [$p, qw/relief Relief/ ],
-troughcolor => [$p, qw/troughcolor -Troughcolor/ ],
-resolution => [$p, qw/resolution Resolution/ ],
-borderwidth => [$p, qw/borderwidth Borderwidth 2/],
-highlightthickness => [$p, qw/highlightthickness Highlightthickness
2/],
-colors => [$p, qw/colors Colors/, [0, 'blue2'] ],
);
}
sub value {
my ($self, $value) = @_;
$self->Subwidget('progressbar')->value($value)
}
sub title {
my ($self, $text) = @_;
$self->Subwidget('titlebar')->configure( -text => $text );
}
Thanks
-shahriar
"Slaven Rezic" <slaven@rezic.de> wrote in message
news:87llku6zmz.fsf@vran.herceg.de...
> "Shahriar" <shahriar_mokhtarzad@pacbell.net> writes:
>
to[color=darkred]
>
> Can you show some sample code? The general solution looks like this:
>
> $cw->ConfigSpecs(
> ...
> -option => [ { -optionX=>$w1, },
> dbname dbclass default ],
> ...
> );
>
> Regards,
> Slaven
>
> --
> Slaven Rezic - slaven@rezic.de
>
> Visualize XML files in a Tk text widget:
> http://search.cpan.org/search?mode=...y=Tk::XMLViewer
| |
| Shahriar 2004-04-18, 2:30 am |
| Hi Slaven,
Yes, it works, Thanks a lot for your time.
Best Regards,
-shahriar
"Slaven Rezic" <slaven@rezic.de> wrote in message
news:87llku6zmz.fsf@vran.herceg.de...
> "Shahriar" <shahriar_mokhtarzad@pacbell.net> writes:
>
to[color=darkred]
>
> Can you show some sample code? The general solution looks like this:
>
> $cw->ConfigSpecs(
> ...
> -option => [ { -optionX=>$w1, },
> dbname dbclass default ],
> ...
> );
>
> Regards,
> Slaven
>
> --
> Slaven Rezic - slaven@rezic.de
>
> Visualize XML files in a Tk text widget:
> http://search.cpan.org/search?mode=...y=Tk::XMLViewer
|
|
|
|
|