Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving widgets on a canvas

Status
Not open for further replies.

MycroftXX

Programmer
Oct 6, 2005
2
DE
Hi,

moving graphical objects on a canvas
is quite easy. But how can I manage to
move common widgets as labels or
frames on a canvas?
The following examples works well
with circles, lines etc. but not
with an label. So where is my mistake?


Mycroft

********************
proc dragstart {w x y} {
global draglocation
catch {unset draglocation}
set draglocation(obj) [$w find closest $x $y]
set draglocation(x) $x
set draglocation(y) $y
}
proc dragit {w x y} {
global draglocation
if {"$draglocation(obj)" != ""} {
set dx [expr $x - $draglocation(x)]
set dy [expr $y - $draglocation(y)]
$w move $draglocation(obj) $dx $dy
set draglocation(x) $x
set draglocation(y) $y
}
}
canvas .c -width 400 -height 400
.c create oval 20 30 40 50 -fill red -stipple gray25 -tags {movable}
.c create window 150 150 -tags {movable} -window [label .c.button -text hallo]

.c bind movable <Button-1> {dragstart %W %x %y}
.c bind movable <B1-Motion> {dragit %W %x %y}

pack .c

*********************
 
I can't see why it doesn't work but the "window" doesn't appear to be movable. Why not use the "create text" feature instead?

_________________
Bob Rashkin
rrashkin@csc.com
 
No, the label was just an example. For my real application I wanted to move frames, buttons and other widgets on the canvas.


MycroftXX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top