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

#1 Does anyone know how to position the DialogBox? I tried to use $mydialogbox->geometry but it didn't move it.


I expect this to be size 300x100 and positioned at the top left hand corner of the screen. $logindialog->geometry("300x100+0+0");

#2 Does anyone know how to make the button background a different color than the dialogbox background color?

Replies are listed 'Best First'.
Re: perl/tk DialogBox position
by zentara (Cardinal) on Apr 18, 2006 at 19:37 UTC
    The perldoc for Tk::DialogBox says
    There is no control over the appearance of the Buttons in the bottom Frame nor is there any way to control the placement of the two +Frames with respect to each other.

    So basically, you can change the color of the frames, and the colors of any widgets you add to the top frame. The DialogBox is a "convenience widget", designed to do the task easily. If you want full control over your popup windows, just make your own toplevel window, and withdraw it. Then pop it up when needed. There is a grabGlobal command to make your toplevel grab focus, just like the DialogBox.

    #!/usr/bin/perl use warnings; use strict; use Tk; my $tl; my $mw = MainWindow->new; $mw->title( "MainWindow" ); $mw->Button( -text => "Toplevel", -command => \&do_Toplevel )->pack(); MainLoop; sub do_Toplevel { if ( !Exists( $tl ) ) { $tl = $mw->Toplevel(); $tl->geometry('300x100+100+100'); $tl->title( "Toplevel" ); $tl->Button( -text => "Close", -command => sub { $tl->withdraw } )->pack; } else { $tl->deiconify(); $tl->raise(); } } ##############################################################

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