Smeagol has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I try to use PAR 0.87 on the example code shown below to make an executable for Win32 (Win XP). The script is a simple script showing a window that accepts drag and drop of files from Explorer or likewise.

When running the exe-file it quits silently, giving no error messages. I'm running ActiveState 5.8.6 build 811. The problem seems to be the Tk::DropSite. Any ideas how to correct this?

Regards Ronny

#!/usr/bin/perl -w # file: test_drag_and_drop.pl use Tk; use Tk::DropSite; use strict; use vars qw($mw $textbox); ################# sub accept_drop { my($widget, $selection) = @_; my $string_dropped; eval { if ($^O eq 'MSWin32') { $string_dropped = $widget->SelectionGet(-selection => $selection, 'STRING'); } else { $string_dropped = $widget->SelectionGet(-selection => $selection, # 'FILE_NAME'); 'STRING'); } }; if (defined $string_dropped) { $widget->insert('end', $string_dropped . "\n"); } } ################# sub print_string_and_exit { my ($mw, $textbox, ) = @_; my $string; $string = $textbox->get("0.0", "end"); print STDOUT "You dragged and dropped ::\n$string\n"; $mw->destroy; } ################# $mw = new MainWindow; $mw->title("Try to Drag and Drop"); $textbox = $mw->Scrolled('Text', -scrollbars => "osoe", -height => 10, -width => 72, )->pack; $textbox->DropSite (-dropcommand => [\&accept_drop, $textbox], -droptypes => ($^O eq 'MSWin32' ? 'Win32' : ['XDND', 'Sun']) ); my $okay_button = $mw->Button( -text => "Okay", -command => [ \&print_string_and_exit, $mw, $textbox, ] )->pack( -side => 'left', -anchor => 'n', -ipadx => 10, -expand => 1, ); MainLoop;

Replies are listed 'Best First'.
Re: Problem with PAR and Tk::Dropsite
by Albannach (Monsignor) on May 19, 2005 at 13:55 UTC
    First, there is an error message, but since you must not be using a command prompt to test your EXE, the window closes before you can see the message. It reads: Cannot find Win32Site at Tk/Widget.pm line 256

    As to the fix, you will find that pp often does not include non-standard modules by itself, but all it needs is a little coaxing:
    pp -M Tk::DragDrop::Win32Site test_drag_and_drop.pl
    produces a functioning EXE.

    --
    I'd like to be able to assign to an luser

      Thank you for responding, and you are of course right. I also got this respons from somewhere else:

      Apply the following patch to Module::ScanDeps 0.51 which teaches it to preload everything below Tk/DragDrop/ once it encounters Tk/DragDrop/Common.pm.

      --- Module/ScanDeps.pm.orig 2005-05-19 13:36:11.000000000 +0200 +++ Module/ScanDeps.pm 2005-05-19 13:49:59.000000000 +0200 @@ -295,6 +295,9 @@ 'Tk/Balloon.pm' => [qw( Tk/balArrow.xbm )], 'Tk/BrowseEntry.pm' => [qw( Tk/cbxarrow.xbm Tk/arrowdownwin.xbm ) +], 'Tk/ColorEditor.pm' => [qw( Tk/ColorEdit.xpm )], + 'Tk/DragDrop/Common.pm' => sub { + _glob_in_inc('Tk/DragDrop', 1); + }, 'Tk/FBox.pm' => [qw( Tk/folder.xpm Tk/file.xpm )], 'Tk/Toplevel.pm' => [qw( Tk/Wm.pm )], 'URI.pm' => sub {

      Regards
      Ronny
Re: Problem with PAR and Tk::Dropsite
by thundergnat (Deacon) on May 19, 2005 at 14:02 UTC

    Tk::DragDrop dynamically loads some modules at runtime which are determined by which OS the script is running under. PAR is probably not following the dependency chain far enough since the specific dependency is only know at run time.

    Try manually adding the modules pathto/Perl/site/lib/Tk/DragDrop/Win32Site.pm and pathto/Perl/site/lib/Tk/DragDrop/Win32Drop.pm to the PAR build. (And possibly pathto/Perl/site/lib/Tk/DragDrop/Common.pm)