in reply to Tk: WaitBox widget not grabbing correctly

I think the WaitBox module is buggy. I kept getting errors with the latest version of Tk. It's no wonder I hardly ever see WaitBox in use.
can't make ".waitbox" its own master at /usr/lib/perl5/5.8.6/i686-linu +x-thread-multi/Tk/Submethods.pm line 37. at /usr/lib/perl5/site_perl/5.8.6/Tk/WaitBox.pm line 58

If you are just looking for a dialog which grabs control, and prevents $mw from responding, try something like the following. There is also DialogBox which will allow you to place your Progressbar into it( I've not tested that combo , but it should work).

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Dialog; my $mw = MainWindow->new(); $mw->geometry("+100+100"); $mw->title("Main Window"); $mw->geometry("250x250"); $mw->bind("<Return>", \&do_dialog); my $result = "Dialog Result Here"; $mw->Label( -textvariable => \$result, -relief => "sunken", -borderwidth => 1 )->pack( -side => "bottom", -fill => "both", -padx => 5, -pady => 5, -ipadx => 3, -ipady => 3 ); $mw->Button( -text => "Exit", -command => sub{ exit(0) }, )->pack( -fill => "x", -padx => 5, -pady => 5, ); $mw->Button( -text => "Test Dialog", -command => \&do_dialog, )->pack( -expand => 1, -fill => "both", -padx => 5, -pady => 5, ); MainLoop; exit(0); sub do_dialog { my $dlg = $mw->Dialog( -title=>"Here is a question for you.", -buttons => ["Cancel", "No", "Yes"], -default_button => "No", -text => "Let's see what the result is..", -font => "Helvetica" ); $result = "Result: " . $dlg->Show(); print("got: $result\n"); }

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

Replies are listed 'Best First'.
Re^2: Tk: WaitBox widget not grabbing correctly
by Anonymous Monk on Jun 29, 2005 at 04:46 UTC
    Hi,

    I think I am still unable to get main window out of focus. If I use the above code - it opens a dialog box which has initial focus, but I can easily move mouse to MainWindow and do all operations like - Minimize, Maximize, Move and even CLOSE, which I dont want

    You might try grabGlobal and see the effect, I want the same affect but locking only the MainWindow and not whole WindowManager.

      The operations you are talking about, are "Window Manager" controls, which are not controlled by Tk. However Tk has a way to disable/enable them. Use overrideredirect(). In the code I posted above do this:
      my $mw = MainWindow->new(); $mw->geometry("+100+100"); $mw->title("Main Window"); $mw->overrideredirect(1); $mw->bind("<Return>", \&do_dialog);
      then if you desire to return full WindowManager controls back to the mainwindow, put:
      $mw->overrideredirect(0);
      somewhere in your code where it's convenient, like only if you get a "yes" response.

      You could also set it up to have your popup dialog use overrideredirect too.


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