Ok, I've only been working with Python for something like 4 days now and I'm stuck trying to do a certain thing in Tkinter. Now, just to get you into the situation here. I've created a little program that has an entry bar and a go button. It says for you to enter in your name in the entry box and click the go button. What should happen is after the person enters in his/hers name and clicks the go button it should print something like Hello, "name" inside the window as a label or in a separate window as a label. but the best I can manage is something like:
def GoButtonClick(self, event)
print "Hello,", self.entryfield.get()

but that prints the Hello, Name in the prompt. Is it possible to do what I'm trying to do or am I thinking on to grand a scale?

Using: Windows ME, Tkinter, Python 3.something in the .20's

Help is appreciated. :cheesy:

Check this code, you may be able to use portions for your project ...

# Tkinter, explore the entry field 

from Tkinter import *

def show():
    # clear the label
    label2.config(text='')
    # get the enter1 text and show it in label2
    label2.config(text='Hello ' + enter1.get())

# create root window
root = Tk()

# create label1
label1 = Label(root, text='Enter your name below:')
label1.pack(side=TOP, fill=X)   # topmost

# creaet entry field
enter1 = Entry(root)
enter1.pack(side=TOP, fill=X)   # below label1
# start entry1 empty
enter1.insert(0, '')
# put cursor into entry1 field
enter1.focus()
# you can either press the enter key or click the button to move text to label2
enter1.bind('<Return>', (lambda event: show()))

# create label2
label2 = Label(root, bg='yellow', anchor=W)
label2.pack(side=TOP, fill=X)   # below entry1

# or get entry text clicking on button
btn1 = Button(root, text='Get Text', command=show)
btn1.pack(side=LEFT)  # below label2

# start the event loop (run the program)
root.mainloop()

Well, looks as if it might work. But there is one thing, is it possible to make it print with an event bind?(at least i think that is what it is called) Mainly because I'm not familliar with the command = show thing.

Well, looks as if it might work. But there is one thing, is it possible to make it print with an event bind?(at least i think that is what it is called) Mainly because I'm not familliar with the command = show thing.

much less the lambda thing

Okay, here is a less complex version using just bind and passing an event argument to show() ...

# Tkinter, explore the entry field (use bind, no lambda)

from Tkinter import *

def show(event):
    # clear the label
    label2.config(text='')
    # get the enter1 text and show it in label2
    label2.config(text='Hello ' + enter1.get())

# create root window
root = Tk()

# create label1
label1 = Label(root, text='Enter you name below:')
label1.pack(side=TOP, fill=X)   # topmost

# creaet entry field
enter1 = Entry(root)
enter1.pack(side=TOP, fill=X)   # below label1
# start entry1 empty
enter1.insert(0, '')
# put cursor into entry1 field
enter1.focus()
# you can either press the enter key or click the button to move text to label2
enter1.bind('<Return>', show)   # bind to pressing of the ENTER key

# create label2
label2 = Label(root, bg='yellow', anchor=W)
label2.pack(side=TOP, fill=X)   # below entry1

# or get entry text clicking on button
btn1 = Button(root, text='Get Text')
btn1.pack(side=LEFT)            # below label2
btn1.bind('<Button-1>', show)   # bind to left mouse click

# start the event loop (run the program)
root.mainloop()
This question has already been answered. Start a new discussion instead.