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

Hi all Perlers!

Just a quick Tk question, is it possible to have a MainWindow (or Toplevel) without the OS specific frame around it. (The Frame containing the maximize, minimize and close buttons).

I'm Working on a drag and drop GUI (under Windows2k) and want it as small as possible, so loosing the surounding frame around it would save me a lot of space.

Cheers nubb

Replies are listed 'Best First'.
Re: Tk MainWindow
by converter (Priest) on Aug 19, 2003 at 09:33 UTC

    Set the override-redirect flag for the window with the overrideredirect method before mapping it (this is documented in the Tk::Wm man page). Example:

    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; $mw->overrideredirect(1); # set the override-redirect flag $mw->packPropagate(0); # prevent the window being resized # for this demo $mw->Button( -text => 'Quit', -command => sub { Tk::exit(0) }, )->pack( -side => 'bottom', ); # after a delay: # withdraw # clear the override-redirect flag # re-map the window $mw->after( 4000, sub { $mw->withdraw; $mw->overrideredirect(0); $mw->deiconify; $mw->raise; } ); # NB: # "Mastering Perl/Tk" mentions that clearing # the override-redirect flag will not cause # the window manager to supply decorations. # This is true, but at least on KDE, clearing # the flag, then unmapping and mapping the # window puts decorations in place. # # Your mileage may vary. MainLoop;

    converter

      True, overrideredirect will remove the decorations; however, you lose functionality also.

      From Wm.pod

      Setting the override-redirect flag for a window causes it to be ignored by the window manager; among other things, this means that the window will not be reparented from the root window into a decorative frame and the user will not be able to manipulate the window using the normal window manager mechanisms.

      One main limitation I have experienced with this is the inability to bind actions. As converter said, your mileage may vary but I don't think overrideredirect is the solution. I have mainly limited my use of the override-redirect to creating splash screens. If someone knows of a way to remove the decorations but still retain full Tk functionality, I would love to hear it.

      Inelukii
        I think this is more of a window manager issue than a Tk issue. From what I understand, overrideredirect simply tells the window manager not to bother with the window. Since the window manager is what's decorating the window in the first place, this accomplishes your goal. However, the window manager is then unable to do other things with the window.
        milkbone - perl/tk instant messaging - it's the only way to fly
        As with both other respondents I have also tried the override redirect method and the functionality problems aside it is a viable way of achieving what you want. It depends purely what level of GUI functionality you need. It is worth a try.

        jdtoronto

Re: Tk MainWindow
by wombat (Curate) on Aug 19, 2003 at 15:41 UTC
    Overrideredirect() is by far the easiest method to remove a window decoration.

    I have also been experimenting with writing code which would restore the lost functionality. I have made a window with a center area in which I draw my widgets, and then have eight bitmaps placed in a grid() around it. I am binding to them and working on making them move the window when one holdclick-moves the mouse. Has anyone else been trying this tack? ~W
Re: Tk MainWindow
by nubb (Acolyte) on Aug 21, 2003 at 07:48 UTC

    Hi and thanks for all your replyes, very kind of all of you :)

    I tried the overrideredirect() code, but as so many of you says, it is not worth the loss of functionality. Especially the move functionality.

    wombat if find a way to move the window i would be more than glad to hear about it.

    Cheers