diff --git a/images/source/milk_shake.png b/images/goal/milk_shake.png similarity index 100% rename from images/source/milk_shake.png rename to images/goal/milk_shake.png diff --git a/images/goal/horse_sit.png b/images/source/horse_sit.png similarity index 100% rename from images/goal/horse_sit.png rename to images/source/horse_sit.png diff --git a/images/goal/think.png b/images/source/think.png similarity index 100% rename from images/goal/think.png rename to images/source/think.png diff --git a/images/goal/tree.png b/images/source/tree.png similarity index 100% rename from images/goal/tree.png rename to images/source/tree.png diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..004d48f --- /dev/null +++ b/main.spec @@ -0,0 +1,38 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['D:/matic/project/image_shenanigans/python/main.py'], + pathex=[], + binaries=[], + datas=[('images', 'images')], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/python/__pycache__/interface.cpython-312.pyc b/python/__pycache__/interface.cpython-312.pyc new file mode 100644 index 0000000..52319c2 Binary files /dev/null and b/python/__pycache__/interface.cpython-312.pyc differ diff --git a/python/__pycache__/interface.cpython-313.pyc b/python/__pycache__/interface.cpython-313.pyc index acb12c0..ec43f15 100644 Binary files a/python/__pycache__/interface.cpython-313.pyc and b/python/__pycache__/interface.cpython-313.pyc differ diff --git a/python/interface.py b/python/interface.py index 2a19dfd..f729b95 100644 --- a/python/interface.py +++ b/python/interface.py @@ -1,5 +1,5 @@ +import sys from pathlib import Path -from glob import glob from PIL import Image import matplotlib.pylab as plt @@ -10,11 +10,14 @@ import transition class ImageInterface: def __init__(self, base_dir=None): - self.base_dir = Path(base_dir or Path(__file__).resolve().parent.parent) + if base_dir: + self.base_dir = Path(base_dir).expanduser().resolve() + else: + self.base_dir = Path(getattr(sys, "_MEIPASS", Path(__file__).resolve().parents[1])) + self.image_dir = self.base_dir / "images" self.image_sets = { - "source": self.load_images(str(self.base_dir / "images" / "source" / "*.png")), - "goal": self.load_images(str(self.base_dir / "images" / "goal" / "*.png")), - "shenanigans": self.load_images(str(self.base_dir / "images" / "shenanigans" / "*.png")), + "source": self.load_images(self.image_dir / "source"), + "goal": self.load_images(self.image_dir / "goal"), } self.current_category = None self.current_index = 0 @@ -31,8 +34,11 @@ class ImageInterface: "button": "#2b2b2b", "button_hover": "#3a3a3a", } - def load_images(self, pattern): - return sorted(glob(pattern)) + def load_images(self, directory): + paths = [] + for extension in ("*.png", "*.jpg", "*.jpeg", "*.bmp", "*.gif", "*.webp"): + paths.extend(directory.glob(extension)) + return sorted(str(path) for path in paths) def ensure_figure(self): if self.figure is None: self.figure = plt.figure(figsize=(10, 6)) diff --git a/python/main.exe b/python/main.exe new file mode 100644 index 0000000..d6b0ad6 Binary files /dev/null and b/python/main.exe differ