drag and drop graphics in tkinter?

Discussion in 'Python' started by Sean McIlroy, Nov 23, 2004.

  1. Sean McIlroy

    Sean McIlroy Guest

    The subject line essentially says it all. Is there a way to do it? If
    so, where do I look to find out how? Any help will be much
    appreciated.

    Thx,
    STM
    Sean McIlroy, Nov 23, 2004
    #1
    1. Advertising

  2. Sean McIlroy

    Eric Brunel Guest

    Sean McIlroy wrote:
    > The subject line essentially says it all. Is there a way to do it? If
    > so, where do I look to find out how? Any help will be much
    > appreciated.
    >
    > Thx,
    > STM


    I'm not quite sure I understand your question: drag and drop between what and
    what? Two windows in a Tkinter application? A file manager and a Tkinter
    application?

    If you want to support drag and drop inside a Tkinter application, check the
    file Tkdnd.py in the Lib/lib-tk sub-directory of the source Python distribution.

    HTH
    --
    - Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
    PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
    Eric Brunel, Nov 23, 2004
    #2
    1. Advertising

  3. Sean McIlroy

    Sean McIlroy Guest

    Eric Brunel <> wrote in message news:<41a2fb94$0$8155$>...

    > I'm not quite sure I understand your question: drag and drop between what and
    > what?


    I'm looking for a way to use drag-and-dropping to pick up a graphic
    and move it from one place to another. For example, I thought I could
    get my feet wet by writing a script to represent small graphs (in the
    nodes-and-vertices sense) as collections of dots and lines onscreen.
    Moving the the dots around (while maintaining line-indicated
    connections between dots) could furnish a graphical way of
    investigating questions like planarity and isomorphism.
    Sean McIlroy, Nov 23, 2004
    #3
  4. Sean McIlroy

    Sean McIlroy Guest

    Eric Brunel <> wrote in message news:<41a2fb94$0$8155$>...

    > I'm not quite sure I understand your question: drag and drop between what and
    > what?


    I'm looking for a way to use drag-and-dropping to pick up a graphic
    and move it from one place to another. For example, I thought I could
    get my feet wet by writing a script to represent small graphs (in the
    nodes-and-vertices sense) as collections of dots and lines onscreen.
    Moving the the dots around (while maintaining line-indicated
    connections between dots) could furnish a graphical way of
    investigating questions like planarity and isomorphism.
    Sean McIlroy, Nov 23, 2004
    #4
  5. > I'm looking for a way to use drag-and-dropping to pick up a graphic
    > and move it from one place to another. For example, I thought I could
    > get my feet wet by writing a script to represent small graphs (in the
    > nodes-and-vertices sense) as collections of dots and lines onscreen.
    > Moving the the dots around (while maintaining line-indicated
    > connections between dots) could furnish a graphical way of
    > investigating questions like planarity and isomorphism.



    That's not what commonly is associated with drag-and-drop - the reason
    beeing that the interesting thing about drag and drop is to create a sort
    of event in the drop-target that is filled with information about _what_
    has been dropped - e.g. a file location - and then act accordingly. This is
    not so much about the graphical appearance, but much more about protocol
    issues.

    What you want is to utilize the canvas widget. It can create graphics
    primitives, and there are plenty of events available so that you get
    noticed when the user picks a node (presumably rendered by a circle) and
    drags it around.

    I've done that years ago, and tk was quite easy to use. But as its a more
    tk-specific question, I suggest you search for tk canvas examples, and
    translate them to tkinter.
    --
    Regards,

    Diez B. Roggisch
    Diez B. Roggisch, Nov 23, 2004
    #5
  6. > > I'm looking for a way to use drag-and-dropping to pick up a graphic
    > > and move it from one place to another. For example, I thought I could
    > > get my feet wet by writing a script to represent small graphs (in the
    > > nodes-and-vertices sense) as collections of dots and lines onscreen.
    > > Moving the the dots around (while maintaining line-indicated
    > > connections between dots) could furnish a graphical way of
    > > investigating questions like planarity and isomorphism.


    Yep, the canvas widget is the way to go. You might also take a look
    at wxPython instead of Tkinter -- if I recall correctly, there's some
    kind of graph widget that might save you some time (run the demo.py
    script to find it). Also, as someone who has spent a lot of time
    lately tinkering with graphs, I can highly recommend graphviz. If you
    haven't already looked at it, it's an excellent tool for graph layout.
    Lonnie Princehouse, Nov 23, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oliver Klein
    Replies:
    0
    Views:
    689
    Oliver Klein
    Aug 24, 2003
  2. Marc
    Replies:
    8
    Views:
    2,875
    Michael Peuser
    Sep 5, 2003
  3. John Benson
    Replies:
    1
    Views:
    1,169
    klappnase
    Dec 9, 2003
  4. Replies:
    3
    Views:
    723
  5. shawleigh17

    Java 2D Graphics Drag and Drop

    shawleigh17, Jul 8, 2009, in forum: Java
    Replies:
    1
    Views:
    1,245
    melita777
    Aug 27, 2012
Loading...

Share This Page