Python Forum

Full Version: Trouble getting data from an entry.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
from tkinter import *
from pytube import YouTube
from pytube import Playlist
from pytube.cli import on_progress

root = Tk()
root.title('Masked YT Video Downloader')

#functions
def find_vid(url):
    return

def check(url):
    if url.startswith('https://www.youtube.com/') or url.startswith('https://www.youtube.com/'):
        find_vid(url)
    else:
        error = Label(root, text = 'Please Enter a YouTube Url.')




#Widgets
name = Label(root, text = 'Masked YT Video Downloader', font = ("arial", 25, "bold"), fg = "Steel Blue", bd = 10).pack()
by = Label(root, text = 'by hehehe', font = ("arial", 15, "bold"), fg = "#cc5c54", bd = 10).pack()
enter_url = Label(root, text = 'Enter YouTube Url').pack()
url_box = Entry(root, borderwidth = 4, width = 60).pack(pady = 5)
find_btn = Button(root, text = 'Find', command = lambda : check(url_box.get())).pack()


root.mainloop()
Error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1885, in __call__ return self.func(*args) File "D:\3. My folder\Projects\Programing\Python\YouTube Video Downloader\Masked YT Video Downloader.py", line 27, in <lambda> find_btn = Button(root, text = 'Find', command = lambda : check(url_box.get())).pack() AttributeError: 'NoneType' object has no attribute 'get'
Why does this happen!?
Because url_box is None.
I think the problem is the .pack integrated into one line,
I've seen this before, can cause problems, try this line instead for the entry:

url_box = Entry(root, borderwidth = 4, width = 60)
url_box.pack()