Leser: 1
![]() |
![]() |
4 Einträge, 1 Seite |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#!/usr/local/bin/perl use strict; use warnings; 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" and "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); } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use warnings;
package Tk::MyLB;
require Tk::Listbox;
our @ISA = qw /Tk::Listbox Tk::Clipboard/;
Tk::Widget->Construct('MyLB');
sub ClassInit{
my ($class,$mw) = @_;
$class->SUPER::ClassInit($mw);
$mw->bind($class,'<Control-v>','insert_from_cb');
}
sub insert_from_cb{
my $self = shift;
$self->insert('end',$self->clipboardGet());
}
package main;
use Tk;
use strict;
use vars qw($top $drop);
$top = new MainWindow;
$top->Label(-text => "The drop area:")->pack;
$drop = $top->Scrolled('MyLB',
-scrollbars => "osoe",
-takefocus => 1,
)->pack;
MainLoop;
perl -pi'*.ori' -e"s/^\d+://" test.pl
Spieler+2007-11-15 14:28:57--PS: kann man die Anzeige der Zeilennummern für [perl] ge'tag'ten code irgendwie unterbinden? Ich mache jetzt z.B.damit, aber ich finde das lästig.Code: (dl )perl -pi'*.ori' -e"s/^\d+://" test.pl
![]() |
![]() |
4 Einträge, 1 Seite |