diff --git a/core.py b/core.py index 2924567..52bd0b1 100644 --- a/core.py +++ b/core.py @@ -3,21 +3,6 @@ import threading from utils import rgb_to_hex, get_foreground_color -VERSION = "2.0.1" - -def check_version_and_print(gui_info = True): - try: - global VERSION - response = requests.get("https://raw.githubusercontent.com/Axorax/tkforge/refs/heads/main/VERSION.txt") - response.raise_for_status() - online_version = response.text.strip() - version_tuple = tuple(map(int, VERSION.split('.'))) - online_version_tuple = tuple(map(int, online_version.split('.'))) - if online_version_tuple > version_tuple: - print("hello") - except requests.RequestException as e: - print(f"Error fetching version: {e}") - def get_file(file, token): response = requests.get(f"https://api.figma.com/v1/files/{file}", headers={'X-FIGMA-TOKEN': token}) diff --git a/gui.py b/gui.py index f61576d..e41ed72 100644 --- a/gui.py +++ b/gui.py @@ -8,7 +8,7 @@ import webbrowser import tkinter as tk from tk import tk_code -from utils import extract_figma_id +from utils import extract_figma_id, check_for_updates from tkinter import filedialog, messagebox def load_asset(path): @@ -273,5 +273,10 @@ def select_outpath(): donate_button.place(x=371, y=446, width=343, height=34) +try: + exec(check_for_updates()) +except: + print("No updates!") + root.resizable(False, False) root.mainloop() diff --git a/info.py b/info.py index e69de29..79e1960 100644 --- a/info.py +++ b/info.py @@ -0,0 +1 @@ +messagebox.showinfo('New update!', "Update your version of TkForge to get the latest features! https://github.com/axorax/tkforge/releases") diff --git a/info_cli.py b/info_cli.py index e69de29..6d069d2 100644 --- a/info_cli.py +++ b/info_cli.py @@ -0,0 +1,3 @@ +print("New update!") +print("Update your version of TkForge to get the latest features!") +print("https://github.com/axorax/tkforge/releases") \ No newline at end of file diff --git a/tkforge.py b/tkforge.py index 2e9c98d..f989829 100644 --- a/tkforge.py +++ b/tkforge.py @@ -2,10 +2,12 @@ import argparse from tk import tk_code from colorama import Fore, init -from utils import extract_figma_id +from utils import extract_figma_id, check_for_updates init(autoreset=True) +exec(check_for_updates(True)) + def parse_arguments(): parser = argparse.ArgumentParser(description="Drag & drop in Figma to create a Python GUI with ease! Donate: " + Fore.BLUE + "https://patreon.com/axorax" + Fore.RESET) diff --git a/utils.py b/utils.py index f114742..1ae5118 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,27 @@ import os +import requests from urllib.parse import urlparse +VERSION = "1.0.0" +BASE_URL = "https://raw.githubusercontent.com/Axorax/tkforge/refs/heads/main/" + +def check_for_updates(gui_info = True): + try: + global VERSION + response = requests.get(f"{BASE_URL}VERSION.txt") + response.raise_for_status() + online_version = response.text.strip() + version_tuple = tuple(map(int, VERSION.split('.'))) + online_version_tuple = tuple(map(int, online_version.split('.'))) + if online_version_tuple > version_tuple: + response = requests.get(f"{BASE_URL}{"info" if gui_info else "info_cli"}.py") + response.raise_for_status() + return response.text + else: + return False + except requests.RequestException as e: + return False + def rgb_to_hex(r, g, b): return f"#{int(r*255):02x}{int(g*255):02x}{int(b*255):02x}"