in reply to POE, Tk, Simultaneous problem!

Test case code (below) generates the errors shown. Looks like POE doesn't do Tk.

* * POE can't use multiple event loops at once. * You used Select and Tk. * BEGIN failed--compilation aborted at C:/Perl/site/lib/POE/Kernel.pm li +ne 491. Compilation failed in require at (eval 14)[C:/Perl/site/lib/POE.pm:40] + line 1. BEGIN failed--compilation aborted at (eval 14)[C:/Perl/site/lib/POE.pm +:40] line 1. could not import qw(Kernel) at noname.pl line 4 BEGIN failed--compilation aborted at noname.pl line 4.
use warnings; use strict; use Tk; use POE; my $killAll = 0; POE::Session->create (inline_states => {_start => \&startApplication, searchmode => \&sea +rchMode}); POE::Session->create (inline_states => {_start => \&searchUpdate}); POE::Kernel->run(); # Relevant is also: sub startApplication { my $main = MainWindow->new; $main->Toplevel(-title => "Search"); MainLoop; $killAll = 1; } sub searchUpdate { while (! $killAll) { sleep 1; print '.'; } }

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: POE, Tk, Simultaneous problem!
by Ace128 (Hermit) on Sep 28, 2005 at 06:03 UTC
    Change that too:
    use warnings; use strict; use Tk; use POE; my $killAll = 0; POE::Session->create (inline_states => {_start => \&startApplication, searchmode => \&sea +rchMode}); POE::Session->create (inline_states => {_start => \&searchUpdate}); POE::Kernel->run(); # Relevant is also: sub startApplication { $poe_main_window->Toplevel(-title => "Search"); $killAll = 1; } sub searchUpdate { while (! $killAll) { sleep 1; print '.'; } }
    That is,
    use $poe_main_window (which is exported Tk Window by POE).
    remove the MainLoop (guess that its's not used with POE!)

      Actually you only need:

      use warnings; use strict; use Tk; use POE;

      to get the error! Something to do with how the Tk event loop gets replaced by the POE event loop. The documentation is not clear on this matter!

      I'm doing this on Windows with ActiveState Perl. There may be issues that a different if you are using a different platform or cygwin Perl.


      Perl is Huffman encoded by design.
        Im also useing Windows with ActiveState Perl. Latest perl (This is perl, v5.8.7 built for MSWin32-x86-multi-thread) and not latest POE (didnt exist on activestate!) (v0.29) and I dont have problems running that small testscript.