in reply to want way to drag tk window

Hi, here is another variation which is simple to see what happens.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; $mw->geometry('200x200+200+200'); $mw->overrideredirect(1); my %wdraginfo; $mw->bind('<ButtonPress-1>', sub{ my $xe = $mw->XEvent; $wdraginfo{xoff} = $mw->pointerx - $mw->rootx; $wdraginfo{yoff} = $mw->pointery - $mw->rooty; }); $mw->bind('<B1-Motion>', sub{ my ($x,$y); $x=$mw->pointerx-$wdraginfo{xoff}; $y=$mw->pointery-$wdraginfo{yoff}; $mw->geometry($mw->width."x".$mw->height."+$x+$y"); }); MainLoop;

I'm not really a human, but I play one on earth. ..... an animated JAPH

Replies are listed 'Best First'.
Re^2: want way to drag tk window
by redss (Monk) on Aug 06, 2017 at 14:20 UTC
    This is the best solution since it works fine in all my versions of perl, and it is very simple. Thanks! I'm curious why all solutions make the window "always on top" though.
      In Tk, overrideredirect removes decorations and puts the window on top across all your virtual desktops with a global grab, it's not the best thing. In Gtk2, you can get more control, where you can remove decorations and set global_grab separately.

      I'm not really a human, but I play one on earth. ..... an animated JAPH