Brennan Wilkes
Brennan Wilkes

Reputation: 213

Tkinter .get() returns {}

I'm trying to create a variable from the text box petals, but when I display the entry, all it says is 'You entered {}'

I have imported everything I need to import, and I run python 2.7 on OS 10.9

def beenclicked():
    tkMessageBox.showinfo("You entered"+petals.get()) 


gui=Tk()
gui.title("Flower Creator")

label1= Label(gui, text="Number of petals:")
label1.pack(side='top',pady=10)

petals = Entry(gui)
petals.pack(side='top')

button1 = Button(gui, text="Generate flower", width=20, command=beenclicked) 
button1.pack(side='bottom',pady=15,padx=15)




gui.mainloop()

Upvotes: 0

Views: 69

Answers (1)

BartoszKP
BartoszKP

Reputation: 35891

The first argument to showinfo is the title. Try like this:

tkMessageBox.showinfo("You entered:", petals.get())

You probably didn't saw user's input, because it was in the dialog window's title and the window doesn't scale automatically for the title to fit. The dialog content was empty, because you provided only the title.

Upvotes: 1

Related Questions