end of development for python going to cpp made an exe file for main.py

This commit is contained in:
2026-09-11 21:49:34 +02:00
parent 3afa31e90f
commit 82d5a9f549
9 changed files with 51 additions and 7 deletions
+13 -7
View File
@@ -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))