-1

I'm working on a project in Tkinter. Entries work perfectly fine for me, but as soon as I create an entry inside a top level window, I can neither insert any text, nor retrieve any input of the entries.

Here is a sample code:

from tkinter import *


window = Tk()
window.geometry('1000x580')

popup=Toplevel(window)
popup.geometry("300x400")

entrycolumns=Entry(popup, width=5).place(x=100,y=130)
entryrows=Entry(popup,width=5).place(x=160,y=130)

#entryrows.insert(0,"test")
#entryrows.get()


popup.mainloop()

window.mainloop()

Everything displays fine.

enter image description here

But as soon as I 'uncomment' and include any of those two lines for example

#entryrows.insert(0,"test")
#entryrows.get()

in order to work with the entries, I get this error message:

entryrows.insert(0,"test") AttributeError: 'NoneType' object has no attribute 'insert'

Process finished with exit code 1

It does not recognize the entries as entries anymore. Is there any way to make Entry widgets that are inside a top level window functional and accessible?

1 Answers1

0
from tkinter import *

window = Tk()
window.geometry('1000x580')

popup = Toplevel(window)
popup.geometry("300x400")

entrycolumns = Entry(popup, width=5)
entryrows = Entry(popup, width=5)

entryrows.insert(0, "test")
entryrows.get()

entrycolumns.place(x=100, y=130)
entryrows.place(x=160, y=130)

popup.mainloop()
window.mainloop()

output of UI UI output

I hope it will work for you

Ramesh
  • 504
  • 5
  • 9
  • 2
    Oh yes, I see. I saved the entry.place command as 'entrycolums'. When defining the variable I cannot immediately place the widget. Thanks! – Tricky Devil Jul 12 '22 at 16:38