Advertisement
k1alo

Untitled

Nov 18th, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. import tkinter
  2. from tkinter import *
  3. import requests
  4.  
  5. def klg():
  6.     api_url = 'https://api.calorieninjas.com/v1/nutrition?query='
  7.     query = input()
  8.     response = requests.get(api_url + query, headers={'X-Api-Key': '1CHQ8yp+m7+5BXHFUoUJ+A==ai2RrNSHUy8hHUT9'})
  9.     if response.status_code == requests.codes.ok:
  10.         print(response.text[1::2])
  11.     else:
  12.         print("Error:", response.status_code, response.text)
  13.  
  14.  
  15.  
  16. root = Tk()
  17. root.geometry("600x400")
  18. root.maxsize(600, 400)
  19. root.title("Калорийность продукта")
  20.  
  21. root.config(bg='#696969')
  22.  
  23. label1 = Label(text="Калорийность продукта", font=('Arial', 25, 'bold'), pady=20, bg='#696969')
  24. label1.pack()
  25.  
  26. pole = Entry(font=('Arial', 15, 'bold'))
  27. pole.pack()
  28.  
  29. button = tkinter.Button(text="Найти", bg='#1E90FF', command=klg)
  30. button.pack()
  31.  
  32. label3 = Label(text='Калорийность: ', pady=20, bg='#696969', font=('Arial', 15, 'bold'))
  33. label3.pack()
  34.  
  35. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement