How To Create A GUI Program In Python Using Tkinter
Language:
In this tutorial, I will show you, how you can build your own Fun Fact Generator GUI in Python by using the library Tkinter & a free API.
import json import requests from tkinter import * window = Tk() window.title("Fun Fact Generator") window.geometry('800x80') def get_fun_fact(): url ="https://uselessfacts.jsph.pl/random.json?language=en" response = requests.request("GET", url) data = json.loads(response.text) useless_fact = data['text'] lbl.configure(text=useless_fact) btn = Button(window,text='Click Me', command=get_fun_fact) btn.pack() lbl = Label(window, text='Click the button to get a random fact') lbl.pack() window.mainloop()