mmartin has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I'm using perl's Gtk2 class for the first time and I'm having a bit of difficulty figuring out how the heck those
options work for attaching an object to a table.

I found a couple different sites that "try" to explain what each option is, but it really doesn't make much sense to me
and every site I found say the EXACT same thing, almost word-for-word, so it really isn't helpful...

I know the format of attaching a "widget/object" to the table is like so:
### ATTACHING TO A "TABLE": $table->attach( $child, $table->attach_defaults( $child, $left_attach, $left_attach, $right_attach, $right_attach, $top_attach, --OR-- $top_attach, $bottom_attach, $bottom_attach); $xoptions, $yoptions, $xpadding, $ypadding );
So in the explanations I found they say the left/right_attach are for where to place the object in the table so if my table
looks like this:
+-----+-----+ | | | +-----+-----+ | | | +-----+-----+
I was under the assumption, and according to the explanations I found, the first 2 options after the $child object are for where I
want to place the object within the table. So if I wanted my $button in the top left quadrant I would do:
$button->attach_defaults($button, 0, 0, ?, ?);
But that will just throw an error saying something like; "assertion 'left_attach < right_attach' failed at ...."


Would it be possible if someone could explain to me what exactly each one of those options actually do?
I'm really confused about the left/right/top/bottom_attach options will actually do..??

Any suggestions/explanations would be greatly appreciated!


Thanks in Advance,
Matt


Replies are listed 'Best First'.
Re: Perl Gtk2 Table's Attach method
by mmartin (Monk) on Jun 21, 2013 at 17:53 UTC
    Ok, I think I figured it out...!!


    Let me know if this is NOT correct.
    Say you have the following Table Grid:
    0,0 +------+------+------+ | | | | +------+------+------+ | | | | +------+------+------+ | | | | +------+------+------+ 3,3
    So Lets say I want a Label to span the entire top row, I think I would do the following:
    # ($widget, LEFT, RIGHT, TOP, BOTTOM) $tabel->attach_defaults($title_label, 0, 3, 0, 1)

    And they way I think of it is like this:
    ### So each 'corner' of the object I'm attaching has coordinates # like so, in which you just plug in the numbers left to right # into the "attach_defaults" method: #-------------------------------------------------------------- TOP-LEFT --> 0,0 TOP-RIGHT --> 3,0 BOTTOM-LEFT --> 0,1 BOTTOM-RIGHT --> 3,1 #--------------------------------------------------------------

    So, does that sound like I got it...?


    Thanks Again,
    Matt