Reply to topic  [ 3 posts ] 
How to wait without discarding keyboard input? 
Author Message
Yorick Master

Joined: Wed Jun 01, 2005 11:34 am
Posts: 112
Post How to wait without discarding keyboard input?
Is there a wait to make Yorick wait without discarding keyboard input?

I can't use pause, because keyboard input interrupts the wait and is then discarded.

I can't use suspend/resume because, again, keyboard input is discarded (with the slightly misleading message message "WARNING discarding keybaord input during window wait"; no window waits are involved).

Here's my scenario:

I have Yorick running under Expect in Tcl/Tk. So Tcl can control Yorick by sending commands via Expect. Additionally, I have a pair of pipes running in the background that let Yorick send commands to Tcl and Tcl send commands to Yorick without involving Expect.

What I want to do is embed a Yorick window in a Tcl window. I can use window, parent=<id> for that. However, I want Yorick to initiate the process. That means it needs to ask Tcl to create its window and then has to wait for Tcl to send back the window ID. So the pseudocode process would be:

Yorick asks Tcl to create the GUI
Yorick suspends
(in the background, Tcl sends the window ID back and calls "resume")
Yorick resumes and creates the window

Using suspend/resume lets me handle that tidly enough. However, the next step of what I want to do is what causes the problem: I want Tcl to be able to send a series of commands via Expect. When the above is in the mix, several of the commands in the series get discarded due to the wait condition.

There are ways to circumvent this need, but I keep running into it and a lot of the ways I've circumvented it are less than ideal. It'd be much simpler if there were a variant of suspend that didn't discard keyboard input. Is there something like that that I just haven't found?


Tue Aug 21, 2012 1:22 pm
Profile
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post Re: How to wait without discarding keyboard input?
Probably the short answer is no.

Your problem sounds like you need to throttle expect/tcl, so isn't it easy to have expect block waiting for an explicit acknowledgement that yorick has has created its window (which you want to do with the wait=1 keyword to avoid more similar race conditions)? So on the yorick side you do

write,"EXPECT:STOP";
window,id=xxx,wait=1;
write,"EXPECT:GO";

and on the expect side, when you see the first message you pause until you get the second.

After all, expect was designed specifically to make exactly this sort of interprocess communication easy, while yorick was not, so it doesn't seem too demanding to ask you to play to the strengths of the respective programming languages...


Wed Aug 29, 2012 8:14 pm
Profile
Yorick Master

Joined: Sun Sep 26, 2004 10:33 am
Posts: 150
Location: Australia
Post Re: How to wait without discarding keyboard input?
gosh, I should have a look at the forum more often.

What I always do in that case is to call the window init yorick function from the gui handling language (in your case tcl, in my case python). In pygtk, there is an event "window realized" or something similar. You can put a python (tcl) callback that will get called when this event is realized and call the yorick function to create the window(s) from there.
Sorry to be so late, I assumed you found a solution since then.


Mon Dec 17, 2012 6:13 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.