in reply to Re^4: creating skinable Perl/Tk apps
in thread creating skinable Perl/Tk apps
use Tk; my $mw = tkinit; $mw->overrideredirect(1); $mw->Label(-text => 'move window')->pack; $mw->Button(-text => 'Exit', -command => sub {exit})->pack; my ($x, $y); $mw->bind('<B1-Motion>', sub { my ($x2, $y2) = $mw->pointerxy; if (defined $x) { printf("move (%d, %d) => (%d, %d)\n", $mw->rootx, $mw->rooty, $mw->rootx+$x2-$x, $mw->rooty+$y2-$y); $mw->geometry(sprintf("+%0d+%0d", $mw->rootx+$x2-$x, $mw->rooty+$y2-$y)) if defined $x; } ($x, $y) = ($x2, $y2); }); # Reset starting-coordinates $mw->bind('<Motion>', sub {($x, $y) = (undef, undef)}); MainLoop;
|
|---|