jcavanaugh has asked for the wisdom of the Perl Monks concerning the following question:
Starting with the droptest.pl script below.
Everything works fine. But...#!/usr/local/bin/perl -w use Tk; use Tk::DropSite; use strict; use vars qw($top $drop); $top = new MainWindow; $top->Label(-text => "The drop area:")->pack; $drop = $top->Scrolled('Listbox', -scrollbars => "osoe", )->pack; # Tell Tk that $drop should accept drops. # The allowed drag and drop types on Unix systems are "KDE", "XDND" an +d "SUN" # and on Windows systems the "Win32" dnd type. # When dropping occurs, execute the accept_drop callback. $drop->DropSite (-dropcommand => [\&accept_drop, $drop], -droptypes => ($^O eq 'MSWin32' ? 'Win32' : ['KDE', 'XDND', 'Sun']) ); MainLoop; sub accept_drop { my($widget, $selection) = @_; my $filename; eval { if ($^O eq 'MSWin32') { $filename = $widget->SelectionGet(-selection => $selection, 'STRING'); } else { $filename = $widget->SelectionGet(-selection => $selection, 'FILE_NAME'); } }; if (defined $filename) { $widget->insert(0, $filename); } } __END__
What I need is a way to get the entire list of dropped files as part of a callback. Unfortunately what I get is a callback for each file dropped.
To give a little context, Im writing some code that will launch a script for all the files dropped on it. I dont want to launch the script 100 times if a 100 files are dropped. Instead I will pass the 100 files to the script once.
Im sure there is some way in Tk to know when a drop is complete or something. That way I could build up an array on the per file callbacks, then just call my script when the "Drop Complete" or something is signaled.
Any assistance would be appreciated...
-- John Cavanaugh
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Tk: Dropsite aggregation vs singles
by pg (Canon) on Jan 04, 2004 at 21:49 UTC | |
|
Re: Perl Tk: Dropsite aggregation vs singles
by JamesNC (Chaplain) on Jan 05, 2004 at 16:04 UTC | |
|
Re: Perl Tk: Dropsite aggregation vs singles
by jcavanaugh (Novice) on Jan 06, 2004 at 08:48 UTC |