Página 1 de 1

Ventana TK que no se cierra

NotaPublicado: 2009-06-15 12:13 @550
por BigBear
Hi!

Ando queriendo hacer una ventana con el módulo Tk que cada vez que se presione el botón cerrar se cree otra igual y no tenga salida pero no sé cómo hacerla.

Ventana normal:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
use Tk;

$mw = MainWindow->new( -background => "black", -cursor=>"crosshair");
$mw->geometry("600x325+100+100");
$mw->title("{Ventana de prueba");



$mw->Label(-background => "black", -foreground => "black")->pack();


$mw->Label(-background => "black", -foreground => "black")->pack();
$mw->Label(-background => "black", -foreground => "black")->pack();
$mw->Label(-background => "black", -foreground => "black")->pack();



MainLoop;
Coloreado en 0.006 segundos, usando GeSHi 1.0.8.4


¿Cómo haría que cada vez que se presione el botón cerrar se cree otra igual y no se pueda cerrar?

NotaPublicado: 2009-06-15 13:03 @585
por explorer
Parece ser que el tema está en capturar el evento WM_DELETE_WINDOW:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
## --perl-- ##
use strict;
use Tk;

my $main=MainWindow->new();
my $quit=$main->Button(-text=>"Exit",-command=>sub {$main->destroy}
)->pack();

#Here are some options..
#Disable the maximize button.
#But also doesn't allow the user to resize...
$main->resizable(0,0);

#Disable the close button...
#Then make sure you have a "QUIT" button!!
$main->protocol('WM_DELETE_WINDOW',sub{return;});

#User fights to iconfiy the window?
$main->bind('<Unmap>',sub{$main->deiconify});#Immediately deiconifies if
iconified.

# Or just uncomment this...but no interaction possible, ARRRRGH!
#$main->overrideredirect(1);

MainLoop;
__END__
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4


http://www.mail-archive.com/perl-win32- ... 01402.html
http://stackoverflow.com/questions/5075 ... on-windows
http://www.justskins.com/forums/closing ... -7674.html