Drag and drop in Tkinter. How difficult is it?

M

Marc

Hi all,

I was thinking about developing a drag and drop application and was curious
how difficult it is to do. Basically I want to have a set of objects that I
move around the screen and drop into place.

Anyone else ever done it? Got any tips?

Thanks,
Marc
 
C

Cameron Laird

Hi all,

I was thinking about developing a drag and drop application and was curious
how difficult it is to do. Basically I want to have a set of objects that I
move around the screen and drop into place.
.
.
.
LOTS of applications--several I've written, I
know--do this sort of thing. You'll need to
learn about bind(), and most likely the events
<1>
<B1-Motion>
<ButtonRelease-1>
in particular: you'll teach <1> to start a
drag, <B1-Motion> to display the dragged object
moving around the screen, and <ButtonRelease-1>
to finish the drop.

Have you read <URL: http://
groups.google.com/groups?as_q=drag+drop+tkinter&as_ugroup=comp.lang.python >?
 
C

Christos TZOTZIOY Georgiou

[Marc]
I was thinking about developing a drag and drop application and was curious
how difficult it is to do. Basically I want to have a set of objects that I
move around the screen and drop into place.

- Cameron -
LOTS of applications--several I've written, I
know--do this sort of thing. You'll need to
learn about bind(), and most likely the events
<1>
<B1-Motion>
<ButtonRelease-1>
in particular: you'll teach <1> to start a
drag, <B1-Motion> to display the dragged object
moving around the screen, and <ButtonRelease-1>
to finish the drop.

Have you read <URL: http://
groups.google.com/groups?as_q=drag+drop+tkinter&as_ugroup=comp.lang.python >?

I should add that drag and drop in the same application can be done
easily, but it's hard to do it between your application and others (too
much window manager dependencies...)
 
C

Cameron Laird

.
.
.
I should add that drag and drop in the same application can be done
easily, but it's hard to do it between your application and others (too
much window manager dependencies...)
.
.
.
Absolutely. My guess is that the original questioner did *not*
have inter-application drag-and-drop in mind, at least not ini-
tially. Those who want to pursue the subject might find the
references at <URL: http://wiki.tcl.tk/DragAndDrop > helpful.
 
M

Marc

Excellent. Thanks for the head start.

A couple of questions.

1) If I want to have a moving object, and not just a cursor that
represents the moving object, do I need to continually pack and unpack
the widget that holds the object and redraw it to give it the
appearance of moving? I know sometimes the redrawing can cause
applications to flicker too much, destroying the effect. I don't know
if there's an optimum way to do this.

2) Also, in reading I found an old module called Tkdnd (drag and
drop). It was an experimental module that was supposed to be updated
but never was. Now I can't find any more information on it. Does this
module still exist or work?

Thanks,
Marc
 
C

Cameron Laird

.
.
.
1) If I want to have a moving object, and not just a cursor that
represents the moving object, do I need to continually pack and unpack
the widget that holds the object and redraw it to give it the
appearance of moving? I know sometimes the redrawing can cause
.
.
.
No! Just move the canvas object to follow the Motion events.
 
C

Cameron Laird

.
.
.
2) Also, in reading I found an old module called Tkdnd (drag and
drop). It was an experimental module that was supposed to be updated
but never was. Now I can't find any more information on it. Does this
module still exist or work?
.
.
.
'Don't know; 'think it hasn't been maintained in a couple of years.

<URL: http://wiki.tcl.tk/tkdnd > might interest you.
 
M

Michael Peuser

Marc said:
Excellent. Thanks for the head start.

A couple of questions.

I think they will be answered when you look at the link (Tree.py) I posted
yesterday ;-)

Kindly
Michael P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top