Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Term::ReadLine and Tk - Solved

by qaz (Sexton)
on Mar 15, 2008 at 21:48 UTC ( #674386=perlquestion: print w/ replies, xml ) Need Help??
qaz has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I am making a Term::ReadLine based shell and I would like to put in some Tk windows and functionalities in it. The problem is the combination of the Tk main loop and readline...

Perldoc for Term::ReadLine says

... tkRunning
makes Tk event loop run when waiting for user input (i.e., during readline method). ...

but I can't really make it work and there is very little information on the subject.

Does anyone knows how to make Term::ReadLine an Tk play together?

Thanks in advance.

Comment on Term::ReadLine and Tk - Solved
Re: Term::ReadLine and Tk
by my_nihilist (Sexton) on Mar 15, 2008 at 23:50 UTC
    How did you try?
Re: Term::ReadLine and Tk
by qaz (Sexton) on Mar 16, 2008 at 07:31 UTC
    Well, apparently it is working...
    I feel silly, shouldn't have posted for this...
    #!/usr/bin/perl use warnings; use Term::ReadLine; use Tk; $mw = MainWindow->new; $mw->geometry('500x400'); $mw->title ("Title"); my $term = new Term::ReadLine 'Perl shell'; my $OUT = $term->OUT || \*STDOUT; $term->tkRunning(1); while ( defined ($_ = $term->readline('Poil Shell >')) ) { my $res = eval($_); warn $@ if $@; }
      That's cool to know, I've added it to my snippet collection. By the way, you can usually run 2 (or more) event-loop systems simultaneously, by having the master loop run a timer( at a fast interval ) to do a 1-loop update of all the slave loops.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-07-10 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (197 votes), past polls