in reply to MainLoop control
So instead of calling MainLoop in the secondary scripts, you do#!/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; } }
in a timer in your main Tk script, likesub manual_loop_control { $mw1->DoOneEvent( DONT_WAIT | ALL_EVENTS ); $mw2->DoOneEvent( DONT_WAIT | ALL_EVENTS ); $mw3->DoOneEvent( DONT_WAIT | ALL_EVENTS ); }
Using this method, you can even combine Gtk2 and Tk (any event loop script) and run them simultaneously.$mw->repeat(10, \&manual_loop_control);
|
|---|