in reply to Border-less main window

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

Replies are listed 'Best First'.
Re^2: Border-less main window (Alt+F4 Ctrl+C
by Anonymous Monk on Jul 15, 2013 at 09:47 UTC

    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