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

Immediately an example to explain my question:

$mw = MainWindow->new(); $mw->Button(-text=>"A", -command=>\&start)->pack(); MainLoop; sub start { $tl=$mw->Toplevel(); $tl->Button(-text=>"B", -command=>sub{destroy $tl})->pack(); }
When starting the toplevelwindow, I want to deactivate the mainwindow. Meaning: put toplevelwindow on top and avoid that any action can be done on the mainwindow. I know it can be done with a withdraw and deiconify but I don't want that the mainwindow totally disappears; I just want to 'deactivate' it. In fact, I want the same behaviour as 'getOpenFile'.
This seems to be a common used something; though I could not find any info in the Monks' infodatabase.
So any help is welcome.
Thx in advance

Replies are listed 'Best First'.
Re: Deactivate MainWindow when starting Toplevel
by jdporter (Paladin) on Apr 01, 2004 at 19:26 UTC
    Try this:
    sub start { $tl = $mw->Toplevel; $tl->title("B"); $tl->focus; $tl->grab; $tl->Button( -text => "B", -command => sub{ destroy $tl } )->pack; }
    title is documented in Tk::Wm;
    focus and grab have their own doc pages.

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.

Re: Deactivate MainWindow when starting Toplevel
by eserte (Deacon) on Apr 02, 2004 at 09:30 UTC
    You can use one of the dialog implementations: Tk::Dialog, Tk::DialogBox or the messageBox method. If this does not match your needs, then you have to fallback to the grab solution like explained by the other monk here.
      jdporter,
      thx a lot. the grab method works fine for me

      eserte,
      I will also try your suggestion

      regards