🐛 Make sound works with executable

Fix #23
This commit is contained in:
Clement Desmidt 2023-05-24 17:25:17 +02:00
parent 508e384858
commit d1400da930
3 changed files with 14 additions and 3 deletions

View File

@ -1,8 +1,13 @@
import os
import sys
from tkinter import * from tkinter import *
from src.window.app import App from src.window.app import App
def main(): def main():
if getattr(sys, 'frozen', False):
os.chdir(sys._MEIPASS)
root = Tk() root = Tk()
root.title("Drawing Training!") root.title("Drawing Training!")
root.geometry("300x600") root.geometry("300x600")

View File

@ -1,2 +1,5 @@
.PHONY: build dist
build: build:
pyinstaller main.py --onefile -w --hidden-import="PIL._tkinter_finder" -n drawingtraining rm -rf build dist drawingtraining.spec
pyinstaller main.py --onefile -w --hidden-import="PIL._tkinter_finder" -n drawingtraining --add-data "assets:assets"

View File

@ -13,6 +13,8 @@ class ImageWindow:
self.window = Toplevel(app.root) self.window = Toplevel(app.root)
self.window.title("Image") self.window.title("Image")
self.window.geometry("1280x1024") self.window.geometry("1280x1024")
self.window.protocol("WM_DELETE_WINDOW", self.on_closing)
self.option = { self.option = {
"bw": False, "bw": False,
"mirror": False, "mirror": False,
@ -33,6 +35,9 @@ class ImageWindow:
self.toolbar = Toolbar(self, self.timer) self.toolbar = Toolbar(self, self.timer)
self.image = ImagePlaceholder(self, self.images) self.image = ImagePlaceholder(self, self.images)
def on_closing(self):
self.countdown_sound.stop()
def next_image(self): def next_image(self):
if self.toolbar.timer_check is not None: if self.toolbar.timer_check is not None:
self.window.after_cancel(self.toolbar.timer_check) self.window.after_cancel(self.toolbar.timer_check)
@ -41,10 +46,8 @@ class ImageWindow:
def lets_draw(self, images, timer): def lets_draw(self, images, timer):
random.shuffle(images) random.shuffle(images)
# self.images = images
self.image.images = images self.image.images = images
self.toolbar.timer = timer self.toolbar.timer = timer
# self.timer = timer
self.next_image() self.next_image()
def play_countdown(self): def play_countdown(self):