-
Notifications
You must be signed in to change notification settings - Fork 6
Description
basicaly im doing a simple UI that can send you the price of an item and the last price recorder but the thing is, the date is way too old and i dont know if its a problem on my side or just that this lib synchronisation is too slow. *
Take a look at my code if you want :
import datetime
import BackpackTF
from customtkinter import *
from BackpackTF import *
api_key = Currency(apikey="661a53e819f57a398c071231")
screen = CTk()
screen.geometry("500x400")
screen.maxsize(500,400)
screen.minsize(500,400)
set_appearance_mode('dark')
Item_name = CTkEntry(master=screen, placeholder_text="Item name", corner_radius=15)
Item_name.place(relx=0.5, rely=0.4, anchor=CENTER)
quality_type = CTkEntry(master=screen, placeholder_text="Quality type", corner_radius=15)
quality_type.place(relx=0.5, rely=0.5, anchor=CENTER)
is_craftable = CTkEntry(master=screen, placeholder_text="Craftable ?", corner_radius=15)
is_craftable.place(relx=0.5, rely=0.6, anchor=CENTER)
craftability_state = 0
if is_craftable == "yes":
craftability_state == 1
elif is_craftable == "no":
craftability_state == 0
def button_event():
global price, item_name_value, quality_type_value, is_craftable_value
item_name_value = Item_name.get()
quality_type_value = quality_type.get()
is_craftable_value = is_craftable.get().lower()
craftability_state = 0
if is_craftable_value == "yes":
craftability_state = 1
elif is_craftable_value == "no":
craftability_state = 0
try:
price = api_key.item_price(item=item_name_value, quality=quality_type_value, craftable=craftability_state)
value = price['value']
currency = price['currency']
timestamp = price['timestamp']
date_time = datetime.datetime.fromtimestamp(timestamp)
output_label = CTkLabel(master=screen, text=f"The price of this item is : {value} {currency}")
output_label.place(relx = 0.5, rely=0.8, anchor=CENTER)
output_label2 = CTkLabel(master=screen, text=f"Price date time : {date_time}")
output_label2.place(relx = 0.5, rely=0.85, anchor=CENTER)
except Exception as e:
print(f"An error occurred: {e}")
btn = CTkButton(master=screen, text="Print result", command=button_event)
btn.place(relx=0.5, rely=0.7, anchor=CENTER)
screen.mainloop()
PS: Can someone of this project update the library documentation on https://pypi.org/project/BackpackTF/