Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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.

Replies are listed 'Best First'.
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
Re: Term::ReadLine and Tk
by my_nihilist (Sexton) on Mar 15, 2008 at 23:50 UTC
    How did you try?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://674386]
Approved by FunkyMonk
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-03-22 11:14 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (273 votes). Check out past polls.