问题描述
限时送ChatGPT账号..我是 Python 初学者.我正在尝试制作一个 python wiki 应用程序,它可以为您提供您搜索的任何内容的摘要.我的代码如下:
I am beginner in python. I am trying to make a python wiki app that gives you a summary of anything that you search for. My code is below:
import wikipedia
question = input("Question: ")
wikipedia.set_lang("en" )
print (wikipedia.summary(question) )
此代码有效,但我想将 tkinter
GUI 添加到带有输入字段和搜索按钮的应用程序.搜索结果将显示在 GUI 中的文本框中.
This code works but I want to add a tkinter
GUI to the app with an entry field and a search button. The result of the search will then be displayed in the GUI in a text box.
推荐答案
假设你真的做了研究并且结果是空的(这是极不可能的),你可以使用类似的东西
assuming you really did research and came out empty(which is highly unlikely),you could use something like
from tkinter import *
import wikipedia
def on_click():
q = get_q.get()
text.insert(INSERT, wikipedia.summary(q))
root = Tk()
question = Label(root, text="Question")
question.pack()
get_q = Entry(root, bd =5)
get_q.pack()
submit = Button(root,text='Submit',command=on_click)
submit.pack()
text = Text(root)
text.pack()
root.mainloop()
尝试进行更多研究并阅读文档,他们是你最好的编程朋友
Do try to research more and readthedocs,they are your best friend in programming
这篇关于使用 def 和 tkinter 在 python 中制作简单的维基百科应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论