-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
36 lines (26 loc) · 846 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
import os
from dotenv import load_dotenv, find_dotenv
import tkinter as tk
from tkinter import *
import json
load_dotenv(find_dotenv())
url = "https://mashape-community-urban-dictionary.p.rapidapi.com/define"
querystring = {"term": "yeet"}
headers = {
'x-rapidapi-key': os.environ.get("RAPIDAPI_KEY"),
'x-rapidapi-host': "mashape-community-urban-dictionary.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers, params=querystring)
result = json.loads(response.text)
definition=result["list"][0]["definition"]
print(definition)
# tkinter window
r = tk.Tk()
r.title("Definition")
l = Label(r, text=definition, justify=LEFT, wraplength=1000)
button = tk.Button(r, text="Close", width=20, command=r.destroy)
l.pack()
button.pack()
#add fonts, window sizing / margins
r.mainloop() #run the window