[Tutor] bind line-oriented device output?

Tom Roche Tom_Roche at pobox.com
Mon Mar 29 17:56:03 CEST 2010

>> I'd like to learn to pythonically redirect the output from a
>> line-oriented character device to a particular file or process,
>> regardless of focus, on a generic graphical OS. But I don't want to
>> redirect stdin entirely.
>> It Would Be Nice, and useful for this seminar's mechanics, to be
>> able to run some code to which one could say, see this device? and
>> this file? Make the device's output go only to that file. For extra
>> credit, don't let anything else write that file while this code is
>> running.

> if you can assure that the target computer will be running a certain
> set of python features (i.e. Tkinter/pyGTK+/wxPython, etc)

Presuming they're available on the user's platform and not too onerous
to install, I can definitely say, "if you want <goodness/>, you need
to install <necessaries/>."

> you can fairly easily write a program that will run fullscreen and
> continually grab focus to whatever widget (in this case a text entry
> field) you want.

*Continually* grabbing focus to a UI is functionally (from the user's
point of view) equivalent to redirecting stdin, no? The user is made
unable to do anything but take attendance for the duration of the
task. In fact, for this usecase, continually grabbing focus is worse,
since the user would be unable to, e.g., read the directions for
setting up the audio. To clarify the usecase:

The barcode scanner (here, a Wasp WLS9500) is connected to an ordinary
multiprocessing laptop (which may be linux, mac, or windows) on which
the user will want to do other things while taking attendance: the
attendees don't come in all at once, and the user must accomplish
other tasks while taking attendance (notably setting up to record the
seminar audio). Hence the desired application

0 is portable.

1 does not redirect all of stdin, only the output from the scanner.
  The user is allowed to continue to work on other tasks (e.g. with
  output from the laptop's keyboard going to whatever frame), with
  only the output from the scanner being bound to a particular file or

2 does not continually grab focus. The user is allowed to continue to
  work on other tasks (e.g. with output from the laptop's keyboard
  going to whatever frame), with only scanner events being bound to a
  particular frame or widget.

But what might satisfy the usecase is

> if the device is something like the CueCat and reports a control
> character (I think it's alt+f7 for the cuecat), then at least on
> linux/windows I think it's much more trivial. You just have to
> register a global hotkey handler that will send the focus to that
> particular window.

I'll read the Product Reference Guide and hope it tells me that the
Wasp WLS9500 "reports a control character." Unfortunately when I
search the PDF


for "control character" I get no hits. Are there synonyms for that
term in this context?

TIA, Tom Roche <Tom_Roche at pobox.com>

More information about the Tutor mailing list