http://qs321.pair.com?node_id=1108239


in reply to Usefulness of -in option in Geometry Management (Perl/Tk)

Tk apparently has two separate hierarchies, parent/child and master/slave. And in my vague and limited understanding, the first controls stacking order and the second controls geometry (screen space). So taking a wild guess here, trying to repack a button with first tab parent into a second tab, changes the geometry but not the parent/child relationship -- meaning the stacking wouldn't work. Take that with a grain of salt, but if you change your button to be a child of the main window, your code works:

my $t_button = $mw->Button(-text=>'OK', -command=>sub{exit});

Replies are listed 'Best First'.
Re^2: Usefulness of -in option in Geometry Management (Perl/Tk)
by Anonymous Monk on Nov 24, 2014 at 18:56 UTC
    Hello Loops,

          Thanks a lot for your swift response and insight. I also read through another response from AM. Just to make sure I understand this correctly,
    1. A parent/child hierarchy is established at the creation phase of objects. For ex:
      my $t_button = $mw->Button(-text=>'OK', -command=>sub{exit});
      This makes the object pointed to by $t_button a child of the object pointed to by $mw.

    2. A master/slave hierarchy is established by the geometry manager used(such as grid, pack, form, place).

    3. When displaying a widget, if the -in option is not at all used then the master/slave hierarchy is exactly the same as parent/child hierarchy.

    If this understanding of mine is correct, then I proceed to a portion of your next statement:
    • ....trying to repack a button with first tab parent into a second tab, changes the geometry...

    • This, I believe, you meant that the pack geometry manager attempts to pack first tab inside the second tab of the same NoteBook. This of-course is not permitted, after all every tab of any given NoteBook must NOT ONLY be a direct child BUT ALSO a direct slave under that NoteBook
    • ...but not the parent/child relationship -- meaning the stacking wouldn't work.
      This I didn't understand, honestly. So please let me know.

    Moving on...Yes, after you said that making button a child of main window, I tried it and it works. But if I change the button to be a child of NoteBook i.e.
    my $t_button = $nb->Button(-text=>'OK', -command=>sub{exit});
    Then not only does the button not show up, I don't get any error from the execution of pack statement inside the callbacks either when the callbacks are executed. What's going on ? Can you please tell me what's the problem here?

    Hey, Thank you for your patience in reading my query.
Re^2: Usefulness of -in option in Geometry Management (Perl/Tk)
by Anonymous Monk on Nov 27, 2014 at 03:48 UTC
    Hello Loops,

        I just chanced to see some details on this.
    1. http://stackoverflow.com/questions/18106377/cant-pack-a-widget-inside-a-sibling-toplevel

    2. the first para of response from Donal Fellows and the last response dated Aug 7 '13 at 17:37 from Elchonon Edelson.

    3. http://stackoverflow.com/questions/21467113/is-there-a-limit-on-the-length-or-nesting-of-tcl-tk-widget-pathnames/21468948#21468948

    4. the response dated Jan 30 at 22:39 from Donal Fellows.

        Those being the responses about pure Tcl/Tk I didn't quite understand what they said. Do you have any explanation/thoughts from your side ?

    Thank you