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

Hi, I want to create the main window border-less and without the window showing in the taskbar. The main window did not look like any widget I know, it was composed of a square colored in 3 colors and that's it. I've seen it done, but I can't find how. Can you please share your infinite wisdom on how this can be done? Thanks

Replies are listed 'Best First'.
Re: Border-less main window
by kcott (Archbishop) on Jul 15, 2013 at 09:16 UTC

    As AM posted, overrideredirect() is the method you want. However, when you do that, you may end up with no (easy) way to shutdown your GUI. So, before testing that method, I'd recommend you test something like this:

    Button(-text => 'Exit', -command => sub { exit })

    -- Ken

      However, when you do that, you may end up with no (easy) way to shutdown your GUI.

      well, I imagine whatever your window manager shortcuts are still work, on onwin32 its Alt+F4 and it works to close the window

      Hitting ctrl+c (if you used perl.exe) in the console also QUITS it :) Terminating on signal SIGINT(2)

      But yeah, if you're going this route you should add a exit button, I prefer one that doesn't call exit :)

      $mw->Button( qw/-text Exit -command / => [ $mw, q/destroy/ ] );

        I used the words may and easy in "... you may end up with no (easy) way ..." quite deliberately as I have no knowledge of what platform the OP is using. Regardless, we both seem to be in agreement that an "Exit" button is a good idea.

        "I prefer one that doesn't call exit"

        Why do you have that preference? Do you perhaps think that exit in a Tk callback refers to CORE::exit?

        Take a look at this from Tk::exit:

        "If calling exit from code invoked via a Tk callback then this Tk version of exit cleans up more reliably than using the perl exit."

        and a little further down

        "... Tk::exit is imported by default ..."

        or simply look in your copy of Tk.pm:

        ... @EXPORT = qw(Exists Ev exit MainLoop DoOneEvent tkinit); ...

        As for destroy() (documented in Tk::Widget), you'd only need to use that (on your MainWindow object) if you had code after MainLoop which you needed to execute. Here's an example of the difference:

        #!/usr/bin/env perl use strict; use warnings; use Tk; my $mw = MainWindow->new; $mw->Button(-text => 'Exit', -command => sub { exit })->pack; $mw->Button(-text => 'Destroy', -command => sub { $mw->destroy })->pac +k; MainLoop; print "After MainLoop\n";

        Sample runs:

        $ pm_tk_exit_vs_destroy.pl # Using 'Exit' button $ pm_tk_exit_vs_destroy.pl # Using 'Destroy' button After MainLoop $

        -- Ken

Re: Border-less main window
by rjt (Curate) on Jul 15, 2013 at 06:05 UTC

    I'd love to help, but what exactly are you trying to do? I.e., what module are you using to create the window? Tk, for example? What have you tried so far (posting a short example that illustrates the problem would help).

      Perl Tk :). I don't have much to share since I don't know how it can be done. I'm looking for an attribute that when it will be passed to a TopLevel or MainWindow it would change its appearnce to be borderless and without leaving a trace at the taskbar. Thanks
Re: Border-less main window (Tk)
by Anonymous Monk on Jul 15, 2013 at 07:06 UTC