Thread Counter aus dem POE-Cookbook (3 answers)
Opened by Froschpopo at 2005-04-11 14:50

Froschpopo
 2005-04-11 14:50
#43437 #43437
User since
2003-08-15
2653 Artikel
BenutzerIn
[default_avatar]
Wieso bitte wird $heap->{counter} erhöht ? Ich kann niergenswo ne schleife finden oder eine Funktion die ui_count() immerwieder aufruft... ?
Code: (dl )
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
#!/usr/bin/perl

use warnings;
use strict;

# Tk support is enabled if the Tk module is used before POE itself.

use Tk;
use POE;

# Create the session that will drive the user interface.

POE::Session->create(
inline_states => {
_start => \&ui_start,
ev_count => \&ui_count,
ev_clear => \&ui_clear,
}
);


$poe_kernel->run();

exit 0;

sub ui_start {
my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];

$poe_main_window->Label( -text => "Counter" )->pack;

$heap->{counter_widget} =
$poe_main_window->Label( -textvariable => \$heap->{counter} )->pack;

$poe_main_window->Button(
-text => "Clear",
-command => $session->postback("ev_clear")
)->pack;

$kernel->yield("ev_count");
}

sub ui_count {
$_[HEAP]->{counter}++;
$_[KERNEL]->yield("ev_count");
}

sub ui_clear {
$_[HEAP]->{counter} = 0;
}

View full thread Counter aus dem POE-Cookbook