![]() |
|< 1 2 >| | ![]() |
16 Einträge, 2 Seiten |
QuoteTcl_VarTraceProc returned 'can't assign non-numeric value to scale variable'
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
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
#!/Perl/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Scale;
use Tk::Balloon;
my $mw = Tk::MainWindow->new(-width=>150,-height=>150,);
$mw->gridPropagate(0);
$mw->packPropagate(0);
my $wert = 0;
my $e = $mw->Entry(-textvariable=>\$wert);
my $s = $mw->Scale(
-variable => \$wert,
-from => 0,
-to => 100,
-length => 50,
-showvalue => 0,
-sliderlength => 6,
-sliderrelief => 'raised',
-orient => 'horizontal',
);
$e->configure(
-validate => 'all',
-validatecommand => sub {
if( $wert =~ m/\D/g ) {
$wert =~ s/\D//g;
# invalid-command kommt hier zum Zuge
return 0;
}
return 1;
},
);
$e->pack();
$s->pack();
Tk::MainLoop;
QuoteName: command
Class: Command
Switch: -command
Specifies the prefix of a perl/Tk callback to invoke whenever the scale's value is changed via a method. The actual command consists of this option followed by a space and a real number indicating the new value of the scale.
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
#!/Perl/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Scale;
use Tk::Balloon;
use Tk::NumEntryPlain;
use Tk::EntryCheck;
use Tk::NumEntry;
my $mw = Tk::MainWindow->new(-width=>150,-height=>150,);
$mw->gridPropagate(0);
$mw->packPropagate(0);
my $wert = 10;
my $s = $mw->Scale(
-variable => \$wert,
-from => 0,
-to => 100,
-length => 50,
-showvalue => 0,
-sliderlength => 6,
-sliderrelief => 'raised',
-orient => 'horizontal',
);
my $e = $mw->NumEntry(
-minvalue => 0,
-maxvalue => 100,
-width => 5,
-bell => 1,
-text => $wert,
);
my $l = $mw->Label(
-textvariable => \$wert,
);
# ------------ configure
$e->configure(
-validate => 'key',
-vcmd => sub{
if( main::setScale($e, $s) ){
return 1;
}else{
return 0;
}
},
);
$s->configure(
-command => sub{
main::setEntry($e, $s, \$wert);
},
);
$e->pack();
$s->pack();
$l->pack();
Tk::MainLoop;
sub setScale {
my ($e, $s) = @_;
# ist Wert ist auf jeden Fall numerisch
# $wert ist bereits durch -variable gesetzt
$e->configure(-text=>$wert);
return 1;
} # /setScale
sub setEntry {
my ($e, $s, $wert_ref) = @_;
# $zw kann "" sein
my $zw = $e->get();
if( $zw =~ m/.{0,0}/ ){
$zw = 0;
}
$$wert_ref = $zw;
$s->set($zw);
} # /setScale
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
#!/Perl/bin/perl
use strict;
use warnings;
use Tk;
use Tk::Scale;
use Tk::Balloon;
use Tk::NumEntryPlain;
use Tk::EntryCheck;
use Tk::NumEntry;
my $mw = Tk::MainWindow->new(-width=>150,-height=>150,);
$mw->gridPropagate(0);
$mw->packPropagate(0);
my $wert = 10;
my $e = $mw->NumEntry(
-minvalue => 0,
-maxvalue => 100,
);
my $s = $mw->Scale(
-from => 0,
-to => 100,
-orient => 'horizontal',
);
my $l = $mw->Label(-textvariable=>\$wert,);
$e->configure(
-validate => 'key',
-vcmd => sub{ setScale($e, $s, $wert); },
);
$e->pack();
$s->pack();
$l->pack();
Tk::MainLoop;
sub setScale {
my ($e, $s, $wert) = @_;
my $zw = $e->get();
if( $zw =~ m/.{0,0}/ ){
print "Feld leer ($zw)!\n";
}
}
QuoteFeld leer (100)!
Feld leer ()!
![]() |
|< 1 2 >| | ![]() |
16 Einträge, 2 Seiten |