drag and drop graphics in tkinter?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sean McIlroy

    #1

    drag and drop graphics in tkinter?

    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
  • Eric Brunel

    #2
    Re: drag and drop graphics in tkinter?

    Sean McIlroy wrote:[color=blue]
    > 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[/color]

    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

    Comment

    • Sean McIlroy

      #3
      Re: drag and drop graphics in tkinter?

      Eric Brunel <eric_brunel@de spammed.com> wrote in message news:<41a2fb94$ 0$8155$8fcfb975 @news.wanadoo.f r>...
      [color=blue]
      > I'm not quite sure I understand your question: drag and drop between what and
      > what?[/color]

      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.

      Comment

      • Sean McIlroy

        #4
        Re: drag and drop graphics in tkinter?

        Eric Brunel <eric_brunel@de spammed.com> wrote in message news:<41a2fb94$ 0$8155$8fcfb975 @news.wanadoo.f r>...
        [color=blue]
        > I'm not quite sure I understand your question: drag and drop between what and
        > what?[/color]

        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.

        Comment

        • Diez B. Roggisch

          #5
          Re: drag and drop graphics in tkinter?

          > I'm looking for a way to use drag-and-dropping to pick up a graphic[color=blue]
          > 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.[/color]


          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

          Comment

          • Lonnie Princehouse

            #6
            Re: drag and drop graphics in tkinter?

            > > I'm looking for a way to use drag-and-dropping to pick up a graphic[color=blue][color=green]
            > > 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.[/color][/color]

            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.

            Comment

            Working...