Solved

Perl/Tk resizing windows etc

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

I have the following code ...

#!/usr/bin/perl
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',
                                   -scrollbars=>'oe',
                                   )->pack(-side=>'left',-fill=>'both', -expand=>1);


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

MainLoop();

++++++++++++++++++++++++
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

Thanks,
abhijit
0
Question by:avizit
    5 Comments
     
    LVL 15

    Assisted Solution

    by:nicholassolutions
    0
     
    LVL 5

    Accepted Solution

    by:
    #! /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 );

    MainLoop();
    0
     
    LVL 11

    Author Comment

    by:avizit
    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 ,
    Abhijit

    0
     
    LVL 5

    Expert Comment

    by:ITcrow
    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.

    0
     
    LVL 11

    Author Comment

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

    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 (http://dilbert.com/strips/comic/2007-08…
    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 (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. 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