Yes, putting the $mw->withdraw AFTER the $dialog->Show works. But I also get a silly empty window besides the one I want. I used 'messageBox' with the main window "withdrawn" and it works perfectly see: old post (second response). Why not this one with DialogBox. I honestly believe that it CAN be done, what is the missing "secret sauce"? | [reply] |
my $mw = MainWindow->new();
$mw->withdraw();
my $ftp_warn = $mw->messageBox(
-title => 'Downloading upgrade',
-message => "We are about to download an upgrade to your software, d
+o you wish to continue?",
-type => 'YesNo',
-icon => 'question',
);
if ( $ftp_warn eq 'No' ) {
exit;
}
else {
&doUpdate();
}
This is a fragment fomr something that happens to be open in my editor, but it will illustrate what you need yo do. Again, "Mastering Perl/Tk" is your friend, why not go to http://safari.oreilly.com and get the 14 day free trial. That way you can learn Perl/Tk BEFORE you can get to the bookstore.
jdtoronto | [reply] [d/l] |
I reworked your original code in this fashion:
use strict;
use warnings;
use Tk;
use Tk::DialogBox;
my $mw = MainWindow->new;
my $dialog = $mw->DialogBox (
-title => "Please pick one of the three",
-buttons => ["One", "Two", "Three"]);
my $item = $dialog->Show();
print "Returned from the show, got $item\n";
This runs in the same fashion as your original code sans the one print statement. After scrutinizing the Tk and Tk::Dialog docs on CPAN, I believe I have the answer here.
From the docs for Tk::Dialog: "A Dialog object essentially consists of two subwidgets: a Label widget for the bitmap and a Label wigdet for the text of the dialog. If required, you can invoke the `configure' method to change any characteristic of these subwidgets."
You'll notice that the "silly box" that you refer to contains whatever you named this script in the title bar and the rest is blank. I believe that the "silly box" is in fact the Label widget for the bitmap. If so, then there is no way to not display that and display a dialog box using the Tk::Dialog module.
If someone shows that my surmise is incorrect, I'll be happy to retract this.
Update 5-05-06: Fixed a typo in the fifth line of code; I had "tmy" instead of "my".
| [reply] [d/l] |
Yes, it seems as though MessageBox is the exception. As you show, one can have the main window 'withdrawn' and the message box appears. Obviously there is some flag that allows this (or am I assuming something here?). All I'm asking is that the dialog box have the same ability. I'm willing to "manually" set the proper flag (if possible) for Dialog. At the moment I've resorted to making the main window small and in one of the corners (it has nothing in it). Maybe all of this is buried deep inside Tk and it can't be changed from the Perl prespective. While I do remain hopeful, I have a solution that works for me.
Thanks to all.
| [reply] |