Smeagol has asked for the wisdom of the Perl Monks concerning the following question:
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 | |
by Smeagol (Initiate) on May 19, 2005 at 16:09 UTC | |
|
Re: Problem with PAR and Tk::Dropsite
by thundergnat (Deacon) on May 19, 2005 at 14:02 UTC |