[Tkinter-discuss] Newbie needs help with entrybox
Simon Pickles
sipickles at hotmail.com
Wed Jun 6 18:18:31 CEST 2007
Hello, I am new to python and tkinter, but enjoying it so far.
In trying to make a simple GUI I have stumbled on a problem binding an event
to a function. I've got a listbox for output and an entrybox for input. How
do I act on the text in the entry box when return is pressed?
Here's my attempt:
# GUI
from Tkinter import*
import tkMessageBox
from time import ctime, time
class CGUI:
def __init__(self, master):
frame = Frame(master, name="server")
frame.pack()
self.output = Listbox(frame, width=100, height=30)
self.output.grid(row=0, column=0)
self.inputBox = Entry(root, bd=5, width=100)
self.inputBox.bind( "<KeyPress-Return>",
self.__ParseInput(self.inputBox.get()) )
self.inputBox.pack(side=BOTTOM, expand=YES, fill=BOTH)
def __ParseInput(self, s):
self.output.insert(END, s)
root = Tk()
gui = CGUI(root)
-------------------------------------------------------------------------
Your advice appreciated!
Thanks
Simon
http://www.simonpickles.com --- http://www.squirtualreality.com
_________________________________________________________________
The next generation of Hotmail is here! http://www.newhotmail.co.uk/
More information about the Tkinter-discuss
mailing list