> Here's a new thread with a suggestion to include the results > in the Tkx > documentation (following an earlier thread on documentation issues). > How do we do drag and drop in Tkx? Does anyone have a simple > script that > demonstrates this for, say, a listbox widget that allows > dropping in file > names from folders on the desktop (in Windows, Mac, and > Linux)? Or, a text > widget that allows dropping in the contents of files from a > simple text > file.
I have no Tkx usage, but I'll share my more generic Tcl.pm way. For intra-application DND, you need to use widgets that support that. For example, BWidgets support this, so may be we could easily develop a Tkx example with BWidgets DND. In my applications I use another way. I use tkdnd http://wiki.tcl.tk/2768, which allows me dropping items from external applications. It happened this way that I am using two ways of doing DND in my applications, both ways based on the same engine under the hood. The newer way, which I currently prefer, involves some pure-tcl code, which I mostly copy-pasted from eslewhere.. Here is pure-tcl code that I feed to tcl/tk: package require tkdnd #the line below is just creating a widget - no "dnd" consideration pack [entry .frTop1.current_dir -textvariable ptclv_current_dir] -side left -fill x -expand 1 # and this actually makes DND work tkdnd::drop_target register .frTop1.current_dir * bind .frTop1.current_dir <<Drop:DND_Files>> { set ptclv_current_dir [lindex %D 0] ptcl_refresh } ....... EOF Then I even do not bother about widget .frTop1.current_dir - it has DND, binded to variable so I do not even expose widget itself to my perl program. I do expose other widgets, however. This approach will suit for Tkx module as well - it is front-end syntax agnostic. Another, elder way, which I do not prefer anymore, uses Tcl::Tk syntax, and technically it is absolytely the same. $interp->packageRequire('tkdnd','2.0'); my $w_curdir = $frame->Entry(-textvariable=>\$var)->pack(-side=>'left',-expand=>1,-fill=>'x'); $interp->tkdnd__drop_target(register => $w_curdir, "*"); $w_curdir->bind('<<Drop:DND_Files>>', \\'D', sub { my (undef,undef,undef,$data) = @_; ($$cwd_r) = $interp->SplitList($data); }); > Even in Tcl, this seems to be a poorly documented issue. Things are not that bad if you know where to search :) BWidgets is well-documented, so if you need inter-app DND, then it will suffice. Usually Jeff tell us about which packages are poorly supported and which are not, and IIRC he said BWidgets are o-kay to use :) BR, Vadim.