Home > Archive > PerlTk > September 2005 > bind double click to resize text widget(s)
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 |
bind double click to resize text widget(s)
|
|
| listmail@triad.rr.com 2005-09-21, 6:58 pm |
| I used the Mastering Perl Tk example to get a basis for what I'm trying
to do. The text widgets are adjustable in the sense that you can make
one smaller and the other larger by moving the adjustment bar. I'd like
to bind the mouse Double Click to resize the text widget that was
clicked larger and the other text widget a bit smaller. Basically
giving more focus to a particular text widget. I'm not able to get the
bind to work as of yet and I am not counting on my resize code to work.
use Tk;
use Tk::Adjuster;
$mw = MainWindow->new(-title => "Adjuster example");
my $frame1=$mw->Frame();
$frame1->pack();
$topw = $frame1->pack(-side => 'top', -fill => 'x');
$botw = $frame1->pack(-side => 'bottom', -fill => 'both', -expand => 1);
$topw->bind('<Double-Button-1>', \&resize(0));
$botw->bind('<Double-Button-1>', \&resize(1));
$lb = $topw->Scrolled('Text', -scrollbars => 'osoe', -height => 10)
->packAdjust(-expand => 1, -fill => 'both');
$botw->Scrolled('Text', -scrollbars => 'osoe', -height => 10)
->pack(-expand => 1, -fill => 'both');
MainLoop();
sub resize () {
my $parm = shift;
#if value is 1 (true) then botw was clicked, else topw
if ($parm) {
$topw->configure(-height=> 5);
$botw->configure(-height=> 10);
} else {
$topw->configure(-height=> 10);
$botw->configure(-height=> 5);
}
}
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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 majordomo@lists.stanford.edu
| |
| Ala Qumsieh 2005-09-21, 6:58 pm |
|
--- listmail@triad.rr.com wrote:
> $topw->bind('<Double-Button-1>', \&resize(0));
> $botw->bind('<Double-Button-1>', \&resize(1));
$topw->bind('<Double-Button-1>', [\&resize, 0]);
$botw->bind('<Double-Button-1>', [\&resize, 1]);
Check out 'perldoc Tk::callbacks' for more info.
--Ala
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.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 majordomo@lists.stanford.edu
| |
| listmail@triad.rr.com 2005-09-21, 6:58 pm |
| Thanks for the response that easily fixed the bind problem. Still not
able to make size changes through widget calls for some reason, I guess
it is something to do with pack.
use strict;
use warnings;
use Tk;
use Tk::Adjuster;
my $mw = MainWindow->new(-title => "Adjuster example");
my $frame1=$mw->Frame();
$frame1->pack();
my $topw = $frame1->pack(-side => 'top', -fill => 'x');
my $botw = $frame1->pack(-side => 'bottom', -fill => 'both', -expand =>
1);
my $tw = $topw->Scrolled('Text', -scrollbars => 'osoe', -height => 10)-
>packAdjust(-expand => 1, -fill => 'both');
my $bw = $botw->Scrolled('Text', -scrollbars => 'osoe', -height => 10)-
>pack(-expand => 1, -fill => 'both');
$tw->bind('<Double-Button-1>', [ \&resize, 0 ]);
$bw->bind('<Double-Button-1>', [ \&resize, 1 ]);
MainLoop();
sub resize () {
my $parm = shift;
if ($parm) {
#basically trying to "redraw" at this point.....
$tw->packForget;
$bw->packForget;
$tw->configure(-height=>5);
$bw->configure(-height=>15);
$tw->pack;
$bw->pack;
} else {
$tw->packForget;
$bw->packForget;
$tw->configure(-height=>15);
$bw->configure(-height=>5);
$tw->pack;
$bw->pack;
}
}
----- Original Message -----
From: Ala Qumsieh <ala_qumsieh@yahoo.com>
Date: Wednesday, September 21, 2005 3:08 pm
Subject: Re: bind double click to resize text widget(s)
>
>
> --- listmail@triad.rr.com wrote:
>
>
> $topw->bind('<Double-Button-1>', [\&resize, 0]);
> $botw->bind('<Double-Button-1>', [\&resize, 1]);
>
> Check out 'perldoc Tk::callbacks' for more info.
>
> --Ala
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.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 majordomo@lists.stanford.edu
|
|
|
|
|