For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > October 2007 > a question about Text-Widget and grid









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 a question about Text-Widget and grid
Pit

2007-10-24, 8:03 am

Hi Folks,

I've a question about using the Text-Widget in collaboration with the grid
geometry manager.

When using a Text-Widget with place, the size of the Text-Widget fits if
the window size is changed by user.

How to achieve the same effect, if the grid geometry manager is used.

Thanks
Pit

--
Message posted using http://www.talkaboutprogramming.com...p.lang.perl.tk/
More information at http://www.talkaboutprogramming.com/faq.html

Marc Dashevsky

2007-10-24, 8:03 am

In article < dd2a70a4b9d86eac80009c577c0e158e@localho
st.talkaboutprogramming.com>,
pharrendorf@am-soft.de says...
> Hi Folks,
>
> I've a question about using the Text-Widget in collaboration with the grid
> geometry manager.
>
> When using a Text-Widget with place, the size of the Text-Widget fits if
> the window size is changed by user.
>
> How to achieve the same effect, if the grid geometry manager is used.


Read about the -sticky option in the grid pod.

--
Go to http://MarcDashevsky.com to send me e-mail.
Pit

2007-10-24, 7:08 pm

Thanks for answer, but I' cant find any solution with the -sticky option.

Please run my little script and watch for the reaction of both
text-widgets when you change the window size

#!/usr/bin/perl5 -w

use strict;
use Tk;
use Tk::Text;

my $top = MainWindow->new;
my $frameo = $top->Frame(-relief => 'ridge',
-bd => 2,
)->pack(-side => 'top',
-anchor => 'nw',
-fill => 'both',
-expand => 1);

my $frameu = $top->Frame(-relief => 'ridge',
-bd => 2,
)->pack(-side => 'top',
-anchor => 'nw',
-fill => 'both',
-expand => 1);

$frameo->Label(-text => 'pack')->pack();
my $text1 = $frameo->Text(-height => 10,
-width => 50,
)->pack();


$frameu->Label(-text => 'grid')->grid(-row => 0, -column => 0, -sticky =>
'w');

my $text2 = $frameu->Text(-height => 10,
-width => 50,
)->grid(-row => 1, -column => 0, -sticky => 'w');

$text1->insert("end",
" AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
$text2->insert("end",
" AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
MainLoop;

Thanks
Pit


--
Message posted using http://www.talkaboutprogramming.com...p.lang.perl.tk/
More information at http://www.talkaboutprogramming.com/faq.html

Ch Lamprecht

2007-10-24, 7:08 pm

Pit schrieb:
> Thanks for answer, but I' cant find any solution with the -sticky option.
>
> Please run my little script and watch for the reaction of both
> text-widgets when you change the window size
>
> #!/usr/bin/perl5 -w
>
> use strict;
> use Tk;
> use Tk::Text;
>
> my $top = MainWindow->new;
> my $frameo = $top->Frame(-relief => 'ridge',
> -bd => 2,
> )->pack(-side => 'top',
> -anchor => 'nw',
> -fill => 'both',
> -expand => 1);
>
> my $frameu = $top->Frame(-relief => 'ridge',
> -bd => 2,
> )->pack(-side => 'top',
> -anchor => 'nw',
> -fill => 'both',
> -expand => 1);
>
> $frameo->Label(-text => 'pack')->pack();
> my $text1 = $frameo->Text(-height => 10,
> -width => 50,
> )->pack();
>
>
> $frameu->Label(-text => 'grid')->grid(-row => 0, -column => 0, -sticky =>
> 'w');
>
> my $text2 = $frameu->Text(-height => 10,
> -width => 50,
> )->grid(-row => 1, -column => 0, -sticky => 'w');
>


$frameu->gridColumnconfigure(0, -weight => 1);


> $text1->insert("end",
> " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
> $text2->insert("end",
> " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
> MainLoop;
>
> Thanks
> Pit
>
>
> --
> Message posted using http://www.talkaboutprogramming.com...p.lang.perl.tk/
> More information at http://www.talkaboutprogramming.com/faq.html
>

HTH, Christoph

--
use Tk;use Tk::GraphItems;$c=tkinit->Canvas->pack;push@i,Tk::GraphItems->
TextBox(text=>$_,canvas=>$c,x=>$x+=70,y=>100)for(Just=>another=>Perl=>Hacker);
Tk::GraphItems->Connector(source=>$i[$_],target=>$i[$_+1])for(0..2);
$c->repeat(30,sub{$_->move(0,4*cos($d+=3.16))for(@i)});MainLoop
Pit

2007-10-25, 8:03 am

Works great

Thanks a lot

Pit

--
Message posted using http://www.talkaboutprogramming.com...p.lang.perl.tk/
More information at http://www.talkaboutprogramming.com/faq.html

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com