I can't see how POE and Tk are fighting - they cooperate. POE queues the main window's destroy event and passes control to Tk. POE code is called from Tk's event dispatcher; then POE uses Tk's event loop handler inside it's own event loop to serve Tk events from inside it's own event loop.
But if by fighting you mean loading order you're right - POE has support for Tk, not the other way round, so you have to load POE first, and access the Main Window via $poe_main_window:
use POE qw(Loop::Tk);
POE::Session->create(
inline_states => {
_start => sub { $_[KERNEL]->yield("next") },
next => sub {
print "tick...\n";
$_[KERNEL]->delay(next => 1);
},
},
);
$button = $poe_main_window->Button(
-text => 'Press me',
-command => sub { exit; },
)->pack();
$poe_kernel->run();
I haven't found a way (yet) to successfully load POE at some time within a running Tk application and shoehorn its event dispatcher somehow into the Tk event loop.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|