Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44533

RE: Drag and drop in Windows

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <Robert.Flintham@uhb.nhs.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'subject:Windows': 0.02; 'tutorial': 0.03; 'argument': 0.05; 'received:169.254.1': 0.05; 'retrieved': 0.05; 'root': 0.05; 'binary': 0.07; 'interpreter.': 0.07; 'none,': 0.07; 'suppose': 0.07; 'tkinter': 0.07; 'append': 0.09; 'none)': 0.09; 'assume': 0.14; 'windows': 0.15; '"register': 0.16; 'accepts': 0.16; 'bind': 0.16; 'braces': 0.16; 'coupling': 0.16; 'disclaimers': 0.16; 'drag': 0.16; 'expecting': 0.16; 'mechanism.': 0.16; 'robert,': 0.16; 'side.': 0.16; 'skip:" 70': 0.16; 'skip:[ 60': 0.16; 'skip:{ 40': 0.16; 'subfolder': 0.16; 'subject:drop': 0.16; 'tcl': 0.16; 'tkinter.': 0.16; 'files.': 0.16; 'folder': 0.16; 'proprietary': 0.16; 'library': 0.18; 'bit': 0.19; 'implementing': 0.19; 'message-----': 0.19; 'widget': 0.19; 'not,': 0.20; 'work,': 0.20; 'seems': 0.21; '(the': 0.22; 'import': 0.22; 'to:name:python- list@python.org': 0.22; 'load': 0.23; 'error': 0.23; 'dll': 0.24; 'file.': 0.24; "i've": 0.25; 'script': 0.25; 'skip:" 30': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'tried': 0.27; 'correct': 0.29; 'robert': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'url:wiki': 0.31; 'file': 0.32; 'received:169.254': 0.32; 'run': 0.32; 'url:python': 0.33; '(most': 0.33; 'skip:# 10': 0.33; 'comment': 0.34; 'skip:_ 10': 0.34; 'maybe': 0.34; 'skip:d 20': 0.34; "can't": 0.35; 'something': 0.35; 'usual': 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'i.e.': 0.36; 'url:listinfo': 0.36; 'charset:us- ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:169': 0.37; 'virtual': 0.37; 'email addr:python.org': 0.37; 'level': 0.37; 'received:10': 0.37; 'step': 0.37; 'christian': 0.38; 'implement': 0.38; 'auto': 0.38; 'generic': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'skip:- 10': 0.38; 'rather': 0.38; 'recent': 0.39; 'legally': 0.39; 'does': 0.39; 'subject:': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'how': 0.40; 'disclaimer:': 0.60; 'event.': 0.60; 'skip:y 20': 0.60; 'then,': 0.60; 'received:unknown': 0.61; 'information,': 0.61; 'first': 0.61; 'received:62': 0.63; 'header:Message-Id:1': 0.63; 'name': 0.63; 're:': 0.63; 'field': 0.63; 'more': 0.64; 'account': 0.65; 'distance': 0.65; 'email name:python-list': 0.65; 'invalid': 0.68; 'privileged.': 0.69; 'e-mail.': 0.70; 'exclusive': 0.81; 'case?': 0.84; 'christian.': 0.84; 'guts': 0.84; 'pad': 0.84; 'typically,': 0.84; 'recipient(s)': 0.95; 'url:tk': 0.95; '2013': 0.98
From Robert Flintham <Robert.Flintham@uhb.nhs.uk>
To 'Christian Gollwitzer' <auriocus@gmx.de>, "python-list@python.org" <python-list@python.org>
Date Tue, 30 Apr 2013 09:39:43 +0100
Subject RE: Drag and drop in Windows
Thread-Topic Drag and drop in Windows
Thread-Index Ac5FGhbiXdXTSlYdRPWnePbL38E0bAAYziSg
OLD-MSG-ID <DFBB66D7CAE80545A91347000FC76D5E0235A2ED55@BOURNE.xuhb.nhs.uk>
References <mailman.1148.1367231567.3114.python-list@python.org> <20130429204237.52A8F448266@nhs-pd1e-esg007.ad1.nhs.net>
In-Reply-To <20130429204237.52A8F448266@nhs-pd1e-esg007.ad1.nhs.net>
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 text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-SEF-7853D99-ADF1-478E-8894-213D316B8FFA 1
X-SEF-Processed 7_0_0_00239__2013_04_30_09_39_49
X-TM-AS-Product-Ver IMSVA-8.0.0.1467-7.0.0.1014-19832.006
X-TM-AS-Result No--31.126-60-31-10
X-imss-scan-details No--31.126-60-31-10; No--31.126-3-31-10; No--31.126-5-31-10
X-TMASE-MatchedRID EoCNt5v31Dq+J2V2/n6KGeYAh37ZsBDCc3ewuwbSaG6YjVGk//6gyRux rpr/pUL/Az8TvINBEuBLF16JzzXMTjT7rmcnNv1sj1RGQOB2Vvlu+Tj21kVZY8eQfu6iwSfsekW kqRyavwA/0gN+AWs2fwgujc5raJdwx6b5UrcphDpPuMJi/ZAk8RkqnRJng/51TliRpURm/BKSNT lFDhS1gP/sDS9b51M9FyCVjv7dlo5OnGmDpYr7R8SaVcOEb3Zct3aeg7g/usBeNs5tWYvjCaavl IwR6/83OKjcIhHUkSZSHwKg482PEGJqIuHqFLYoMAuD+BTmZchPn74Ug5EKEHLLhex0FFibcbcg OSSPsBdyKbXcsoQTsNQTMO5G6F0o06P6nK44odA0uZ5aG4kmrvngX/aL8PCNMMn1rcqKQagCMTN 4O+16f/iiQ0ugCAbYUBNTWj7/a74rQ4Lf8bCdwZPf7FSKi4gAENswxezu/44zs7oxv6pPAbe25A mPxvRo/DKheHzPEGKo8iTRLP4F3n+OhC1J6Q0szq/P2v00iKOr3d1rmRdCgBYvYmBVVNAYCf2h9 A2gFAWvExSmuBldGksoDo7ne8USyTBgz6hl0dd7sw7yO+Y9LO0DrqzpLK29lpyqxIUg/ZQL4KbF 8qbADItWcC0zAi54vECLuM+h4RB+3BndfXUhXQ==
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1173.1367311190.3114.python-list@python.org> (permalink)
Lines 61
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367311190 news.xs4all.nl 15968 [2001:888:2000:d::a6]:38635
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44533

Show key headers only | View raw


Thanks Christian.

I've tried the following code:
################
import Tkinter

root = Tkinter.Tk()
root.title("DICOM Opener")
root.tk.eval('lappend auto_path {K:/Python27/Lib/site-packages/tkdnd2.6}')
root.tk.eval('package require tkdnd')
################

But I get the following traceback:
################
Traceback (most recent call last):
  File "K:\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1397, in <module>
    debugger.run(setup['file'], None, None)
  File "K:\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1090, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "K:\PROGRAMMING\mripy\dicom_opener.py", line 7, in <module>
    root.tk.eval('package require tkdnd')
_tkinter.TclError: couldn't load library "K:/Python27/Lib/tkdnd2.6/tkdnd26.dll": invalid argument
################

Is "invalid argument" as generic as it sounds, or does it mean something specific in this case?  Is Tcl expecting an additional argument in the 'package require' line?

I assume the append auto path line is correct as it seems to have found the DLL (presumably from pkgIndex.tcl).

Apologies for any disclaimers that pad out this message - it's a work email account and they get added after I hit "send".

All the best,
Rob

-----Original Message-----
From: Python-list [mailto:python-list-bounces+robert.flintham=uhb.nhs.uk@python.org] On Behalf Of Christian Gollwitzer
Sent: 29 April 2013 21:38
To: python-list@python.org
Subject: Re: Drag and drop in Windows

Hi Robert,

Am 29.04.13 12:25, schrieb Robert Flintham:
> I've found this (TkDND):
>
> http://wiki.tcl.tk/2768
 > But I don't know how to implement this in Python.  The Windows binary  > for it comes as a set of ".tcl" files and a single ".dll" file.
 > 2.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?

I can only comment on the Tcl side, since I'm not an expert in the Tkinter coupling mechanism. TkDND is indeed the way to go if you want native drag'n'drop support. The first step would indeed be to load the package into the Tcl interpreter. You need to:

1) Create a folder for the packages, put the files in a subfolder Typically, this is something like lib/tkdnd, and at that level there must be the "pkgIndex.tcl" file
2) Append the lib/ folder to the auto path tk.eval('lappend auto_path {mypath/lib}') (the braces are Tcl's quoting mechanism)
3) load the package
tk.eval('package require tkdnd')

Then, you need to "register the target", i.e. declare a widget that it accepts files. Here, you need the Tk path name of the widget, which is retrieved by __str__:

tk.eval('tkdnd::drop_target register ' + yourwidget +' *')

Then, if you drop something, the widget recieves a virtual event <<Drop:DND_Files>> . Now this is tricky, I don't know how to bind to that event. Following the tutorial for Tcl on http://wiki.tcl.tk/36708, I suppose something like

	yourwidget.bind("<<Drop::DND_Files>>", filesdropped)

should in principle work, but how to get the data out of it? It is stuffed into the %D bind substitution. Usual events store the MouseWheel distance in this field; so maybe you can get it from the field event.delta. I can't test it now, but I am a bit skeptical whether this works with the guts of TkInter. If not, you'd need to do some more forwarding from the Tcl side.

	Christian
--
http://mail.python.org/mailman/listinfo/python-list

DISCLAIMER:
This email and any attachments hereto contains proprietary information, some 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 transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Drag and drop in Windows Robert Flintham <Robert.Flintham@uhb.nhs.uk> - 2013-04-29 11:25 +0100
  Re: Drag and drop in Windows Christian Gollwitzer <auriocus@gmx.de> - 2013-04-29 22:38 +0200
  RE: Drag and drop in Windows Robert Flintham <Robert.Flintham@uhb.nhs.uk> - 2013-04-30 09:39 +0100
    Re: Drag and drop in Windows Christian Gollwitzer <auriocus@gmx.de> - 2013-04-30 14:08 +0200
  Re: Drag and drop in Windows Kevin Walzer <kw@codebykevin.com> - 2013-04-30 10:33 -0400
  Re: Drag and drop in Windows Kevin Walzer <kw@codebykevin.com> - 2013-04-30 19:09 -0400
  RE: Drag and drop in Windows Robert Flintham <Robert.Flintham@uhb.nhs.uk> - 2013-05-01 09:06 +0100
    Re: Drag and drop in Windows Christian Gollwitzer <auriocus@gmx.de> - 2013-05-01 10:25 +0200

csiph-web