UPDATE July 3, 2011 After reading over perldoc Tk::Widget, I see that it is better to use UnmapWindow, and MapWindow, rather than withdraw and deiconify. So better code would be:
-command => sub { #$top->withdraw; $top->UnmapWindow; my $timer = Tk::after(2000, sub{ #$top->deiconify; # throws a tcl warning $top->MapWindow; });
P.S. Gtk2's method of removing window manager controls is better than Tk, as it will still show an overrideredirected window in the Window Manager's tray.
#!/usr/bin/perl use warnings; use strict; use Tk; my $top = MainWindow->new; $top->geometry('200x200+200+200'); $top->overrideredirect(1); $top->Label( -text => 'Click and Drag' )->pack( -expand => 1, -fill => 'both' ); $top->Button( -text => 'Minimize', -command => sub { $top->withdraw; my $timer = Tk::after(2000, sub{ $top->deiconify; }); } )->pack; $top->Button( -text => 'Exit', -command => sub { $top->destroy } )->pack; my @deltaxy; $top->bind( '<1>' => \&getdelta ); $top->bind( '<B1-Motion>' => \&mousemove ); MainLoop; sub mousemove { my ( $width, $height, $x, $y ) = split /[+x]/, $top->geometry; $x = $top->pointerx - $deltaxy[0]; $y = $top->pointery - $deltaxy[1]; $top->geometry( $width . 'x' . $height . "+$x+$y" ); } sub getdelta { @deltaxy = ( $top->pointerx - $top->x, $top->pointery - $top->y ); }
In reply to Re^5: Perl Tk (Kinda urgent)
by zentara
in thread Perl Tk (Kinda urgent)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |