Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Maximise or minimise Perl/Tk Main Window

by blackadder (Hermit)
on Sep 18, 2002 at 10:43 UTC ( [id://198786]=perlquestion: print w/replies, xml ) Need Help??

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

Greetings all,

How can I minimize or maximize a perl Tk main window?

I create the window like this: my $mw = MainWindow->new;

and I would like to minimize it like this: $mw->minimize; or maximise it like this: $mw->maximize;

Can someone please show me how? I sure you can't put this past Perl.
  • Comment on Maximise or minimise Perl/Tk Main Window

Replies are listed 'Best First'.
Re: Maximise or minimise Perl/Tk Main Window
by dree (Monsignor) on Sep 18, 2002 at 11:51 UTC
    What do you mean for "minimize" ? Iconify? If yes, try this:
    use strict; use Tk; my $mw = new MainWindow; $mw->Frame(-width=>200, height =>25); $mw->Button(-text => "Maximize", -command => sub {$mw->geometry($mw->screenwidth . "x" . $mw->s +creenheight . "+0+0")}) ->pack(); $mw->Button(-text => "Minimize", -command => sub {$mw->iconify;}) ->pack(); $mw->Button(-text => "Close", -command => sub {exit;}) ->pack(); MainLoop;
    You can try perldoc Tk::Wm
Re: Maximise or minimise Perl/Tk Main Window
by alien_life_form (Pilgrim) on Sep 18, 2002 at 11:47 UTC
    Greetings,

    $mw->geometry(($mw->maxsize())[0] .'x'.($mw->maxsize())[1]);

    Cheers,
    alf
    You can't have everything: where would you put it?
      Thanks to you Dree and Alf,....I will try this.
Re: Maximise or minimise Perl/Tk Main Window
by Anonymous Monk on Aug 06, 2007 at 17:31 UTC
    I found a better way simply: $mw->iconify; # Minimize $mw->deiconify; # Restore $mw->state('withdrawn'); # Hide $mw->state('normal'); # Show
      States: must be normal, iconic, withdrawn, or zoomed.
      $mainwindow->state('zoomed'); #maximize

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://198786]
Approved by fireartist
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (None)
    As of 2024-04-25 00:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found