Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:Windows': 0.02; 'skip:[ 20': 0.04; 'i?m': 0.05; 'received:169.254.1': 0.05; 'binary': 0.07; 'i?ve': 0.07; 'tkinter': 0.07; 'you?d': 0.07; 'imported': 0.09; 'wrapper': 0.09; 'python': 0.11; '2.7': 0.14; 'windows': 0.15; 'appreciated!': 0.16; 'bind': 0.16; 'idx': 0.16; 'proc': 0.16; 'stumbled': 0.16; 'subject:drop': 0.16; 'tcl': 0.16; 'xppython': 0.16; 'proprietary': 0.16; 'code.': 0.18; 'variable': 0.18; 'all,': 0.19; 'bit': 0.19; 'trying': 0.19; '<': 0.19; 'implementing': 0.19; 'command': 0.22; 'input': 0.22; 'import': 0.22; 'to:name :python-list@python.org': 0.22; 'error': 0.23; 'dll': 0.24; 'file.': 0.24; "i've": 0.25; 'options': 0.25; 'switch': 0.26; 'post': 0.26; 'skip:" 20': 0.27; 'don?t': 0.29; 'mode': 0.30; "i'm": 0.30; 'included': 0.31; 'url:wiki': 0.31; 'skip:? 20': 0.31; 'file': 0.32; 'this.': 0.32; 'probably': 0.32; 'received:169.254': 0.32; 'open': 0.33; 'skip:& 30': 0.33; 'skip:? 10': 0.33; 'but': 0.35; 'url:rec-html40': 0.35; 'really': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'received:169': 0.37; 'searching': 0.37; 'url:microsoft': 0.37; 'two': 0.37; 'received:10': 0.37; 'implement': 0.38; 'skip:o 20': 0.38; 'generic': 0.38; 'question,': 0.38; 'window': 0.38; 'url:office': 0.38; 'skip:[ 10': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'url:schemas': 0.38; 'planning': 0.38; 'rather': 0.38; 'url:omml': 0.39; 'url:2004': 0.39; 'legally': 0.39; 'skip:& 20': 0.39; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'disclaimer:': 0.60; 'received:unknown': 0.61; 'information,': 0.61; 'received:62': 0.63; 'header:Message-Id:1': 0.63; 'such': 0.63; 'direct': 0.67; 'bottom': 0.67; 'email,': 0.69; 'privileged.': 0.69; 'e-mail.': 0.70; 'exclusive': 0.81; 'skip:$ 10': 0.81; 'explorer': 0.84; 'that?s': 0.84; 'recipient(s)': 0.95; 'url:tk': 0.95 From: Robert Flintham To: "python-list@python.org" Date: Mon, 29 Apr 2013 11:25:51 +0100 Subject: Drag and drop in Windows Thread-Topic: Drag and drop in Windows Thread-Index: Ac5Ew+vkfYcj8bi9TaCKw8Ot8YgvlA== OLD-MSG-ID: Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-GB Content-Type: multipart/alternative; boundary="_000_DFBB66D7CAE80545A91347000FC76D5E0235A2ED54BOURNExuhbnhs_" MIME-Version: 1.0 X-SEF-7853D99-ADF1-478E-8894-213D316B8FFA: 1 X-SEF-Processed: 7_0_0_00239__2013_04_29_11_25_58 X-TM-AS-Product-Ver: IMSVA-8.0.0.1467-7.0.0.1014-19830.006 X-TM-AS-Result: No--38.722-60-31-10 X-imss-scan-details: No--38.722-60-31-10; No--38.722-3-31-10; No--38.722-5-31-10 X-TMASE-MatchedRID: dwz5Qv+5WGrdeQjqNZdjdCZm6wdY+F8KQrO4XR6BRQMZnbM1DCQfDfRm 0kmqtH+DHZ42wuMtlG2XOXSR+sVuoVxH8Dm6GqsW84dsinZ5e1hy4VFP6muDhqbGGv9dC9Uchbj XiP8vmiywQmjMkzPgDUBmhlAfq+ED02FrWs7riSAD2WXLXdz+AQkN8Uvsy+nttSlhqC3qPOhDZs GJaCDYmLJJPvchJmiFKB5B11+7y+FDPREoNRs4IxK6EFc0lvV0XEjKf9fhKafF7duWDXiFEhs46 Rwf3Ox5os9DXkHxMZ1r4j/oOfXFUnBQEhF4lroX0Xw0ILvo/uX54F/2i/DwjRC5sbPgjhvgFUc7 hcYrKS5oDyC1jJiOF3VALpStBs0q3jv4KvWrwsQAz7oVOD+dyjoSfZud5+GgmmzaGKIwUHbkhXZ 0G9JRyzba6gSbbjl+QVYK+bzrDzjSxemNC+0f0PU1Xpm2N12S/AZW18vjv1o6iP0NczjR0lvr9J ucnAavzkH/0tV77RAZttB2H+RMvwkbnmLrKdccY4guKfvwCBaPzMNXaUvE6YtSx8A+2HeKakcq2 RAHKcqFNXznDVhjDbjhwRWzN/6QMuYLNWSVlUgc9jA4mLo8uaX1XMd/SqvuKOpzudgQfQJR18Qp zXStTnic1EL5RdbnKoWa7+H+3DvMWzPfoqOdFjTR2TFg0xG3pwnFZnn+VHwaK6XhXABo9yJkpIM WHcbC92grUwQgYZcl9IJzJrAT7nMbiLLKBHkE/sToY2qzpx6SiN8MzoBQOEUYJ3RLQ0KypyBBhr A3gBwIi8x5+jfCK4DMUZ7Ecdr/rv9HEZyuwxnrpcchznD6Bw== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 252 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367231567 news.xs4all.nl 15909 [2001:888:2000:d::a6]:33215 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44493 --_000_DFBB66D7CAE80545A91347000FC76D5E0235A2ED54BOURNExuhbnhs_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello all,=0D=0A=0D=0ASorry to post such a generic question, but after sear= ching the interwebs I'm not really any wiser about how to start with this.=0D= =0A=0D=0AI'm currently on:=0D=0AWindows XP=0D=0APython 2.7=0D=0A=0D=0AI'm t= rying to create a small window in Python 2.7, that when you drop a file ont= o it from Windows explorer returns the file's path so that I can then go on= to open the file and do whatever with it. I was planning on using Tkinter= because that's what I've used before for GUI's, but I can be swayed from t= his if needs be.=0D=0A=0D=0AI've found this (TkDND):=0D=0Ahttp://wiki.tcl.t= k/2768=0D=0A=0D=0ABut I don't know how to implement this in Python. The Wi= ndows binary for it comes as a set of ".tcl" files and a single ".dll" file= =2E=0D=0A=0D=0AThe two options I've stumbled across seem to be=0D=0A=0D=0A1= =2E a Python wrapper for the DLL (I think to wrap C code=3F=3F), which can= then be imported like you'd import a Python package=0D=0A=0D=0A2. direct = implementation of the Tcl file [tk.eval('source ...')], but I don't reallu = understand what's going on with this - can you only execute a "main" bit of= Tcl files rather than implementing individual functions=3F=0D=0A=0D=0AAny = input (however minimal) is definitely appreciated! I've included what I th= ink are probably the relevant functions from the Tcl files at the bottom of= the email, but I don't really understand the nuts and bolts of the code.=0D= =0A=0D=0AAll the best,=0D=0ARob=0D=0A=0D=0A[From "tkdnd.tcl"...]=0D=0A=0D=0A= # -------------------------------------------------------------------------= ---=0D=0A# Command tkdnd::drag=5Fsource=0D=0A# ---------------------------= -------------------------------------------------=0D=0Aproc tkdnd::drag=5Fs= ource { mode path { types {} } { event 1 } } {=0D=0A set tags [bindtags $p= ath]=0D=0A set idx [lsearch $tags "TkDND=5FDrag*"]=0D=0A switch -- $mode= {=0D=0A register {=0D=0A if { $idx !=3D -1 } {=0D=0A bindta= gs $path [lreplace $tags $idx $idx TkDND=5FDrag$event]=0D=0A } else {=0D= =0A bindtags $path [concat $tags TkDND=5FDrag$event]=0D=0A }=0D= =0A set types [platform=5Fspecific=5Ftypes $types]=0D=0A set old=5F= types [bind $path <>]=0D=0A foreach type $types {=0D=0A= if {[lsearch $old=5Ftypes $type] < 0} {lappend old=5Ftypes $type}=0D= =0A }=0D=0A bind $path <> $old=5Ftypes=0D=0A = }=0D=0A unregister {=0D=0A if { $idx !=3D -1 } {=0D=0A bindt= ags $path [lreplace $tags $idx $idx]=0D=0A }=0D=0A }=0D=0A }=0D=0A= };# tkdnd::drag=5Fsource=0D=0A=0D=0A=0D=0A[From "tkdnd=5Fwindows.tcl"...]=0D= =0A=0D=0A# ----------------------------------------------------------------= ------------=0D=0A# Command olednd::=5FGetDragSource=0D=0A# --------------= --------------------------------------------------------------=0D=0Aproc ol= ednd::=5FGetDragSource { } {=0D=0A variable =5Fdrag=5Fsource=0D=0A retur= n $=5Fdrag=5Fsource=0D=0A};# olednd::=5FGetDragSource=0D=0ADISCLAIMER:=0D=0A= This email and any attachments hereto contains proprietary information, som= e or all of which may be confidential or legally privileged. It is for the = exclusive use of the intended recipient(s) only. If an addressing or transm= ission error has misdirected this e-mail and you are not the intended recip= ient(s), please notify the author by replying to this e-mail. If you are no= t the intended recipient you must not use, disclose, distribute, copy, prin= t, or rely on this e-mail or any attachments, as this may be unlawful.=0D=0A= --_000_DFBB66D7CAE80545A91347000FC76D5E0235A2ED54BOURNExuhbnhs_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello all,

<= span style=3D'font-size:10.0pt;font-family:Consolas;color:black'> = ;

Sorry to post such a generic question, but af= ter searching the interwebs I’m not really any wiser about how to sta= rt with this.

 

=

I’m currently on:

Window= s XP

Python 2.7

 

I’m trying to create a= small window in Python 2.7, that when you drop a file onto it from Windows= explorer returns the file’s path so that I can then go on to open th= e file and do whatever with it.  I was planning on using Tkinter becau= se that’s what I’ve used before for GUI’s, but I can be s= wayed from this if needs be.

 

I’ve found this (TkDND):=

http://wiki.tcl.tk/2768

 

But I don’t know how to imple= ment this in Python.  The Windows binary for it comes as a set of R= 20;.tcl” files and a single “.dll” file.

 

The two options I’ve stumbled across= seem to be

1.<= span style=3D'font:7.0pt "Times New Roman"'>  a Python wrapp= er for the DLL (I think to wrap C code=3F=3F), which can then be imported l= ike you’d import a Python package

2.&nb= sp; direct implementation of the Tcl file [tk.eval(‘source = …’)], but I don’t reallu understand what’s going on= with this – can you only execute a “main” bit of Tcl fil= es rather than implementing individual functions=3F

 

Any input (however minimal) is definitely appreci= ated!  I’ve included what I think are probably the relevant func= tions from the Tcl files at the bottom of the email, but I don’t real= ly understand the nuts and bolts of the code.

&nb= sp;

All the best,

Rob

 

[From “tkdnd.tcl”…]=

 

# ----------------------------= ------------------------------------------------

#&nbs= p; Command tkdnd::drag=5Fsource

<= span style=3D'font-size:10.0pt;font-family:Consolas'># --------------------= --------------------------------------------------------<= /p>

proc tkdnd::drag=5Fsource { mode path { types {} } { event 1 } } {<= /o:p>

  set tags [bindtags $path]

 = ; set idx  [lsearch $tags "TkDND=5FDrag*"]=

  switch -- $mode {

    regist= er {

      if { $idx !=3D -1 = } {

        bindtag= s $path [lreplace $tags $idx $idx TkDND=5FDrag$event]

=

=       } else {

  &n= bsp;     bindtags $path [concat $tags TkDND=5FDrag$even= t]

      }<= /p>

      set types [platform=5Fspecific=5Ftypes $t= ypes]

      set old=5Ftypes= [bind $path <<DragSourceTypes>>]

 &n= bsp;    foreach type $types {

  = ;      if {[lsearch $old=5Ftypes $type] < 0} {l= append old=5Ftypes $type}

    &nbs= p; }

      bind $path <<= ;DragSourceTypes>> $old=5Ftypes

  &nbs= p; }

    unregister {=

      if { $idx !=3D -1 } {<= /p>

        bindtags $path [lreplace $tag= s $idx $idx]

      }

    }

  }<= /span>

};# tkdnd::drag=5Fsource

 

 

[From “tkdnd=5Fwindows.tcl”= ;…]

 

# --------------= --------------------------------------------------------------

#  Command olednd::=5FGetDragSource

# --= --------------------------------------------------------------------------<= o:p>

proc olednd::=5FGetDragSource {  } {

  variable =5Fdrag=5Fsource

  retur= n $=5Fdrag=5Fsource

};# olednd::=5FGetDragSource



<= tr>

DISCLAIMER:
=0D=0AThis email and any atta= chments hereto contains proprietary information, s= ome or all of which may be confidential&= nbsp;or legally privileged. It is for the&nbs= p;exclusive use of the intended recipient(s) = only. If an addressing or transmission error&= nbsp;has misdirected this e-mail and you are&= nbsp;not the intended recipient(s), please notify&= nbsp;the author by replying to this e-mail.&n= bsp;If you are not the intended recipient&nbs= p;you must not use, disclose, distribute, cop= y, print, or rely on this e-mail or = ;any attachments, as this may be unlawful.
--_000_DFBB66D7CAE80545A91347000FC76D5E0235A2ED54BOURNExuhbnhs_--