I'm new to Python and I'm struggling to figure out what's wrong with my code.
import tkinter as tk
r = tk.Tk()
r.title('PROJECT')
def file_entry():
global ent
tk.Label(r, text = "ENTRY").grid(row = 2)
ent = tk.Entry(r).grid(row = 2, column = 1)
b_ent = tk.Button(r, text="OK", width = 5, command = print_input).grid(row = 2, column = 2)
def print_input():
print(ent.get())
l = tk.Label(r, text="OPTION 1 OR 2?").grid(row = 0)
b = tk.Button(r, text='1', width=25, command=file_entry).grid(row = 1,column = 0)
b2 = tk.Button(r, text='2', width=25, command=r.destroy).grid(row = 1,column = 1)
r.mainloop()
I'm trying to call "ent", but every time I run it, it would give me an error for it being a NoneType.
Like I said, I'm new to Python, and this is a school project, it would really be helpful if someone could explain what the problem is, as simply as possible.
Thanks!