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

I have a TK script that pops up a TopLevel window using a DynaTabFrame with a tab for a selectable set of categories
Each tab is pretty complex with a whole host of buttons, entries and labels.
Most of the time it works properly but if I pick the right combination of categories, the Toplevel will pop up empty with no widgets displayed.

The failing case is repeatable (but the case that fails seems to change when I update the code to add new debugging hooks etc..)
I have examined the Toplevel object in the debugger in the failed state and I can't see anything obvious between a fully populated window and the empty window.

I am using strict and warnings, and no warnings are reported in the failing case.

I also examined the failing/passing cases with WidgetDump. The content of that window is a bit overwhelming,
but it looks like the empty TopLevel is fully populated with all the tabs and widgets I'd expect to see

Is there a way to do a text based WidgetDump to a file so I can use tkdiff to compare the working vs non-working cases?

Can anyone think of any other debugging tips to track down what could be causing an empty topLevel window?

Update...
If I have a fully populated/working TopLevel window and I double click the dynatabframe element in the WidgetDump window
it becomes an empty non-functioning Toplevel window.
Not sure if thats a clue or just a red-herring

Update...
If I switch from DynaTabFrame to the Notebook widget, which i can do with a run-time option, It doesn't seem to break...
I noticed that when I used the DynaTabFrame I was adding an extra level of scrolled frame to each tab.
I removed that scrolled frame and packed everything directly into the tab and now it doesn't seem to break
(I did have to add a loop to raise all the tabs I created, one by one, to get the top level window to resize properly)

Since my "FIX" resulted from a guess, I have no real answer what was causing the problem,
I want to keep the question open...
Can anyone think of any other debugging tips to track down what could be causing an empty topLevel window?

Replies are listed 'Best First'.
Re: Debugging Tk empty Toplevel window (packForget)
by Anonymous Monk on May 27, 2019 at 01:00 UTC
    #!/usr/bin/perl -- use strict; use warnings; use Tk qw/ tkinit /; my $mw = tkinit( -title, -mw ); my $dyna = $mw->DynaTabFrame()->pack( -side => 'top', -expand => 1, -fill => 'both' ); $dyna->add( 'test' . $_, -label => 'test' . $_ ) for 1 .. 2 + rand 10; $mw->Button( -text, 'packForget', -command, [ \&fuhget, $mw, ], )->pack; $mw->MainLoop; exit( 0 ); sub fuhget { $_->packForget for shift( @_ )->children; }

      Thanks for the code
      I ran with several random numbers of tabs and never saw the failure at startup
      It is interesting that the "Empty TopLevel Window" I describe is what remains
      after I use your packForget button

        packForget is the only way I know to get empty toplevel :)