G'day Audar,

Welcome to the monastery.

When asking questions about Tk, please provide a short working example script that we can run. This allows us to reproduce your problem rather than guessing what all the missing code might be. Furthermore, excluding non-essential elements (such as relief, borderwidth, colours, etc.) removes a lot of noise in the code and helps us get to the heart of the problem. Also, a simple piece of ASCII-art, demonstrating the layout you're trying to achieve, is vastly superior to a textual description of what you want: "a picture paints a thousand words".

I added code to what you posted to get the GUI running. I couldn't reproduce what you described. This is the problem I already mentioned: "guessing what all the missing code might be". I can supply a few suggestions as to where you might be going wrong.

Using '-fill => 'both', -expand => 1' will tend to force elements to the centre: this may be one of your issues. See Tk::pack paying particular attention to the sections: "DESCRIPTION", "THE PACKER ALGORITHM" and 'EXPANSION". Hint: it's often useful to temporarily set different background colours (-bg option) for every widget to see exactly what space they are taking up.

The '-anchor' option is a standard widget option as well as a pack() option. I suspect you want the former: check Tk::options and Tk::pack.

Tk::Frame is not intended to be an interactive widget. From its DESCRIPTION:

"A frame is a simple widget. Its primary purpose is to act as a spacer or container for complex window layouts. The only features of a frame are its background color and an optional 3-D border to make the frame appear raised or sunken."

Tk::Pane is probably what you want for the "Scrolled('Frame' ..." code. From its DESCRIPTION:

"Tk::Pane provides a scrollable frame widget. Once created it can be treated as a frame, except it is scrollable."

While unrelated to your current problem (as far as I can tell), you really should avoid Indirect Object Syntax. Its use is strongly discouraged: see perlobj: Invoking Class Methods.

-- Ken


In reply to Re: Perl Tk - Frame packing issue by kcott
in thread Perl Tk - Frame packing issue by Audar

Title:
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, details, 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, summary, 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.