Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- from tkinter import *
- import requests
- def klg():
- api_url = 'https://api.calorieninjas.com/v1/nutrition?query='
- query = input()
- response = requests.get(api_url + query, headers={'X-Api-Key': '1CHQ8yp+m7+5BXHFUoUJ+A==ai2RrNSHUy8hHUT9'})
- if response.status_code == requests.codes.ok:
- print(response.text[1::2])
- else:
- print("Error:", response.status_code, response.text)
- root = Tk()
- root.geometry("600x400")
- root.maxsize(600, 400)
- root.title("Калорийность продукта")
- root.config(bg='#696969')
- label1 = Label(text="Калорийность продукта", font=('Arial', 25, 'bold'), pady=20, bg='#696969')
- label1.pack()
- pole = Entry(font=('Arial', 15, 'bold'))
- pole.pack()
- button = tkinter.Button(text="Найти", bg='#1E90FF', command=klg)
- button.pack()
- label3 = Label(text='Калорийность: ', pady=20, bg='#696969', font=('Arial', 15, 'bold'))
- label3.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement