Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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:


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?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (15)
As of 2014-10-21 18:26 GMT
Find Nodes?
    Voting Booth?

    For retirement, I am banking on:

    Results (106 votes), past polls