-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
35 lines (27 loc) · 1.13 KB
/
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
from tkinter import *
import requests
from requests import exceptions
def get_quote():
pass
#to make api call
response = requests.get(url = "https://api.kanye.rest")
#to raise exceptions
response.raise_for_status()
#to show the data of the response in the terminal
data = response.json()
#we can get the hold of the actual quote by simply tapping to the data using square brackets to fetch the value under the key quote
quote = data["quote"]
#to put that quote into our canvas we need to config the item first
canvas.itemconfig(quote_text, text = quote)
window = Tk()
window.title("Kanye Says...")
window.config(padx=50, pady=50)
canvas = Canvas(width=300, height=414)
background_img = PhotoImage(file="background.png")
canvas.create_image(150, 207, image=background_img)
quote_text = canvas.create_text(150, 207, text="Kanye Quote Goes HERE", width=250, font=("Arial", 30, "bold"), fill="white")
canvas.grid(row=0, column=0)
kanye_img = PhotoImage(file="kanye.png")
kanye_button = Button(image=kanye_img, highlightthickness=0, command=get_quote)
kanye_button.grid(row=1, column=0)
window.mainloop()