use Tk; use POE; POE::Session->create( inline_states => { _start => \&handle_start, ev_count => \&handle_count, ev_clear => \&handle_clear, } ); POE::Kernel->run(); exit 0; sub handle_start { $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 handle_count { $_[HEAP]->{counter}++; $_[KERNEL]->yield("ev_count"); } sub handle_clear { $_[HEAP]->{counter} = 0; }