Home > Archive > PerlTk > March 2007 > I'm stuck on how to arrange widgets
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 |
I'm stuck on how to arrange widgets
|
|
|
|
I have a main window that I create like this:
$MW = MainWindow->new;
$MW->title("CLUSTER");
$F = $MW->Frame(
-bg => 'PeachPuff4',
-relief => 'flat',
-borderwidth => '5',
);
$F->pack;
And I am putting widgets into it with grid like this:
$Button1 = $F->Button(
-text => 'Run',
-width => 15,
-command => \&run,
-highlightbackground => 'PeachPuff4',
-bg => 'DarkOrange',
-relief => 'raised',
-takefocus => 0,
-state => 'normal'
);
$Button1->grid(-row => 1, -column => 0,);
$Button2 = $F->Button(
-text => 'Stop',
-width => 15,
-command => \&stop,
-highlightbackground => 'PeachPuff4',
-bg => 'DarkOrange',
-relief => 'raised',
-takefocus => 0,
-state => 'normal'
);
$Button2->grid(-row => 1, -column => 1,);
What I am trying to do is bundle about 10 widgets in a frame and put
that frame into $MW at grid location row => 0, -column=> 5.
How can I do this? Everything I have tried will not run.
| |
| Ch Lamprecht 2007-03-21, 7:02 pm |
| jcf wrote:
>
> I have a main window that I create like this:
>
> $MW = MainWindow->new;
> $MW->title("CLUSTER");
> $F = $MW->Frame(
> -bg => 'PeachPuff4',
> -relief => 'flat',
> -borderwidth => '5',
> );
> $F->pack;
>
> And I am putting widgets into it with grid like this:
>
> $Button1 = $F->Button(
> -text => 'Run',
> -width => 15,
> -command => \&run,
> -highlightbackground => 'PeachPuff4',
> -bg => 'DarkOrange',
> -relief => 'raised',
> -takefocus => 0,
> -state => 'normal'
> );
> $Button1->grid(-row => 1, -column => 0,);
>
> $Button2 = $F->Button(
> -text => 'Stop',
> -width => 15,
> -command => \&stop,
> -highlightbackground => 'PeachPuff4',
> -bg => 'DarkOrange',
> -relief => 'raised',
> -takefocus => 0,
> -state => 'normal'
> );
> $Button2->grid(-row => 1, -column => 1,);
>
> What I am trying to do is bundle about 10 widgets in a frame and put
> that frame into $MW at grid location row => 0, -column=> 5.
>
> How can I do this? Everything I have tried will not run.
>
Hi,
you can't. You can't pack one widget ($F) into $MW and then grid another into
the same parent.
Maybe you want to put the frame into $F ?
Christoph
my $container = $F->Frame->grid(-row => 0, -column => 5);
for (0..9){
$container->Label(-text => "widget no. $_")->pack;
}
--
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
|
|
|
|
|