in reply to Perl Tk::Wm

use Tk; my $mw = new MainWindow(); $mw->geometry("200x400+0+0"); $mw->deiconify(); MainLoop;

When a perl/Tk application started, by default the application window gets iconified (appears as an icon). Calling deiconify() overrides the default, and makes the window really displayed,

geometry() takes the a string as parameter, and the string has the format "wxh[+-]l[+-]t":

Compare the following code with the code at the beginning of this post, tun both of them and see the differences:

use Tk; my $mw = new MainWindow(); $mw->geometry("400x200-0-0"); $mw->deiconify(); MainLoop;

Replies are listed 'Best First'.
Re: Re: Perl Tk::Wm
by flyingmoose (Priest) on Dec 18, 2003 at 14:34 UTC

    Ok, you confused me. I'm not sure I understand the 'deiconify' part, as I've written numerous apps that start up fine and not as an icon by default. Usually my apps look something like this, but never exhibit iconify problems:

    my $win = MainWindow->new; $win->configure(-title =>'hi',-background=>'blue'); $win->geometry('+225+150'); # offset from top left $win->minsize(575,375); # no smaller than this $win->maxsize(575,375); # no larger than this # add widgets ... MainLoop();

    Slightly off-topic: Note that since I want a window that doesn't change size, I don't have to supply the initial width and height to the 'geometry' method. I should, yes, but three calls in a row to control sizes didn't seem quite so elegant. Still, I have two calls, and that seems to be one too many. Can dictating a non-resizable window of dimensions $x and $y be made in a single call?

    As one last follow up: Mastering Perl/Tk by O'Reilly (the Emu book) is a *really* good book. If you can get your work to pay for this, that would be a good thing to do, if not, buy it anyway. I use it all the time and it is really well written. GUI programming books are rarely this easy to read, and this one has tons of content.

      Instead of maxsize and minsize, try $win->resizable(0,0). That specifies whether the window can be resized in width or height (neither in this case). So your code becomes:
      $win->geometry('575x375+225+150'); # geometry / offset $win->resizable(0,0); # non-resizable