-1

I have a program I am writing that has a root Tk() window as well as an admin Toplevel() that opens based on a condition. Inside the admin toplevel I have an Entry() however I cannot use .get() without getting this error

AttributeError: 'NoneType' object has no attribute 'get'

Here is a sample code of my problem

import tkinter
from tkinter import *

root = tkinter.Tk()
root.minsize(width=800, height = 600)
root.maxsize(width=800, height = 600)

def proceed():
    admin = tkinter.Toplevel()
    admin.minsize(width=800, height = 600)
    admin.maxsize(width=800, height = 600)

    entry = Entry(admin).pack()
    entry.get()

button = Button(root, text="Proceed", command=proceed).pack()

mainloop()
Shniper
  • 854
  • 1
  • 9
  • 31

1 Answers1

2

Where you assign entry = Entry(admin).pack() you are calling the pack method of the created widget which returns None so entry gets assigned None. Assign entry = Entry(admin) and then pack or grid the widget.

The same problem will occur when you try and assign button.

patthoyts
  • 32,320
  • 3
  • 62
  • 93