in reply to Using a Tk window within a function

If this is a 1-shot query, you are probably alright doing that way in your sub. HOWEVER, if it is going to be used more than once, you do NOT want to create a new $mw in your sub, because it will cause a "memory leak", even if you destroy the $mw after use.

What you want to do is create your $mw or $dialog just once, and withdraw it from view. Then when you enter your sub, you configure the $dialog and pop it up. That what you can reuse it on subsequent queries to the user, and you won't have "memory gain" problems.


I'm not really a human, but I play one on earth. flash japh
  • Comment on Re: Using a Tk window within a function

Replies are listed 'Best First'.
Re: Re: Using a Tk window within a function
by Anonymous Monk on May 28, 2004 at 18:00 UTC
    Thanks zentara, that's useful.

      Presumably I would withdraw it from view like so:

      $mainwindow->withdraw()
      Yes, and a good way to bring it out of hiding is:
      $mw->raise();
      You can also test for what state you are in:
      if ($mw->state eq 'withdrawn') { $mw->raise; } else { $mw->withdraw;

      I'm not really a human, but I play one on earth. flash japh