|< 1 2 3 >| | 23 Einträge, 3 Seiten |
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $input = 'noname.pl';
# Hauptfenster
my $nw = MainWindow->new();
# Titel des Hauptfensters
$nw->title ('Man Machine Interfaces II - UE - BSP 2');
# Menü
my $mbar = $nw->Menu();
$nw->configure (-menu => $mbar);
my $file = $mbar->cascade (-label => "File", -underline => 0);
$file->command (-label => "New", -command => [\&neu, "new"], -accelerator => 'Crtl-N', -underline => 0);
$file->command (-label => "Open", -command => [\&open, "open"], -accelerator => 'Crtl-O', -underline => 0);
$file->command (-label => "Save", -command => [\&save, "save"], -accelerator => 'Crtl-S', -underline => 0);
$file->separator();
$file->command (-label => "Exit", -command => [$nw => 'destroy'], -accelerator => 'Crtl-B', -underline => 0);
my $do = $mbar->cascade (-label => "Do", -underline => 0);
$do->command (-label => "Translation" -command => sub {translate}, -accelerator => 'Crtl-T', underline => 0);
# Text-Widget
my $In = $nw->Text (-wrap => 'none')->pack;
my $Out = $nw->Text (-wrap => 'none')->pack;
# Dictionary-Listbox
my $Dict = $nw->Listbox()->pack (-side => 'top', -expand => 1, -fill => 'both');
$Dict->insert("end", "the - das");
$Dict->insert("end", "sea - meer");
$Dict->insert("end", "is - ist");
$Dict->insert("end", "blue - blau");
MainLoop();
sub file {
} # sub file
sub neu {
my $tw = $nw->Toplevel(-title => 'New');
$tw->Label(-text => "Name of the File: ")->pack();
my $in = $tw->Entry(-textvariable => \$input)->pack();
$in->bind('<Return>', [\&create, $tw]);
} # sub neu
# Erzeugen einer neuen Datei
sub create {
CORE::open (IFILE, ">> $input") or die "can't create '$input':$!\n";
close IFILE;
$_[1]->destroy(); #Fenster wieder löschen
} # sub create
sub open {
my $tw = $nw->Toplevel(-title => 'Open');
$tw->Label(-text => "Open which File: ")->pack();
my $in = $tw->Entry(-textvariable => \$input)->pack();
$in->bind('<Return>', [ \&read, $tw ]);
} # sub open
# Datei zum Lesen und Schreiben Öffnen
sub read {
CORE::open (IFILE, "< $input") or die "can't open '$input':$!\n";
while (<IFILE>) {
$In->insert("end", $_);
}
close IFILE;
$_[1]->destroy(); #Fenster wieder löschen
} # sub read
sub save {
my $tw = $nw->Toplevel(-title => 'Save');
$tw->Label(-text => "Save : $input")->pack();
my $in=$tw->Entry(-textvariable => \$input)->pack();
print $input , "\n";
$in->bind('<Return>', [\&write, $tw]);
} # sub save
#Speichern der Eingabe
sub write {
CORE::open (IFILE, "+< $input") or die "can't open '$input':$!\n";
print IFILE $In->get('1.0', 'end');;
close IFILE or die $!;
$_[1]->destroy(); #Fenster löschen
} # sub write
sub perl {
system("/usr/bin/perl $input");
} # sub perl
sub translate {
}
Bareword "translate" not allowed while "strict subs" in use at C:\bsp2_final.pl line 29.
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $input = 'noname.pl';
# Hauptfenster
my $nw = MainWindow->new();
# Titel des Hauptfensters
$nw->title ('Man Machine Interfaces II - UE - BSP 2');
# Menü
my $mbar = $nw->Menu();
$nw->configure (-menu => $mbar);
my $file = $mbar->cascade (-label => "File", -underline => 0);
$file->command (-label => "New", -command => [\&neu, "new"], -accelerator => 'Crtl-N', -underline => 0);
$file->command (-label => "Open", -command => [\&open, "open"], -accelerator => 'Crtl-O', -underline => 0);
$file->command (-label => "Save", -command => [\&save, "save"], -accelerator => 'Crtl-S', -underline => 0);
$file->separator();
$file->command (-label => "Exit", -command => [$nw => 'destroy'], -accelerator => 'Crtl-B', -underline => 0);
my $do = $mbar->cascade (-label => "Do", -underline => 0);
$do->command(-label => "translation", -command => sub {&translate()}, -accelerator => 'Crtl-T', -underline => 0);
# Text-Widget
my $In = $nw->Text (-wrap => 'none')->grid(-column => 0, -row => 0);
my $Out = $nw->Text (-wrap => 'none')->grid(-column => 1, -row => 0);
# Dictionary-Listbox
my $Dict = $nw->Listbox()->grid(-column => 0, -row => 1, -columnspan => 2);
$Dict->insert("end", "the - das");
$Dict->insert("end", "sea - meer");
$Dict->insert("end", "is - ist");
$Dict->insert("end", "blue - blau");
MainLoop();
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
#!/usr/bin/perl use strict; use warnings; use Tk; my $input = 'noname.pl'; # Hauptfenster my $nw = MainWindow->new(); # Titel des Hauptfensters $nw->title ('Man Machine Interfaces II - UE - BSP 2'); # Text-Widget my $In = $nw->Text (-wrap => 'none')->pack; my $Out = $nw->Text (-wrap => 'none')->pack; # Menü my $mbar = $nw->Menu(); $nw->configure (-menu => $mbar); my $file = $mbar->cascade (-label => "File", -underline => 0); $file->command (-label => "New", -command => [\&neu, "new"], -accelerator => 'Crtl-N', -underline => 0); $file->command (-label => "Open", -command => [\&open, "open"], -accelerator => 'Crtl-O', -underline => 0); $file->command (-label => "Save", -command => [\&save, "save"], -accelerator => 'Crtl-S', -underline => 0); $file->separator(); $file->command (-label => "Exit", -command => [$nw => 'destroy'], -accelerator => 'Crtl-B', -underline => 0); my $do = $mbar->cascade (-label => "Do", -underline => 0); $do->command (-label => "Translation", -command => sub {translate()}, -accelerator => 'Crtl-T', -underline => 0); # Dictionary-Listbox my $Dict = $nw->Listbox()->pack (-side => 'top', -expand => 1, -fill => 'both'); $Dict->insert("end", "the - das"); $Dict->insert("end", "sea - meer"); $Dict->insert("end", "is - ist"); $Dict->insert("end", "blue - blau"); MainLoop(); sub file { } # sub file sub neu { my $tw = $nw->Toplevel(-title => 'New'); $tw->Label(-text => "Name of the File: ")->pack(); my $in = $tw->Entry(-textvariable => \$input)->pack(); $in->bind('<Return>', [\&create, $tw]); } # sub neu # Erzeugen einer neuen Datei sub create { CORE::open (IFILE, ">> $input") or die "can't create '$input':$!\n"; close IFILE; $_[1]->destroy(); #Fenster wieder löschen } # sub create sub open { my $tw = $nw->Toplevel(-title => 'Open'); $tw->Label(-text => "Open which File: ")->pack(); my $in = $tw->Entry(-textvariable => \$input)->pack(); $in->bind('<Return>', [ \&read, $tw ]); } # sub open # Datei zum Lesen und Schreiben Öffnen sub read { CORE::open (IFILE, "< $input") or die "can't open '$input':$!\n"; while (<IFILE>) { $In->insert("end", $_); } close IFILE; $_[1]->destroy(); #Fenster wieder löschen } # sub read sub save { my $tw = $nw->Toplevel(-title => 'Save'); $tw->Label(-text => "Save : $input")->pack(); my $in=$tw->Entry(-textvariable => \$input)->pack(); print $input , "\n"; $in->bind('<Return>', [\&write, $tw]); } # sub save #Speichern der Eingabe sub write { CORE::open (IFILE, "+< $input") or die "can't open '$input':$!\n"; print IFILE $In->get('1.0', 'end');; close IFILE or die $!; $_[1]->destroy(); #Fenster löschen } # sub write sub perl { system("/usr/bin/perl $input"); } # sub perl sub translate { my $text = $In->getSelected(); $Out->insert('end',$text); }
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $input = 'noname.pl';
# Hauptfenster
my $nw = MainWindow->new();
# Titel des Hauptfensters
$nw->title ('Man Machine Interfaces II - UE - BSP 2');
# Text-Widget
my $In = $nw->Text (-wrap => 'none')->grid(-column => 0, -row => 0);
my $Out = $nw->Text (-wrap => 'none')->grid(-column => 1, -row => 0);
# Menü
my $mbar = $nw->Menu();
$nw->configure (-menu => $mbar);
my $file = $mbar->cascade (-label => "File", -underline => 0, -tearoff => 0);
$file->command (-label => "New", -command => [\&neu, "new"], -accelerator => 'Crtl-N', -underline => 0);
$file->command (-label => "Open", -command => [\&open, "open"], -accelerator => 'Crtl-O', -underline => 0);
$file->command (-label => "Save", -command => [\&save, "save"], -accelerator => 'Crtl-S', -underline => 0);
$file->separator();
$file->command (-label => "Exit", -command => [$nw => 'destroy'], -accelerator => 'Crtl-B', -underline => 0);
my $do = $mbar->cascade (-label => "Do", -underline => 0, -tearoff => 0);
$do->command (-label => "Translation", -command => sub {translate()}, -accelerator => 'Crtl-T', -underline => 0);
# Dictionary-Listbox
my $Dict = $nw->Listbox()->grid(-column => 0, -row => 1, -columnspan => 2);
$Dict->insert("end", "the - das");
$Dict->insert("end", "sea - meer");
$Dict->insert("end", "is - ist");
$Dict->insert("end", "blue - blau");
MainLoop();
sub file {
} # sub file
sub neu {
my $tw = $nw->Toplevel(-title => 'New');
$tw->Label(-text => "Name of the File: ")->pack();
my $in = $tw->Entry(-textvariable => \$input)->pack();
$in->bind('<Return>', [\&create, $tw]);
} # sub neu
# Erzeugen einer neuen Datei
sub create {
CORE::open (IFILE, ">> $input") or die "can't create '$input':$!\n";
close IFILE;
$_[1]->destroy(); #Fenster wieder löschen
} # sub create
sub open {
my $tw = $nw->Toplevel(-title => 'Open');
$tw->Label(-text => "Open which File: ")->pack();
my $in = $tw->Entry(-textvariable => \$input)->pack();
$in->bind('<Return>', [ \&read, $tw ]);
} # sub open
# Datei zum Lesen und Schreiben Öffnen
sub read {
CORE::open (IFILE, "< $input") or die "can't open '$input':$!\n";
while (<IFILE>) {
$In->insert("end", $_);
}
close IFILE;
$_[1]->destroy(); #Fenster wieder löschen
} # sub read
sub save {
my $tw = $nw->Toplevel(-title => 'Save');
$tw->Label(-text => "Save : $input")->pack();
my $in=$tw->Entry(-textvariable => \$input)->pack();
print $input , "\n";
$in->bind('<Return>', [\&write, $tw]);
} # sub save
#Speichern der Eingabe
sub write {
CORE::open (IFILE, "+< $input") or die "can't open '$input':$!\n";
print IFILE $In->get('1.0', 'end');;
close IFILE or die $!;
$_[1]->destroy(); #Fenster löschen
} # sub write
sub perl {
system("/usr/bin/perl $input");
} # sub perl
sub translate {
my $text = $In->getSelected();
$Out->insert('end',$text);
}
1
2
3
4
5
6
# Dictionary-Listbox
my $Dict = $nw->Listbox()->grid(-column => 0, -row => 1, -columnspan => 2);
$Dict->insert("end", "the - das");
$Dict->insert("end", "sea - meer");
$Dict->insert("end", "is - ist");
$Dict->insert("end", "blue - blau");
1
2
3
4
5
6
# Dictionary-Listbox
my $Dict = $nw->Listbox()->grid(-column => 0, -row => 1, -columnspan => 2);
$Dict->insert("end", "the - das");
$Dict->insert("end", "sea - meer");
$Dict->insert("end", "is - ist");
$Dict->insert("end", "blue - blau");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/Perl/bin/perl
use strict;
use warnings;
use Data::Dumper qw/Dumper/;
use WWW::Leo;
my $leo = WWW::LEO->new();
$leo->query("das meer ist blau");
if ($leo->num_results) {
print Dumper $leo->en_de();
}else{
print "Sorry, your query for '%s'gave no results.\n", $leo->query;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# ... $do->command (-label => "Translation", -command => sub {translate($In, $Out)}, -accelerator => 'Crtl-T', -underline => 0); # ... =head3 translate($in, $out) Liest den Textaus dem Eingabe-Widget $in aus und fügt in in das Ausgabe-Widget ein ($out). Ein- und Ausgabewidget müssen vom Typ Tk::Text sein. =cut sub translate { my $in = shift; my $out = shift; my $text = $in->getSelected(); # Übersetzung $out->insert('end',$text); }
|< 1 2 3 >| | 23 Einträge, 3 Seiten |