using def with tkinter to make simple wikipedia app in python

2024/10/6 8:24:38

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 wikipediaquestion = input("Question: ")wikipedia.set_lang("en" )print (wikipedia.summary(question) )

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.

Answer

assuming you really did research and came out empty(which is highly unlikely),you could use something like

from tkinter import *
import wikipediadef 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

https://en.xdnf.cn/q/118975.html

Related Q&A

Only length-1 arrays can be converted to Python scalars with log

from numpy import * from pylab import * from scipy import * from scipy.signal import * from scipy.stats import * testimg = imread(path) hist = hist(testimg.flatten(), 256, range=[0.0,1.0])[0] hist…

Deploying Django with apache using wsgi.py

Im trying to deploy a Django project on a linode server that has apache, some other django projects and a php project on it. Also my project is in a virualenv and the other django projects arent.My Dja…

Building a decision tree using user inputs for ordering goods

I am trying to program a decision tree to allow customers to order goods based on their input. So far, I have devised a nested if-elif conditional structure to decide if customer want to order what or…

How to de-serialize the spark data frame into another data frame [duplicate]

This question already has answers here:Explode array data into rows in spark [duplicate](3 answers)Closed 4 years ago.I am trying to de-serialize the the spark data frame into another data frame as exp…

How to pull specific key from this nested dictionary?

{"newData": [{"env1": [{"sins": [{"host": "test.com","deployTime": "2015-07-23 11:54 AM",…}],"name": “hello”}, {"…

Dropping cell if it is NaN in a Dataframe in python

I have a dataframe like this.Project 4 Project1 Project2 Project3 0 NaN laptio AB NaN 1 NaN windows ten NaN 0 one NaN NaN 1 …

How can I iterate through excel files sheets and insert formula in Python?

I get this error TypeError: Workbook object is not subscriptablewhen i run this code import xlsxwriter from openpyxl import load_workbookin_folder = rxxx #Input folder out_folder = rxxx #Output folde…

How to bind all frame widgets to Enter event

I the following code I want to bind all frame1 items to <Enter> Event, but it does not work. I mean canvas.focus_set() does not take effect. How can I solve my problem?for w in frame1.winfo_chil…

Typeerror takes no arguments [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.This question was caused by a typo or a problem that can no longer be reproduced. While similar q…

Unable to access element within page

Form Screenshot HTML Inspect Code screenshotIm trying to access an element within a page. Cannot give out the exact page link owing to security concerns. Im writing a python program that uses selenium …