From 21a8001f5676d4fd6f92ca49018ce80d2bb2bf43 Mon Sep 17 00:00:00 2001 From: Paweł Jastrzębski Date: Thu, 13 Jun 2013 12:36:34 +0200 Subject: Not using Pixmaps outside GUI thread anymore --- kcc/KCC_gui.py | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 97cb977..5a9fb4a 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -99,11 +99,11 @@ class WorkerThread(QtCore.QThread): GUI.JobList.clear() for job in currentJobs: errors = False - self.emit(QtCore.SIGNAL("addMessage"), 'Source: ' + job, icons.info) + self.emit(QtCore.SIGNAL("addMessage"), 'Source: ' + job, 'info') if str(GUI.FormatBox.currentText()) == 'CBZ': - self.emit(QtCore.SIGNAL("addMessage"), 'Creating CBZ file...', icons.info) + self.emit(QtCore.SIGNAL("addMessage"), 'Creating CBZ file...', 'info') else: - self.emit(QtCore.SIGNAL("addMessage"), 'Creating EPUB file...', icons.info) + self.emit(QtCore.SIGNAL("addMessage"), 'Creating EPUB file...', 'info') jobargv = list(argv) jobargv.append(job) try: @@ -116,16 +116,16 @@ class WorkerThread(QtCore.QThread): "Error on file %s:\n%s\nTraceback:\n%s" % (jobargv[-1], str(err), traceback.format_tb(traceback_)), QtGui.QMessageBox.Ok) - self.emit(QtCore.SIGNAL("addMessage"), 'KCC failed to create EPUB!', icons.error) + self.emit(QtCore.SIGNAL("addMessage"), 'KCC failed to create EPUB!', 'error') continue if not errors: if str(GUI.FormatBox.currentText()) == 'CBZ': - self.emit(QtCore.SIGNAL("addMessage"), 'Creating CBZ file... Done!', icons.info, True) + self.emit(QtCore.SIGNAL("addMessage"), 'Creating CBZ file... Done!', 'info', True) else: - self.emit(QtCore.SIGNAL("addMessage"), 'Creating EPUB file... Done!', icons.info, True) + self.emit(QtCore.SIGNAL("addMessage"), 'Creating EPUB file... Done!', 'info', True) if str(GUI.FormatBox.currentText()) == 'MOBI': if not os.path.getsize(outputPath) > 314572800: - self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file...', icons.info) + self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file...', 'info') self.emit(QtCore.SIGNAL("progressBarTick"), 1) try: retcode = call('kindlegen "' + outputPath + '"', shell=True) @@ -133,8 +133,8 @@ class WorkerThread(QtCore.QThread): continue self.emit(QtCore.SIGNAL("hideProgressBar")) if retcode == 0: - self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file... Done!', icons.info, True) - self.emit(QtCore.SIGNAL("addMessage"), 'Removing SRCS header...', icons.info) + self.emit(QtCore.SIGNAL("addMessage"), 'Creating MOBI file... Done!', 'info', True) + self.emit(QtCore.SIGNAL("addMessage"), 'Removing SRCS header...', 'info') os.remove(outputPath) mobiPath = outputPath.replace('.epub', '.mobi') shutil.move(mobiPath, mobiPath + '_tostrip') @@ -146,27 +146,27 @@ class WorkerThread(QtCore.QThread): if not errors: os.remove(mobiPath + '_tostrip') self.emit(QtCore.SIGNAL("addMessage"), 'Removing SRCS header... Done!', - icons.info, True) + 'info', True) else: shutil.move(mobiPath + '_tostrip', mobiPath) self.emit(QtCore.SIGNAL("addMessage"), - 'KindleStrip failed to remove SRCS header!', icons.warning) + 'KindleStrip failed to remove SRCS header!', 'warning') self.emit(QtCore.SIGNAL("addMessage"), 'MOBI file will work correctly but it will be highly oversized.', - icons.warning) + 'warning') else: os.remove(outputPath) os.remove(outputPath.replace('.epub', '.mobi')) - self.emit(QtCore.SIGNAL("addMessage"), 'KindleGen failed to create MOBI!', icons.error) - self.emit(QtCore.SIGNAL("addMessage"), 'Try converting smaller batch.', icons.error) + self.emit(QtCore.SIGNAL("addMessage"), 'KindleGen failed to create MOBI!', 'error') + self.emit(QtCore.SIGNAL("addMessage"), 'Try converting smaller batch.', 'error') else: os.remove(outputPath) self.emit(QtCore.SIGNAL("addMessage"), 'Created EPUB file is too big for KindleGen!', - icons.error) + 'error') self.emit(QtCore.SIGNAL("addMessage"), 'Try converting smaller batch.', - icons.error) + 'error') self.parent.needClean = True - self.emit(QtCore.SIGNAL("addMessage"), 'All jobs completed.', icons.warning) + self.emit(QtCore.SIGNAL("addMessage"), 'All jobs completed.', 'warning') self.emit(QtCore.SIGNAL("modeConvert"), True) @@ -308,6 +308,7 @@ class Ui_KCC(object): def addMessage(self, message, icon=None, replace=False): if icon: + icon = eval('icons.' + icon) item = QtGui.QListWidgetItem(icon, message) else: item = QtGui.QListWidgetItem(message) @@ -332,7 +333,7 @@ class Ui_KCC(object): self.needClean = False GUI.JobList.clear() if GUI.JobList.count() == 0: - self.addMessage('No files selected! Please choose files to convert.', icons.error) + self.addMessage('No files selected! Please choose files to convert.', 'error') self.needClean = True return self.thread.start() @@ -359,20 +360,20 @@ class Ui_KCC(object): self.needClean = True self.GammaValue = 0 - self.addMessage('Welcome!', icons.info) - self.addMessage('Remember: All options have additional informations in tooltips.', icons.info) + self.addMessage('Welcome!', 'info') + self.addMessage('Remember: All options have additional informations in tooltips.', 'info') if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0: self.KindleGen = True formats = ['MOBI', 'EPUB', 'CBZ'] else: self.KindleGen = False formats = ['EPUB', 'CBZ'] - self.addMessage('Not found KindleGen! Creating MOBI files is disabled.', icons.warning) + self.addMessage('Not found KindleGen! Creating MOBI files is disabled.', 'warning') if call('unrar', stdout=PIPE, stderr=STDOUT, shell=True) == 0: self.UnRAR = True else: self.UnRAR = False - self.addMessage('Not found UnRAR! Processing of CBR/RAR files is disabled.', icons.warning) + self.addMessage('Not found UnRAR! Processing of CBR/RAR files is disabled.', 'warning') GUI.BasicModeButton.clicked.connect(self.modeBasic) GUI.AdvModeButton.clicked.connect(self.modeAdvanced) -- cgit 1.4.1 From 3cbc7f163a97725411081f0c29a890567b013271 Mon Sep 17 00:00:00 2001 From: Paweł Jastrzębski Date: Thu, 13 Jun 2013 13:04:54 +0200 Subject: Not using Pixmaps outside GUI thread anymore - Part 2 --- kcc/KCC_gui.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 5a9fb4a..8e99e00 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -308,7 +308,7 @@ class Ui_KCC(object): def addMessage(self, message, icon=None, replace=False): if icon: - icon = eval('icons.' + icon) + icon = eval('self.icons.' + icon) item = QtGui.QListWidgetItem(icon, message) else: item = QtGui.QListWidgetItem(message) @@ -348,11 +348,11 @@ class Ui_KCC(object): self.settings.sync() def __init__(self, ui, KCC): - global GUI, MainWindow, icons + global GUI, MainWindow GUI = ui MainWindow = KCC profiles = sorted(ProfileData.ProfileLabels.iterkeys()) - icons = Icons() + self.icons = Icons() self.settings = QtCore.QSettings('KindleComicConverter', 'KindleComicConverter') self.lastPath = self.settings.value('lastPath', '', type=str) self.lastDevice = self.settings.value('lastDevice', 10, type=int) @@ -390,10 +390,10 @@ class Ui_KCC(object): KCC.closeEvent = self.saveSettings for profile in profiles: - GUI.DeviceBox.addItem(icons.deviceKindle, profile) + GUI.DeviceBox.addItem(self.icons.deviceKindle, profile) GUI.DeviceBox.setCurrentIndex(self.lastDevice) for f in formats: - GUI.FormatBox.addItem(eval('icons.' + f + 'Format'), f) + GUI.FormatBox.addItem(eval('self.icons.' + f + 'Format'), f) GUI.FormatBox.setCurrentIndex(0) self.modeBasic() -- cgit 1.4.1 From e570e25b24e4042e4a77e9f8c28b4b53a665e2dd Mon Sep 17 00:00:00 2001 From: Paweł Jastrzębski Date: Thu, 13 Jun 2013 14:33:51 +0200 Subject: cx_Freeze Linux support --- icons/comic2ebook.png | Bin 0 -> 73100 bytes setup.py | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 icons/comic2ebook.png diff --git a/icons/comic2ebook.png b/icons/comic2ebook.png new file mode 100644 index 0000000..13585d9 Binary files /dev/null and b/icons/comic2ebook.png differ diff --git a/setup.py b/setup.py index 9f5286b..c79c95d 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,14 @@ """ cx_Freeze build script for KCC. -Usage (Mac OS X): - python setup.py bdist_mac - Usage (Windows): python setup.py build + +Usage (Linux): + python setup.py build + +Usage (OS X): + python setup.py bdist_mac """ from sys import platform from cx_Freeze import setup, Executable @@ -40,7 +43,14 @@ elif platform == "win32": appendScriptToLibrary=False, compress=True)]) else: - exit(0) + extra_options = dict( + options={"build_exe": {"include_files": includefiles, "excludes": excludes, "compressed": True}}, + executables=[Executable(MAIN, + icon="icons/comic2ebook.png", + copyDependentFiles=True, + appendScriptToExe=True, + appendScriptToLibrary=False, + compress=True)]) setup( name=NAME, @@ -51,6 +61,6 @@ setup( license="ISC License (ISCL)", keywords="kindle comic mobipocket mobi cbz cbr manga", url="http://github.com/ciromattia/kcc", - packages=['KCC'], requires=['PIL'], + packages=['kcc'], requires=['PIL'], **extra_options ) \ No newline at end of file -- cgit 1.4.1