diff --git a/Matrix.spec b/Matrix.spec index b98a0bf..0338975 100644 --- a/Matrix.spec +++ b/Matrix.spec @@ -7,8 +7,8 @@ block_cipher = None a = Analysis( ['ascii12.py'], pathex=[], - binaries=[], - datas=[('.\icon-32.png', '.\icon-32.png')], + binaries=[('I:\\ascii\\matrix.ico', '.')], + datas=[('I:\\ascii\\matrix.ico', '.')], hiddenimports=[], hookspath=[], hooksconfig={}, @@ -52,5 +52,5 @@ exe = EXE( target_arch=None, codesign_identity=None, entitlements_file=None, - icon=['icon-32.png'], + icon=['I:\\ascii\\matrix.ico'], ) diff --git a/ascii12.py b/ascii12.py index 051819b..55b167c 100644 --- a/ascii12.py +++ b/ascii12.py @@ -20,8 +20,8 @@ camera = 1 # à Modifier si ne fonctionne pas #add id to app to show icon in window and taskbar -myappid = 'bit-scripts.matrix.cameraascii.twelve' # arbitrary string -ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) +#myappid = 'bit-scripts.matrix.cameraascii.twelve' # arbitrary string +#ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) # Variable partagée pour signaler à un thread qu'il doit s'arrêter stop = threading.Event() @@ -44,6 +44,17 @@ def image_to_ascii(image): ascii_image += "\n" return ascii_image + +def resource_path(relative_path): + """ Get absolute path to resource, works for dev and for PyInstaller """ + try: + # PyInstaller creates a temp folder and stores path in _MEIPASS + base_path = sys._MEIPASS + except Exception: + base_path = os.path.abspath(".") + + return os.path.join(base_path, relative_path) + # Création de la fenêtre tkinter root = tk.Tk() root.configure(bg='#000') @@ -53,7 +64,8 @@ def image_to_ascii(image): sh = root.winfo_screenheight() root.geometry("%dx%d+%d+%d" % (1100, 620, (sw-1100)/2, (sh-620)/2)) directory = os.getcwd() -root.tk.call('wm','iconphoto',root._w,tk.PhotoImage(file=directory + "/icon-32.png")) +#root.tk.call('wm','iconphoto',root._w,tk.PhotoImage(file=directory + "/icon-32.png")) +root.iconbitmap(resource_path('matrix.ico')) root.title("ASCII Camera") if getattr(sys, 'frozen', False): import pyi_splash diff --git a/ico/Matrix.ico b/ico/Matrix.ico new file mode 100644 index 0000000..40a2986 Binary files /dev/null and b/ico/Matrix.ico differ diff --git a/matrix.ico b/matrix.ico new file mode 100644 index 0000000..40a2986 Binary files /dev/null and b/matrix.ico differ diff --git a/output/Matrix.exe b/output/Matrix.exe deleted file mode 100644 index 7979e24..0000000 Binary files a/output/Matrix.exe and /dev/null differ diff --git a/output/icon-32.ico b/output/icon-32.ico deleted file mode 100644 index 90a065d..0000000 Binary files a/output/icon-32.ico and /dev/null differ diff --git a/output/icon-32.png b/output/icon-32.png deleted file mode 100644 index ff441f0..0000000 Binary files a/output/icon-32.png and /dev/null differ