Buscar Informação através da Wikipédia (Usando tkinter)
# As palavras de pesquisa têm de ser em inglês
from tkinter import *
from wikipedia import summary
import tkinter.scrolledtext as scrolledtext
root =Tk()
class app():
def __init__(self):
self.root = root
self.janela()
self.pesquisaapp()
root.mainloop()
def janela(self):
self.root.title("Pesquisar Palavras Wikipedia ")
self.root.geometry("600x600")
self.root.resizable(False, False)
self.root.configure(background='#eaeef5')
def pesquisaapp(self):
self.palavra = StringVar()
self.palavra_lb = Label(text=" Palavra a procurar: ",
font=("Helvetica", '10','bold')
,bg='#78c8c0',fg='#0a0fc9')
self.palavra_lb.place(relx=0.05,rely=0.05)
self.palavra_entry = Entry(textvariable=self.palavra,justify='center')
self.palavra_entry.place(relx=0.43,rely=0.06,relwidth=0.5)
#
self.button = Button( text='Pesquisa',bg='#0a0fc9',fg='#78c8c0',
font=('Arial','13'),
command=self.search)
self.button.place(relx=0.45,rely=0.15,relheight=0.1)
self.summary_text = scrolledtext.ScrolledText( font=('Ariel 16'))
self.summary_text.place(relx=0.08,rely=0.3,relwidth=0.9,relheight=0.65)
def search(self):
try:
self.summary_text.delete(1.0, END)
self.summary_text.insert(INSERT,summary(self.palavra.get()))
except Exception as error:
self.messagebox.showerror('Error', error)
app()
Comentários
Enviar um comentário