Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I started using pack because in most documentation said it's the simplest geometry manager. Honestly at the beginning I felt like a daunting task, but with practice I managed to produce the results I wanted.
Besides taking care of which side you "stack" your widgets, I found that the most important thing with pack is the order in which you place your widgets. For example, I wanted to put several checkbuttons one after the other horizontally. Then I wanted a button just below these checkbuttons. However, after minutes of trial and error I found that the code for the button should go first than the checkbuttons. Here is a snapshot of the code:

#!/usr/perl/bin/perl use Tk; use warnings; use strict; my ($search, $mw, $entry, $text, $io, $checks); my $id = 0; $mw = MainWindow -> new; $mw -> title("AIM"); $mw -> bind('<Key-Escape>' => sub { exit } ); #**************** text ************************* my $scrollbar = $mw->Scrollbar( ); $scrollbar->pack(-side => 'right', -fill => 'y'); $text = $mw -> Text(-font=>"{Verdana} 10 {bold}", -width => 50, -heigh +t => 25, , -yscrollcommand => ['set' => $scrollbar]) -> pack(-side=>'right'); $scrollbar->configure(-command => ['yview' => $text]); #**************** entry ************************* $entry = $mw -> Entry(-font=>"{Verdana} 10 {bold}", -textvariable => \ +$search) -> pack(-side=>'top'); $entry -> bind('<Key-Return>' => \&search ); $entry -> focus; #**************** button ************************* my $btn_clip = $mw -> Button(-text=>"Copy to Clipboard", -command=>sub {$text->clipboardAppend($text->get( +"1.0", 'end'));}) ->pack(-side=>'bottom', -expand=>'1', -anchor=>'n +w'); #*********** checkbutton ************************* foreach (qw/address telephone keyword all/) { $checks = $mw -> Checkbutton( -text => $_) -> pack(-side=>'lef +t', -anchor=>'n'); } MainLoop;
Hope this helps...!!!!

In reply to Re: Tk: pack, grid or place? by milarepa
in thread Tk: pack, grid or place? by davies

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [LanX]: "DH" eq "Dumb Homies "?
    [shmem]: no, no previous, and python just accepts that.
    [LanX]: HA ... fun! =)
    [LanX]: Py2 or 3 ?
    [shmem]: moment... lemme see...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (12)
    As of 2018-03-20 18:26 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (257 votes). Check out past polls.