cx_freeze Path Updates

This commit is contained in:
DH4 2017-06-23 02:39:56 -05:00
parent 60d62599f7
commit 8c9914850e
6 changed files with 62 additions and 30 deletions

View File

@ -22,7 +22,13 @@ class Core():
self.dataDir = QDesktopServices.storageLocation(
QDesktopServices.DataLocation)
self.presetDir = os.path.join(self.dataDir, 'presets')
self.wd = os.path.dirname(os.path.realpath(__file__))
if getattr(sys, 'frozen', False):
# frozen
self.wd = os.path.dirname(sys.executable)
else:
# unfrozen
self.wd = os.path.dirname(os.path.realpath(__file__))
self.loadEncoderOptions()
self.videoFormats = Core.appendUppercase([
'*.mp4',

11
main.py
View File

@ -52,8 +52,15 @@ if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
app.setApplicationName("audio-visualizer")
app.setOrganizationName("audio-visualizer")
window = uic.loadUi(os.path.join(
os.path.dirname(os.path.realpath(__file__)), "mainwindow.ui"))
if getattr(sys, 'frozen', False):
# frozen
wd = os.path.dirname(sys.executable)
else:
# unfrozen
wd = os.path.dirname(os.path.realpath(__file__))
window = uic.loadUi(os.path.join(wd, "mainwindow.ui"))
# window.adjustSize()
desc = QtGui.QDesktopWidget()
dpi = desc.physicalDpiX()

View File

@ -63,9 +63,7 @@ class MainWindow(QtGui.QMainWindow):
LoadDefaultSettings(self)
self.presetManager = PresetManager(
uic.loadUi(
os.path.join(os.path.dirname(os.path.realpath(__file__)),
'presetmanager.ui')),
self)
os.path.join(self.core.wd, 'presetmanager.ui')), self)
if not os.path.exists(self.dataDir):
os.makedirs(self.dataDir)
@ -143,7 +141,7 @@ class MainWindow(QtGui.QMainWindow):
window.spinBox_aBitrate.valueChanged.connect(self.updateCodecSettings)
self.previewWindow = PreviewWindow(self, os.path.join(
os.path.dirname(os.path.realpath(__file__)), "background.png"))
self.core.wd, "background.png"))
window.verticalLayout_previewWrapper.addWidget(self.previewWindow)
# Make component buttons

View File

@ -23,7 +23,7 @@ class Worker(QtCore.QObject):
self.stackedWidget = parent.window.stackedWidget
self.background = Image.new("RGBA", (1920, 1080), (0, 0, 0, 0))
self.background.paste(Image.open(os.path.join(
os.path.dirname(os.path.realpath(__file__)), "background.png")))
self.core.wd, "background.png")))
@pyqtSlot(str, list)
def createPreviewImage(self, components):

View File

@ -1,30 +1,51 @@
from cx_Freeze import setup, Executable
import sys
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [
"apport",
"apt",
"ctypes",
"curses",
"distutils",
"email",
"html",
"http",
"json",
"xmlrpc",
"nose"
], include_files = ["main.ui"])
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
buildOptions = dict(
packages=[],
excludes=[
"apport",
"apt",
"curses",
"distutils",
"email",
"html",
"http",
"xmlrpc",
"nose"
],
include_files=[
"mainwindow.ui",
"presetmanager.ui",
"background.png",
"encoder-options.json",
"components/"
],
includes=[
'numpy.core._methods',
'numpy.lib.format'
]
)
base = 'Win32GUI' if sys.platform == 'win32' else None
executables = [
Executable('main.py', base=base, targetName = 'audio-visualizer-python')
Executable(
'main.py',
base=base,
targetName='audio-visualizer-python'
)
]
setup(name='audio-visualizer-python',
version = '1.0',
description = 'a little GUI tool to render visualization videos of audio files',
options = dict(build_exe = buildOptions),
executables = executables)
setup(
name='audio-visualizer-python',
version='1.0',
description='GUI tool to render visualization videos of audio files',
options=dict(build_exe=buildOptions),
executables=executables
)

View File

@ -69,7 +69,7 @@ class Worker(QtCore.QObject):
def previewDispatch(self):
background = Image.new("RGBA", (1920, 1080), (0, 0, 0, 0))
background.paste(Image.open(os.path.join(
os.path.dirname(os.path.realpath(__file__)), "background.png")))
self.core.wd, "background.png")))
background = background.resize((self.width, self.height))
while not self.stopped: