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
use Device::SerialPort;
use AnyEvent;
my $ ob = Device::SerialPort-> new ( '/dev/pts/2') || die;
my $main = AnyEvent->condvar;
$t = AnyEvent->timer( interval => 1, cb => sub {
$tmp = $ob->read(1900);
$tmp1 = substr($tmp, 3, 66);
@s = split(/\s+/, $tmp);
print $s[2] . "\n";
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
sub gewicht {
my ($self, $event) = @_;
my $timer = AnyEvent->condvar;
my $t = AnyEvent->timer( interval => 1, cb => sub {
my @wert = wiegen(1);
$self->{kg}->SetLabel($wert[2]);
});
$timer->recv;
}
2010-05-06T12:24:05 esskardu musst Wx::Timer benutzen.
1
2
3
4
5
6
7
sub gewicht {
my ($self, $event) = @_;
my @wert = wiegen(1);
$self->{kg}->SetLabel($wert[2]);
}
2010-05-07T08:40:40 esskarich denke mal, das $self ist jetzr der timer und nicht dein object.
(ich rate hier nur, hab damit selber noch nie was gemacht, versuche nur das einzusetzen, was ich sonst so über timer und callback signaturen von anderen systemen weiß).
1
2
3
4
5
6
sub gewicht {
my ($self, $event, $timer) = @_;
my @wert = wiegen(1);
$timer->{kg}->SetLabel("ja")
}
1
2
3
4
5
6
sub gewicht {
my ($self, $event, $timer) = @_;
my @wert = wiegen(1);
$timer->SetLabel("ja")
}
Wx::Event::EVT_TIMER($timer, -1 , \&gewicht);
1 2 3
my $timer = Wx::Timer->new( $self, -1 ); Wx::Event::EVT_TIMER($self, -1, sub { shift->gewicht } ); $timer->Start( 1 * 1000, 0 );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
sub start_timer { # set or update timer events my $win = Kephra::App::Window::_ref(); my $config = Kephra::API::settings()->{file}; stop_timer(); if ($config->{open}{notify_change}) { $timer{file_notify} = Wx::Timer->new( $win, 2 ); $timer{file_notify}->Start( $config->{open}{notify_change} * 1000 ); Wx::Event::EVT_TIMER( $win, 2, sub { Kephra::File::changed_notify_check() } ); } if ($config->{save}{auto_save}) { $timer{file_save} = Wx::Timer->new( $win, 1 ); $timer{file_save}->Start( $config->{save}{auto_save} * 1000 ); Wx::Event::EVT_TIMER( $win, 1, sub { Kephra::File::save_all_named() } ); } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
$self->{timer} = Wx::Timer->new();
$self->{timer}->Start(1000);
$self->__set_properties();
$self->__do_layout();
Wx::Event::EVT_TIMER($self->{timer}, -1 , \&gewicht);
...
sub gewicht {
my ($self, $event) = @_;
my @wert = wiegen(1);
$self->{kg}->SetLabel("ja")
}
...