Skip to content Skip to sidebar Skip to footer

Python Tkinter's Entry.get() Does Not Work, How Can I Fix It?

I am building a simple program for university. We have to convert our code to an interface. Ive managed to make the interface, but i cant seem to pass my values from Entry to the a

Solution 1:

You cannot create the widget and grid it at the same time like this, if you still need to access it later. stock_Entry.get() will raise an AttributeError (NoneType).

Instead of:

stock_Entry= ttk.Entry(mainframe, width = 60, textvariable="stock").grid(column=0, row = 1, sticky=W)

use:

stock_Entry = ttk.Entry(mainframe, width =60, textvariable="stock")
stock_Entry.grid(column=0, row=1, sticky=W)

Same for the Quantity_Entry:

Quantity_Entry = ttk.Entry(mainframe, width =60, textvariable="Quantity")
Quantity_Entry.grid(column=0, row=2, sticky=W)

...and it works:

enter image description here

Post a Comment for "Python Tkinter's Entry.get() Does Not Work, How Can I Fix It?"