in reply to Re: passing TK object into a sub
in thread passing TK object into a sub

Im my example I just have a window with a menubar at the top. Selecting a mode from the "mode" menu displays different content in the main window.

So I built all of that and put a frame below the menu to house whatever content I need to load into it. Which is loaded by calling a specific sub.

So by your example, I should build all of the widgets ahead of time and just pack/forgetPack them with the subs to change their visibility? Does that have an adverse effect on memory usage?

Replies are listed 'Best First'.
Re^3: passing TK object into a sub
by zentara (Cardinal) on Jul 16, 2008 at 15:38 UTC
    You are correct. Build all of your widgets ahead of time, and control their visibility by packing/packForgetting them. Your memory usage will stay constant that way. If you are talking about many widgets, that may never get used, only build them as you need them, and store them in a hash or array for easy manipulation. So you can do something like this, where you can set the variable for the checkbox, to $num, and when you click the checkbox, the $num will be sent to the sub.
    my %entry; #global to store entries sub get_entry{ my $num = shift; if ( !Exists( $entry{$num}{'entry'} ) { $entry{$num}{'entry'} = $frame->Entry()->pack(); } else { #repack $entry{$num}{'entry'}->pack(); } }

    I'm not really a human, but I play one on earth CandyGram for Mongo
      awesome, thank you very much