From 293725d427d7550e71d454b28592f8dc640501cd Mon Sep 17 00:00:00 2001 From: Joey Payne Date: Sun, 19 Oct 2014 16:19:09 +1300 Subject: [PATCH] Added ability to replace windows icons on export if the Window Icon field is filled in. --- main.py | 19 +++++++++++++++++-- pepy | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 83c0797..d0add91 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ from utils import zip_files, join_files, log, get_temp_dir, open_folder_in_explorer +from pepy.pe import PEFile import urllib2, re import sys, os, glob, json, re, shutil, stat, tarfile @@ -191,7 +192,7 @@ class MainWindow(QtGui.QWidget): win_32_dir_prefix+'/icudtl.dat', win_32_dir_prefix+'/libEGL.dll', win_32_dir_prefix+'/libGLESv2.dll'], - dest_files=['nw.exe', + dest_files=['nw.exe', #must be the first entry 'nw.pak', 'icudtl.dat', 'libEGL.dll', @@ -1181,16 +1182,22 @@ class MainWindow(QtGui.QWidget): self.progress_text += '.' else: ext = '' + windows = False if ex_setting.name == 'windows': ext = '.exe' + windows=True nw_path = os.path.join(export_dest, ex_setting.dest_files[0]) dest_binary_path = os.path.join(export_dest, self.projectName()+ext) - join_files(os.path.join(export_dest, self.projectName()+ext), nw_path, zip_file) + + join_files(dest_binary_path, nw_path, zip_file) sevenfivefive = stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH os.chmod(dest_binary_path, sevenfivefive) + if windows: + self.replace_icon_in_exe(dest_binary_path) + self.progress_text += '.' if os.path.exists(nw_path): @@ -1201,6 +1208,14 @@ class MainWindow(QtGui.QWidget): finally: shutil.rmtree(tempDir) + def replace_icon_in_exe(self, exe_path): + icon_setting = self.getSetting('icon') + if icon_setting.value: + p = PEFile(exe_path) + p.replace_icon(os.path.join(self.projectDir(), icon_setting.value)) + p.write(exe_path) + p = None + def show_and_raise(self): self.show() self.raise_() diff --git a/pepy b/pepy index 6eb2006..51525ed 160000 --- a/pepy +++ b/pepy @@ -1 +1 @@ -Subproject commit 6eb2006269318abb7eadd03178cf3f2fa7df7a5f +Subproject commit 51525eddff3ed50d4879366f2ba1ae4ed30a678f