from tkinter import *
from tkinter import messagebox
import webbrowser
root = Tk()
root.geometry("500x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Google")
# Pesquisar uma palavras e abrir
titulo = Label(text="Google",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.34, rely=0.05)
texto_sub1 = Label(text="Palavra a pesquisar: ",
font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.4)
Palavra_pesquisar = StringVar()
Palavra_pesquisar_entrada = Entry(textvariable=Palavra_pesquisar,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Palavra_pesquisar_entrada.place(relx=0.55, rely=0.41, relwidth=0.35)
def limpar():
Palavra_pesquisar_entrada.delete(0, END)
def app():
palavra = Palavra_pesquisar.get()
if palavra:
url = f"https://www.google.com/search?q={palavra}"
webbrowser.open(url)
else:
messagebox.showwarning("Aviso", "Por favor, insira um termo de pesquisa.")
# Botão "Estou com sorte"
def estou_com_sorte():
termo = Palavra_pesquisar.get()
if termo:
url = f"https://www.google.com/doodles"
webbrowser.open(url)
else:
messagebox.showwarning("Aviso", "Por favor, insira um termo de pesquisa.")
botao_sorte = Button( text="Estou com sorte", font=("Arial", 12),
bg="#34A853", fg="white", activebackground="#2c8e46",
activeforeground="white", command=estou_com_sorte, cursor="hand2")
botao_sorte.place(relx=0.35, rely=0.8, relwidth=0.25, relheight=0.1)
but1 = Button(text="Pesquisar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.65, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.65, relwidth=0.25, relheight=0.1)
but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.7, rely=0.65, relwidth=0.25, relheight=0.1)
root.mainloop()