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

Hi All, i am a new user. Actually i want to know how to place a dialog inside a main window using perl/tk.My main window size is 700x500 and dialog's size is 600x420.i want to locate tht dialog in the center of main window but i am unable to do so.Plz help me on this.

Replies are listed 'Best First'.
Re: how to place dialog in main window?
by atemon (Chaplain) on Jul 24, 2007 at 10:49 UTC

    you can pass the reference to the main window to the dialoge as follows

    my $mw = MainWindow->new( ... options ... ); $DialogRef = $widget->Dialog( -mw => $mw ... ... ... );

    Hope this helps :)

    Cheers!

    --VC

    There are three sides to any argument.....
    your side, my side and the right side.

Re: how to place dialog in main window?
by zentara (Cardinal) on Jul 24, 2007 at 12:15 UTC
    Learn to read the perldocs. From "perldoc Tk::Dialog"
    The actual Dialog is shown using the Popup method. Any other options s +upplied to Show are passed to Popup, and can be used to position the + Dialog on the screen. Please read Tk::Popup for details.

    Example:

    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::DialogBox; my $mw = MainWindow->new(); $mw->geometry("600x400+100+100"); my $dialog = $mw->DialogBox( -title => 'Test', -buttons => [qw/Yes No Cancel/], ); my $lifter; $mw->Button(-text=>'Get_dialog', -command => sub{ $lifter = $mw->repeat(100,sub{ $dialog->raise }); #my $answer = $dialog->Show; my $answer = $dialog->Show(-popover => $mw); $lifter->cancel; #do your $dialog return testing } )->pack; MainLoop;

    Note, this may not work on old versions of Tk, like Tk800 on Perl5.6, but show some code and give more details if you still have a problem.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: how to place dialog in main window?
by GrandFather (Saint) on Jul 24, 2007 at 05:20 UTC

    What have you tried so far?


    DWIM is Perl's answer to Gödel
Re: how to place dialog in main window?
by Anonymous Monk on Jul 24, 2007 at 09:12 UTC
    Dialogs don't work like that.