On Mon, 23 Jan 2006 13:06:53 -0500
"Michael Solem" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I want to create a program to talk to the com port
> (something like hyperterminal or minicom).  The display should be a
> box that outputs characters as they come in (from the port), and
> accepts characters as input, which it sends to the port.  Characters
> entered on the screen should not be shown on the screen (which is the
> default behavior of hyperterm and minicom).
> 
> I was planning on using the Tkinter Text widget for this, but see no
> way of having the user enter data, without it showing up on the
> screen.  Is there a way to do that?  Is there another widget that can
> do it?  
> 

Hi Michael,

you need to bind a special callback to the KeyPress events, like this one:

>>> from Tkinter import *
>>> root = Tk()
>>> text = Text(root)
>>> text.pack(fill=BOTH, expand=1)
>>> def keypress(event):
...     print event.keysym
...     return 'break'
... 
>>> text.bind('<Any-KeyPress>', keypress)

As you see in the example you can use the event.keysym attribute to catch the 
character
that would have been entered into the Text widget and the return "break" 
statement to
prevent the event from being delivered to the Text widget's insertion mechanism.

I hope this helps

Michael
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to