Here is a simple example. It is not well structured but it should give you the idea.
from Tkinter import *
def showText(evt):
print 'Text is:', text.get('0.0', END)
return 'break' # Prevent the event from propagating to the Text widgetroot = Tk() text = Text()
# This line binds the showText handler to the <Return> key event
text.bind('<Return>', showText)
text.pack()
root.mainloop()
Kent
Diana Hawksworth wrote:
I am using the tkinter toolkit. Just wish to have the button I have formed replaced by the Enter key - if possible. Would the raw_input() work, as Bernard has suggested, or do I need another piece of code that refers to the Enter key?
Thanks. Diana
----- Original Message ----- From: "Kent Johnson" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Tuesday, April 05, 2005 7:20 AM
Subject: Re: [Tutor] using the enter key
Diana Hawksworth wrote: > At the moment I have some user input tied to a button that allows the
input to be "submitted" and then an answer is supplied. How can I get rid of this submit button, and have the user just press the "enter" key and have the same result happen?
How is the user interface built? Are you using a GUI toolkit like Tkinter
or wxPython or is it a web
form?
Kent
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
