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

I'm currently writing a script using Perl/Tk for windows NT. I would like to know how we can maximize the main window like if the user is pressing the second button in the upper-right corner of the window. The only way I have found yet is to ask the desktop his resolution and then call geometry with this resolution :

$::mainWindow->geometry( $::mainWindow->screenwidth() . "x" . $::mainWindow->screenheight() . "+0+0");

Thanks, Fred

Replies are listed 'Best First'.
Re: Maximizing window in Perl/TK
by holygrail (Scribe) on Jun 22, 2001 at 21:32 UTC
    There is no "maximize" function in Tk. You could however use your method, which I would use like this:
    $main->withdraw(); $main->geometry($main->screenwidth."x".$main->screenheight."+0+0"); $main->deiconify(); $main->raise();
    First you minimize the window, then you set the new geometry, after that restore the window and then bring it to front.

    --HolyGrail
(ichimunki) Re: Maximizing window in Perl/TK
by ichimunki (Priest) on Jun 22, 2001 at 21:40 UTC
    If by "upper-right corner of the window", you mean the buttons at the right end of the title bar, those buttons should be handled by your window manager--in this case NT. Which means that you shouldn't have to code for them at all (and probably shouldn't, since that is likely to introduce irregularities and confuse users).

    Is that not happening in your application?

    BTW, as a callback or sub what you have looks fine to me-- or did this not work either?

    Additional thought: you may want to ensure that you set a height that takes into account the typical size of the menu bar, since otherwise you'll just create a window bigger than the actual screen real estate available.