Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl Tk Grid

Reply
Thread Tools

Perl Tk Grid

 
 
f1crazed
Guest
Posts: n/a
 
      10-08-2009
Hello,

I am new to using tk and perl. What I am trying to do below is just
get the label and text boxes to line up on the left side and top of
the mainwindow. It seems that there is some kind of padding on the
left side and top of the window that won't allow me to put widgets all
the way on the left and top of the window.

Here is the code:

#!/usr/bin/perl -w
use Tk;
use strict;

my $mw = new MainWindow(); # Main Window
$mw->geometry("400x200+500+400");
$mw->title("Learning Grid");

$mw -> Label(-text=> "hello") -> grid(-row=>0, -column=>0, -sticky =>
'w', );
my $txt = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>2, -
column=>0, -sticky => 'w') ;
my $txt2 = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>3, -
column=>0, -sticky => 'w');

MainLoop;

Thanks for any help!
-JD
 
Reply With Quote
 
 
 
 
f1crazed
Guest
Posts: n/a
 
      10-09-2009
On Oct 8, 7:11*pm, (E-Mail Removed) wrote:
> f1crazed <(E-Mail Removed)> wrote in message-id: *<(E-Mail Removed)>
>
> > Hello,

>
> > I am new to using tk and perl. What I am trying to do below is just
> > get the label and text boxes to line up on the left side and top of
> > the mainwindow. *It seems that there is some kind of padding on the
> > left side and top of the window that won't allow me to put widgets all
> > the way on the left and top of the window.

>
> > Here is the code:

>
> > #!/usr/bin/perl -w
> > use Tk;
> > use strict;

>
> > my $mw = new MainWindow(); # Main Window
> > $mw->geometry("400x200+500+400");
> > $mw->title("Learning Grid");

>
> > $mw -> Label(-text=> "hello") -> grid(-row=>0, -column=>0, -sticky =>
> > 'w', );
> > my $txt = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>2, -
> > column=>0, -sticky => 'w') ;
> > my $txt2 = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>3, -
> > column=>0, -sticky => 'w');

>
> > MainLoop;

>
> > Thanks for any help!
> > -JD

>
> You need to define 'weight' for your rows and columns.
> See the gridRowconfigure and gridColumnconfigure statements below.
>
> Also, it is a good idea to put your widgets into a frame rather
> than directly into the MainWindow.
>
> #!/usr/bin/perl -w
> use Tk;
> use strict;
>
> my $mw = new MainWindow(); # Main Window
> $mw->geometry("400x200+500+400");
> $mw->title("Learning Grid");
> $mw->gridRowconfigure(4, -weight => 1,);
> $mw->gridColumnconfigure(1, -weight => 1,);
>
> $mw -> Label(-text=> "hello") -> grid(-row=>0, -column=>0, -sticky =>
> 'w', );
> my $txt = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>2, -
> column=>0, -sticky => 'w') ;
> my $txt2 = $mw-> Text(-width=>20, -height=>1)-> grid(-row=>3, -
> column=>0, -sticky => 'w');
>
> MainLoop;


Thanks q! That did the trick.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need a container to hold grid positions and the objects on the grid? Simon L C++ 3 03-31-2006 03:38 PM
Grouped grid? Or grid within datalist? Danny Tuppeny ASP .Net 1 10-27-2005 10:03 PM
How to transfer a value from an Invisible Grid to an visible Grid =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?= ASP .Net 2 10-17-2005 03:56 AM
Grid within a Grid ItemDataBound event problem Girish ASP .Net 4 07-19-2005 01:17 AM
Grid question: How do I force grid elements to expand and use available space Marc Python 0 10-08-2003 05:06 PM



Advertisments