From Newsgroup: comp.lang.tcl
On Thu, 14 Mar 2024 17:37:45 -0400, saitology9 wrote:
### code follows ###########
package require Tk
label .l -text "Move me to move the window" -width 40 -height 10
pack .l -fill both -expand 1
bind .l <1> {
set coords "%x %y"
lassign $coords ::labelx ::labely
}
bind .l <B1-Motion> {
moveme %W %x %y
}
proc moveme {win x y} {
set top [winfo toplevel $win]
lassign [split [winfo geometry $top] "+"] dims x1 y1
set newX [expr {$x1 + $x}]
set newY [expr {$y1 + $y}]
set newX [expr {$newX - $::labelx}]
set newY [expr {$newY - $::labely}]
wm geometry $top "${dims}+${newX}+${newY}"
}
### end of code ############
--
Luc
--- Synchronet 3.20a-Linux NewsLink 1.114