in reply to Wx with Tk
Yes you can mix 2 or more eventloop systems by making one loop the master controlling loop, and all others, as slaves. The slaves get pumped by a timer call in your master loop, which tells each looping system, to do one loop. You will need to call this timer often, to make all the widgets seem responsive.
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
I don't have Wx going, but here is an example mixing Gtk2 and Tk
The same principle should work for you with Tk and Wx. Just find the Wx command to execute 1 loop, and manually call it from Tk.... or vice/versa#!/usr/bin/perl -w use strict; use Gtk2; use Tk; #setup Tk loop my $mw = MainWindow->new(-title=>'Tk Window'); my $count_tk = 0; my $labtk = $mw->Label(-textvariable =>\$count_tk)->pack; #setup Gtk2 loop Gtk2->init; my $count_gtk = 0; my $window = Gtk2::Window->new('toplevel'); $window->set_title('Gtk2 Window'); my $glabel = Gtk2::Label->new("This is a Gtk2 Label $count_gtk"); $window->add($glabel); $window->show_all; # make Tk loop the master, but you could make Gtk2 master if desired # the lower the repeat rate, i.e. 1 ms, # will give more cpu time to the gtk2 loop # this is sometimes called manually pumping the event loop my $tktimer = $mw->repeat(10, sub{ $count_gtk++; $glabel->set_text("This is a Gtk2 Label $count_gtk"); Gtk2->main_iteration while Gtk2->events_pending; $count_tk++; }); $mw->Button(-text=>' Tk control Quit ', -command => sub{exit} )->pack(); MainLoop; #######################################
But in all honesty, you should be able to find a set of widgets, all from the same toolkit, so you wouldn't need this hackery.
Why can't you use the Canvas from Wx?
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Wx with Tk
by Khariton (Sexton) on Nov 22, 2010 at 20:07 UTC | |
by zentara (Archbishop) on Nov 23, 2010 at 13:48 UTC | |
by Khariton (Sexton) on Nov 24, 2010 at 19:16 UTC | |
by zentara (Archbishop) on Nov 25, 2010 at 12:02 UTC | |
by Khariton (Sexton) on Nov 25, 2010 at 18:28 UTC | |
| |
by Anonymous Monk on Nov 23, 2010 at 14:02 UTC | |
by zentara (Archbishop) on Nov 23, 2010 at 14:14 UTC |
In Section
Seekers of Perl Wisdom