Perl Tk Grid

Discussion in 'Perl Misc' started by f1crazed, Oct 8, 2009.

  1. f1crazed

    f1crazed Guest

    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
     
    f1crazed, Oct 8, 2009
    #1
    1. Advertising

  2. f1crazed

    f1crazed Guest

    On Oct 8, 7:11 pm, wrote:
    > f1crazed <> wrote in message-id:  <>
    >
    > > 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.
     
    f1crazed, Oct 9, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Girish
    Replies:
    4
    Views:
    727
    Patrick.O.Ige
    Jul 19, 2005
  2. =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?=

    How to transfer a value from an Invisible Grid to an visible Grid

    =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?=, Oct 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    486
    =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?=
    Oct 17, 2005
  3. Danny Tuppeny

    Grouped grid? Or grid within datalist?

    Danny Tuppeny, Oct 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    531
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Oct 27, 2005
  4. Marc
    Replies:
    0
    Views:
    469
  5. Simon L
    Replies:
    3
    Views:
    427
    Jeff Flinn
    Mar 31, 2006
Loading...

Share This Page