banging head against sys.stdin and tkinter on win32

David Mallwitz dmallwitz at cox.rr.com
Tue Dec 11 01:44:56 EST 2001


thump thump thump

    A few weeks ago I decided to try to become more proficient in Python by
writing a plain vanilla GUI app that interfaces with a serial port. Turns
out to have been pretty straightforward and everything is now at least
working, if not working the way I want it to. The program is a single
Tkinter text widget in its own thread to display everything that is read
from the serial port, another thread to read from that port, and one more
thread to continuously read input from the user. I don't need to process any
input from the user, just send it straight to the device attached to the
serial port.
    So far no problem. I've been using a while 1 loop and msvcrt to poll for
any keystrokes, but this keeps a console window open and all commands must
be typed in that window. I'd like to 86 the console and just have all
input/output done on the display window (I'm familiar with the .pyw filename
trick, won't work, msvcrt need that console window to function). This is
where the headbanging thing happens.
    I've tried wrapping the window in a class and defining a read method in
order to redirect sys.stdin - no joy, msvcrt just wants to use a console
window no matter what. I used an Entry widget for a while, but the number of
bind statements was prohibitively long, and would all need to be changed if
I tried to communicate with a different type of device. Input and raw_input
don't really apply here since I need to work on a character by character
basis and not wait for \n to terminate a string.
    Am I even on the right track here? I'll gladly RTFM if someone will
point me to where an appropriate FM is. For that matter, where is the source
code for msvcrt? There is no file with that name in my Python path (or
anywhere else), yet I have to import it as a module.

Best,
Dave






-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----



More information about the Python-list mailing list