Skip to content

Commit

Permalink
feat: Update notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Axorax committed Oct 23, 2024
1 parent 369b1b1 commit e8aed76
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
15 changes: 0 additions & 15 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
7 changes: 6 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
1 change: 1 addition & 0 deletions info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
messagebox.showinfo('New update!', "Update your version of TkForge to get the latest features! https://github.com/axorax/tkforge/releases")
3 changes: 3 additions & 0 deletions info_cli.py
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 3 additions & 1 deletion tkforge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 21 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -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}"

Expand Down

0 comments on commit e8aed76

Please sign in to comment.