| #!/usr/bin/perl -w
| # file: dnd.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;
|
-----------------------------------------------------------------------------
Malcolm Nooning Replied:

I use Tk quite a bit. I have found that PAR does not pack all the needed non-standard modules. For example, the executable made from your script gave me
Cannot find Win32Site at Tk/Widget.pm line 256
which I have come to expect.
Rather than try to figure what I need and don't need, I do the -M thing on most of the non-standard modules, like the Tk modules. Here is the one for Win32Site


 -M Tk::DragDrop::Win32Site

For things like dll files, I use -l, like this:
    -l $msvcr70
where $msvcr70 is defined like this:
  my $msvcr70 = "c:\\WINDOWS\\system32\\msvcr70.dll";

My actual pp command lines vary quite a bit, but in general they have many, many -M a::b::c items, sprinkled with just a few -l full_path_name items.

Good luck.




Reply via email to