Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchro time issue #19

Open
akio622 opened this issue Jul 19, 2024 · 0 comments
Open

Synchro time issue #19

akio622 opened this issue Jul 19, 2024 · 0 comments

Comments

@akio622
Copy link

akio622 commented Jul 19, 2024

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant