in reply to Tk and Threads (again)

You are running into the same roadblock everyone who runs threads with Tk encounters. You cannot pass a Tk widget to a thread, even if it isn't going to do anything. So that accounts for your "wrong pool" error, and there isn't anyway around it with Tk.

Now the question is "how to do it, while keeping the GUI thread-safe?" The #1 idea could be done by forking off and communicating with sockets....but that is probably harder than the threads.

#2b is the way I usually do it. Have shared variables, which can be set by the threads and read by the Main-GUI thread with a timer. When the GUI sees the flag, it processes the data for display, and possibly closes off the thread( or puts it to sleep for later use). A timer is not that much over head, and is a clean easy-to-use solution.

You can mix Gtk2( what Wx is based on) and Tk. But you will still have to use a timer to call the "do-one-loop" iteration of the secondary gui; that keeps the secondary gui from freezing. Here is a Tk MainLoop running a Gtk2 loop. (It can be done the other way too)

#!/usr/bin/perl -w use strict; use Gtk2; use Tk; my $mw = MainWindow->new(-title=>'Tk Window'); Gtk2->init; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Gtk2 Window'); my $glabel = Gtk2::Label->new("This is a Gtk2 Label"); $window->add($glabel); $window->show_all; my $tktimer = $mw->repeat(10, sub{ Gtk2->main_iteration while Gtk2->events_pending; }); $mw->Button(-text=>' Quit ', -command => sub{exit} )->pack(); MainLoop; ######################################## __END__

You might want to look at the newest Gtk2-Perl threads demo. They have an example that might be what you are looking for. They have a "thread-safe" mode that lets you share some widgets in threads, and "enter" and "leave" the thread to update the threaded widgets.


I'm not really a human, but I play one on earth. flash japh