top of page

Getting quotes and displaying them

  • Writer: 라임 샹큼
    라임 샹큼
  • 6 days ago
  • 1 min read

from tkinter import *

import requests




def get_quote():

    quote_url = requests.get(url='https://api.kanye.rest')

    quote_json = quote_url.json()

    actual_quote = quote_json['quote']

    canvas.itemconfig(quote_text, text = actual_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()

 
 
 

Recent Posts

See All
Stock market price alerter

Lately I’ve been getting API data from existing data and using it to get actual live data. This is done by importing requests.  This was...

 
 
 
Making a better quiz ui

I reencountered classes again. I remember I had a a hard time learning how classes were different from simply defining functions. It was...

 
 
 
Password Manager

import tkinter from tkinter import messagebox from tkinter import PhotoImage import random # ---------------------------- PASSWORD...

 
 
 

Comentários


© 2024 by GifTED. Powered and secured by Wix

bottom of page