Reader: 1
3 entries, 1 page |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
my $fenster = new MainWindow;
my $hl = $fenster->HList(-width => 50,)->pack();
my $style = $hl->ItemStyle('text',
-foreground => '#FF0000',
-selectforeground => '#FF0000'
);
my $toplevel = $fenster->toplevel;
my $menubar = $toplevel->Menu(-type => 'menubar');
$toplevel->configure(-menu => $menubar);
my $datei = $menubar->cascade(-label => '~Datei',
-tearoff => 0);
$datei->command(-label => 'Zeige', -command => sub{nickchange()});
$datei->command(-label => 'Quit', -command => [$fenster=>'destroy']);
1
2
3
4
5
6
7
8
9
10
11
sub nickchange {
my $window2 = $fenster->Toplevel;
my $text = $window2->Label(-text => "Nickname eingeben")->pack();
my $entry = $window2->Entry()->pack();
my $button = $window2->Button(-text => 'Ok',-command => \&action)->pack();
sub action {
my $eingabe = $entry->get();
$window2->destroy();
$variable = $eingabe;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Tk::Error: not a Tk object
Tk::die_with_trace at C:/Perl/lib/Tk.pm line 252
Tk::__ANON__ at ts_telnet_user_info.pl line 369
main::action at C:/Perl/lib/Tk.pm line 252
(eval) at C:/Perl/lib/Tk.pm line 252
Tk::__ANON__ at C:/Perl/lib/Tk/Button.pm line 111
Tk::Button::butUp at C:/Perl/lib/Tk.pm line 411
(eval) at C:/Perl/lib/Tk.pm line 411
Tk::MainLoop at ts_telnet_user_info.pl line 315
Tk callback for .toplevel.button
Tk::__ANON__ at C:/Perl/lib/Tk.pm line 252
Tk::Button::butUp at C:/Perl/lib/Tk/Button.pm line 111
<ButtonRelease-1>
(command bound to event)
1
2
3
4
5
Variable "$entry" will not stay shared at C:\community\toplevel.pl line 32.
Variable "$window2" will not stay shared at C:\community\toplevel.pl line 33.
Global symbol "$variable" requires explicit package name at C:\community\toplevel.pl line 22.
Global symbol "$variable" requires explicit package name at C:\community\toplevel.pl line 34.
Execution of C:\community\toplevel.pl aborted due to compilation errors.
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::HList;
use Tk::ItemStyle;
my $variable;
my $fenster = new MainWindow;
my $hl = $fenster->HList(-width => 50,)->pack();
my $style = $hl->ItemStyle('text',
-foreground => '#FF0000',
-selectforeground => '#FF0000'
);
my $toplevel = $fenster->toplevel;
my $menubar = $toplevel->Menu(-type => 'menubar');
$toplevel->configure(-menu => $menubar);
my $datei = $menubar->cascade(-label => '~Datei',
-tearoff => 0);
$datei->command(-label => 'Zeige', -command => sub{nickchange()});
$datei->command(-label => 'Quit', -command => [$fenster=>'destroy']);
$hl->repeat(1000, sub{print $variable;});
MainLoop;
sub nickchange {
my $window2 = $fenster->Toplevel;
my $text = $window2->Label(-text => "Nickname eingeben")->pack();
my $entry = $window2->Entry()->pack();
my $button = $window2->Button(-text => 'Ok',-command => [\&action,$window2,$entry])->pack();
}
sub action {
my ($window2,$entry) = @_;
my $eingabe = $entry->get();
$window2->destroy();
$variable = $eingabe;
}
3 entries, 1 page |