diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1999-06-21 16:19:43 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1999-06-21 16:19:43 (GMT) |
commit | 1de2a92791998d5a495aa3f8072086d67663c2bc (patch) | |
tree | c75b06c05b35eb5aa8455e15dd95c8ee99c96435 /Mac | |
parent | 58b2eacf6b53fff92ecad3233073efbd5ca756d2 (diff) | |
download | cpython-1de2a92791998d5a495aa3f8072086d67663c2bc.zip cpython-1de2a92791998d5a495aa3f8072086d67663c2bc.tar.gz cpython-1de2a92791998d5a495aa3f8072086d67663c2bc.tar.bz2 |
Initial minimal test program: print information on anything dropped onto Python
window.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Lib/test/dragtest.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Mac/Lib/test/dragtest.py b/Mac/Lib/test/dragtest.py new file mode 100644 index 0000000..7663af7 --- /dev/null +++ b/Mac/Lib/test/dragtest.py @@ -0,0 +1,43 @@ +import Drag +import time +xxxx=1 +def decode_hfs(data): + import struct, macfs + tp = data[0:4] + cr = data[4:8] + flags = struct.unpack("h", data[8:10]) + fss = macfs.RawFSSpec(data[10:]) + return tp, cr, flags, fss + +def tracker(msg, dragref, window): + pass + +def dropper(dragref, window): + global xxxx + n = dragref.CountDragItems() + print 'Drop %d items:'%n + for i in range(1, n+1): + refnum = dragref.GetDragItemReferenceNumber(i) + print '%d (ItemReference 0x%x)'%(i, refnum) + nf = dragref.CountDragItemFlavors(refnum) + print ' %d flavors:'%nf + for j in range(1, nf+1): + ftype = dragref.GetFlavorType(refnum, j) + fflags = dragref.GetFlavorFlags(refnum, ftype) + print ' "%4.4s" 0x%x'%(ftype, fflags) + if ftype == 'hfs ': + datasize = dragref.GetFlavorDataSize(refnum, ftype) + data = dragref.GetFlavorData(refnum, ftype, datasize, 0) + print ' datasize', `data` + xxxx = data + print ' ->', decode_hfs(data) + + +def main(): + print "Drag things onto output window. Press command-. to quit." + Drag.InstallTrackingHandler(tracker) + Drag.InstallReceiveHandler(dropper) + while 1: + time.sleep(100) + +main() |