Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: AnyEvent + Wx, Gtk2/3 or Tk ?

by zentara (Archbishop)
on Dec 10, 2012 at 10:57 UTC ( #1008085=note: print w/ replies, xml ) Need Help??


in reply to [Solved] AnyEvent + Wx, Gtk2/3 or Tk ?

I have read that Wx is faster than Tk

I'm not sure where you heard that, or what sort of application they were talking about.

If you want a filehandle watcher in Gtk2, you can do that, Gtk2 is pretty good in my book, although I never had trouble with Tk's speed, unless the number of widgets were very large.

You can run mixed event loops by making one loop a master, and the other a slave. The slave loop gets pumped every so many milliseconds by a timer in the master loop. See Wx with Tk and here below is a Gtk2-Tk hybrid script. It may be useful.

#!/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; ########################################

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


Comment on Re: AnyEvent + Wx, Gtk2/3 or Tk ?
Download Code
Re^2: AnyEvent + Wx, Gtk2/3 or Tk ?
by mascip (Pilgrim) on Dec 10, 2012 at 12:49 UTC

    If i understood well, AnyEvent is made so that one doesn't need to "plug" loops together manually, like you just showed me how to do (thank you!).
    I think i'll go for an EV loop, with Gtk2 embedded (or Gtk3 if it works).

    My question was very naive : it's the first time in years that i implement a GUI, and the first time that i use events too.
    Thank you for reassuring me that Tk and Gtk2 are not slow. I don't remember where i read that Wx was faster, but these words can make newbies like me imagine that not-Wx is bound to be slow.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008085]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (17)
As of 2015-07-06 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls