-1

I don't understand what is wrong with this code it keeps saying:

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

Code:

# initial variables

from tkinter import *
import tkinter as tk
import webbrowser

window = Tk()

new = 1

url = 'https://www.youtube.com/watch?v=wb2yOsgEJJg'

window.title("Youtube link dowloader")

window.geometry('1920x1080')

# title setup

title = Label(window,text = 'Youtube Video Downloader', ).pack()

title.grid(column=0, row=0)

# Textbox

searchbar = Entry(window,width=10).pack()

searchbar.grid(column=0, row=0)

# Function to open the link in a browser

def openweb():
    url = searchbar.get()
    webbrowser.open(url,new=new)

# button setup

btn = Button(window, text = 'click this button to go to converter', height = 10,width = 50, 
command=openweb).pack()

btn.grid(column=0, row=3)

window.mainloop()
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268

1 Answers1

0

works for me well without pack(), like that:

import webbrowser
from tkinter import *

window = Tk()
new = 1
url = 'https://www.youtube.com/watch?v=wb2yOsgEJJg'
window.title("Youtube link dowloader")
window.geometry('1920x1080')

title = Label(window, text='Youtube Video Downloader')
title.grid(column=0, row=0)
searchbar = Entry(window, width=10)
searchbar.grid(column=0, row=0)

def openweb():
    url = searchbar.get()
    webbrowser.open(url, new=new)


btn = Button(window, text='click this button to go to converter', height=10, width=50,command=openweb)

btn.grid(column=0, row=3)
window.mainloop()
Vova
  • 3,117
  • 2
  • 15
  • 23