Ask coding questions

← Back to all posts
what does it mean?
dObbOb11 (21)

I wrote a program to open google and get the search results and it used the same concept as https://replit.com/@dObbOb11/Googleable#main.py (googleable does work just not on Replit) but I got this error when trying to get input from an entry widget:

Traceback (most recent call last):
File "C:\Users~\Desktop\Python\Google-Getter.py", line 20, in <module>
search = entry.get()
AttributeError: 'NoneType' object has no attribute 'get'

Can you help?

Answered by LegendaryWolf (574) [earned 5 cycles]
View Answer
Comments
hotnewtop
LegendaryWolf (574)

maybe this code will work for tkinter

import tkinter as tk
import tkinter.font as font
import webbrowser

root = tk.Tk()
root.title("google alt")



def search():
  query = "https://www.google.com/search?q="+entry.get().replace(" ","+")
  webbrowser.open(query)

# Fonts
logoFont = font.Font(family="Arial", size="30")

# Header
title = tk.Label(text="Google", font=logoFont).pack()
btn1 = tk.Label(text="\nGoogle Search...").pack()

# Searchbox
entry = tk.Entry(root)
entry.pack()

btn = tk.Button(root, text="search google", command=search)
btn.pack()

root.mainloop()
LegendaryWolf (574)

yes I can if you invite me to this repl