Tuesday, January 28, 2014

Qt's Drag-and-Drop Architecture for Python and PyQt5
Pt. 8, Running Tests

To repeat, the entire code of the example program is in this PasteBin. Copy it; save it as draggin.py; and execute it from a command line:

$ python draggin.py

Try dragging and dropping:

  • From the source onto upper part of the target
  • Onto the forbidden (lower right) quadrant of the target
  • Onto another app that accepts text drops, like a text editor
  • Onto the desktop (in Mac OS, makes a "clipping" file)
  • Onto something that doesn't accept the drop

You can also start more than one copy:

$ python draggin.py &
$ python draggin.py &

Now you have two copies. Drag and drop from the source of one onto the target of the other and note, although the drop is accepted by a Qt widget, the source doesn't get any indication of success.

Next post: hacking the QDrag class for fun (but no profit)!

No comments: