]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Initial minimal test program: print information on anything dropped onto Python
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 21 Jun 1999 16:19:43 +0000 (16:19 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 21 Jun 1999 16:19:43 +0000 (16:19 +0000)
window.

Mac/Lib/test/dragtest.py [new file with mode: 0644]

diff --git a/Mac/Lib/test/dragtest.py b/Mac/Lib/test/dragtest.py
new file mode 100644 (file)
index 0000000..7663af7
--- /dev/null
@@ -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()