Leser: 2
6 Einträge, 1 Seite |
Quote\n\nName: variable
Class: Variable
Switch: -variable
Specifies reference to a variable to set to indicate whether or not this button is selected. Defaults to \$widget->{'Value'} member of the widget's hash. In general perl variables are undef unless specifically initialized which will not match either default -onvalue or default -offvalue.
$menu->entrycget(0, -menu)->entryconfigure(1, -state => "disabled");
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
#!/Perl/bin/perl
use strict;
use Tk;
use Tk::Menu;
my $mw = Tk::MainWindow->new();
my $var = 1;
my $menuitems = [
[Cascade => "~Datei", -menuitems =>
[
[Button => "~Neu", -command => sub{ return 1; }],
[Separator => ""],
[Button => "~Öffnen", -command => sub{ return 1; }],
[Button => "~Sichern", -command => sub{ return 1; }],
[Checkbutton => "~checkbox", -command => sub{ return 1; }, -variable => \$var,],
],
],
];
my $menu = $mw->Menu(-menuitems => $menuitems);
$mw->configure(-menu => $menu);
$mw->Button(
-text=>'Knopf',
-command => sub{
if( $var == 1 ) {
$var = 0;
}else{
$var = 1;
}
},
)->pack();
$mw->Label(-textvariable => \$var)->pack();
MainLoop;
6 Einträge, 1 Seite |