Python Forum
[Tkinter] Trouble getting data from an entry.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Trouble getting data from an entry.
#1
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!?
Reply
#2
Because url_box is None.
Reply
#3
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()
Oshadha likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Grid data entry problem kenwatts275 3 2,244 Mar-22-2020, 03:13 PM
Last Post: kenwatts275
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,420 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 3,451 Mar-18-2019, 05:36 PM
Last Post: woooee
  [Tkinter] Thousand Separator Entry Widget Cursor Pos Trouble papatubies 4 5,133 Jul-24-2017, 02:51 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020