Perl/Tk resizing windows etc

Posted on 2004-11-01
Last Modified: 2008-01-09
I have just started trying to learn perl/tk

I have the following code ...

require Tk;
use Tk;
my $main = MainWindow->new();

my $lr_frame = $main->Frame(-background=>'cyan')->pack(-side=>'top',-fill=>'both');

my $left_box = $lr_frame->Scrolled('Text',
                                   )->pack(-side=>'left',-fill=>'both', -expand=>1);

my $right_box = $lr_frame->Scrolled('Text',
                                   )->pack(-side=>'left', -fill=>'both',  -expand=>1);


so basically when I run the above  I get two textbox .. which does look as if both has 50% of the window share ..
but when I maximize the window it doesnt look like that one textbox is larger than the other ..How can I ensure that both textboxes are of the same size ?

also any pointers/urls to good online perl/Tk tutorials  would be appreciated

Question by:avizit
    LVL 15

    Assisted Solution

    LVL 5

    Accepted Solution

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

    my $main = MainWindow->new();

    my $lr_frame = $main->Frame(-background=>'cyan')->pack(-side=>'top',-fill=>'both');

    my $left_box = $lr_frame->Scrolled('Text', -scrollbars=>'oe',);
    my $right_box = $lr_frame->Scrolled('Text', -scrollbars=>'oe',);

    # Use Grid
    $left_box->grid( -in => $lr_frame, -row=>1,-column => '1', -sticky => 'nesw' );
    $right_box->grid( -in => $lr_frame, -row=>1,-column => '2', -sticky => 'nesw' );

    $lr_frame->gridRowconfigure(1, -weight=>1, -minsize =>50 );
    $lr_frame->gridColumnconfigure(1, -weight=>1, -minsize =>50 );
    $lr_frame->gridColumnconfigure(2, -weight=>1, -minsize =>50 );

    LVL 11

    Author Comment

    Thanks for the links nicholassolutions
    ITcrow , your solution works fine , but any idea if the same can be done using "pack" . I will wait for a day more if any more suggestions comes , else I will split the points amongts you two.

    Thanks ,

    LVL 5

    Expert Comment

    Hello Abhi,

    Pack doesn't really give very well defined mechanism to get full control on GUI. The method I proposed gives you full control on how and where you want to place your GUI elements.

    LVL 11

    Author Comment

    Thanks ITcrow , seems like now i have to start looking at grids ..luckily i have just started .. so not much harm done :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    877 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now