Added update coding to the program, as well as fixed it so search lets you autocomplete.

This commit is contained in:
2025-06-03 18:20:03 -04:00
parent de26c2e4c6
commit 93f4826148
4 changed files with 578 additions and 410 deletions

Binary file not shown.

889
main.py

File diff suppressed because it is too large Load Diff

46
update_checker.py Normal file
View File

@ -0,0 +1,46 @@
# ──────────────────────────────────────────────────────────────────────────────
# update_checker.py (fold this into main.py or import it)
# ──────────────────────────────────────────────────────────────────────────────
import requests
import webbrowser
from tkinter import messagebox
# Fill in your GitHub “owner/repo” here:
GITHUB_REPO = "YourUsername/YourRepo"
def check_for_updates(local_version: str, repo: str) -> None:
"""
1. Hits GitHubs API: /repos/{repo}/releases/latest
2. Reads the "tag_name" of the latest release (e.g. "v1.2.60" or "1.2.60").
3. Strips any leading "v" and compares semver (major, minor, patch) tuples.
4. If GitHubs version > local_version, prompts user to open the Releases page.
"""
api_url = f"https://api.github.com/repos/{repo}/releases/latest"
try:
resp = requests.get(api_url, timeout=5)
resp.raise_for_status()
data = resp.json()
tag = data.get("tag_name", "").lstrip("v")
except Exception:
return # silently do nothing on network or JSON errors
def to_tuple(v: str):
parts = [int(x) for x in v.split(".") if x.isdigit()]
return tuple(parts)
try:
if to_tuple(tag) > to_tuple(local_version):
answer = messagebox.askyesno(
"Update Available",
f"A newer release ({tag}) is available on GitHub.\n"
f"Youre currently on {local_version}.\n\n"
"Would you like to open the Releases page?"
)
if answer:
webbrowser.open(
data.get("html_url", f"https://github.com/{repo}/releases/latest")
)
except Exception:
pass

39
versioning.py Normal file
View File

@ -0,0 +1,39 @@
# ──────────────────────────────────────────────────────────────────────────────
# versioning.py (you could put this at the top of main.py or in its own file)
# ──────────────────────────────────────────────────────────────────────────────
import subprocess
import shlex
# Only bump these when you deliberately want to release a new major/minor:
MAJOR = 0
MINOR = 1
# Fallback “build” if not in a Git repo (e.g. when you zip up or PyInstallerbundle).
# In that scenario, commitcount detection will fail and well use this.
__version__ = f"{MAJOR}.{MINOR}.0"
def get_local_version() -> str:
"""
Try to get the current Gitbased build number via:
git rev-list --count HEAD
This returns an integer count of commits on HEAD. We build a version string:
"<MAJOR>.<MINOR>.<commit_count>"
If anything fails (no Git, or not in a repo), we fall back to __version__.
"""
try:
# This returns something like "57\n" if there have been 57 commits.
p = subprocess.run(
shlex.split("git rev-list --count HEAD"),
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
check=True,
text=True
)
build = p.stdout.strip()
# Construct "MAJOR.MINOR.build"
return f"{MAJOR}.{MINOR}.{build}"
except Exception:
# Either git isnt installed or this isnt a Git checkout.
return __version__