in reply to MainLoop control

Another option, is to name your maindows in the other Tk scripts differently (like $mw1, $mw2,$mw3 , etc, then don't call MainLoop in those secondary windows, but do-one-loop manually. Its a bit more complex than fork-and-exec, but you asked for manual mainloop control.
#!/usr/bin/perl use warnings; use strict; use Tk qw/tkinit DoOneEvent exit DONT_WAIT ALL_EVENTS/; my $mw = tkinit; $mw->Button( -text => 'Test', -command => sub { print "Pushed\n" }, )->pack(); $mw->Button( -text => 'Quit', -command => sub { Tk::exit(0) }, )->pack(); my $I; while (1) { $mw->DoOneEvent( DONT_WAIT | ALL_EVENTS ); if ( ++$I > 10000 ) { #slows things down use 1 for max speed print '.'; $I = 0; } }
So instead of calling MainLoop in the secondary scripts, you do
sub manual_loop_control { $mw1->DoOneEvent( DONT_WAIT | ALL_EVENTS ); $mw2->DoOneEvent( DONT_WAIT | ALL_EVENTS ); $mw3->DoOneEvent( DONT_WAIT | ALL_EVENTS ); }
in a timer in your main Tk script, like
$mw->repeat(10, \&manual_loop_control);
Using this method, you can even combine Gtk2 and Tk (any event loop script) and run them simultaneously.

I'm not really a human, but I play one on earth. Cogito ergo sum a bum