mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-06 05:39:00 +08:00
Fixed a few issues with a frozen executable. Slicing now works, and images work. Will need more testing.
This commit is contained in:
parent
a93fde841c
commit
a9ed300675
@ -361,6 +361,8 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
|
|||||||
else:
|
else:
|
||||||
self.offsetX += float(e.GetX() - self.oldX) * self.zoom / self.GetSize().GetHeight() * 2
|
self.offsetX += float(e.GetX() - self.oldX) * self.zoom / self.GetSize().GetHeight() * 2
|
||||||
self.offsetY -= float(e.GetY() - self.oldY) * self.zoom / self.GetSize().GetHeight() * 2
|
self.offsetY -= float(e.GetY() - self.oldY) * self.zoom / self.GetSize().GetHeight() * 2
|
||||||
|
|
||||||
|
#Workaround for buggy ATI cards.
|
||||||
size = self.GetSizeTuple()
|
size = self.GetSizeTuple()
|
||||||
self.SetSize((size[0]+1, size[1]))
|
self.SetSize((size[0]+1, size[1]))
|
||||||
self.SetSize((size[0], size[1]))
|
self.SetSize((size[0], size[1]))
|
||||||
|
@ -12,6 +12,13 @@ from util import profile
|
|||||||
# toolbar buttons.
|
# toolbar buttons.
|
||||||
#######################################################
|
#######################################################
|
||||||
|
|
||||||
|
def getBitmapImage(filename):
|
||||||
|
#The frozen executable has the script files in a zip, so we need to exit another level to get to our images.
|
||||||
|
if hasattr(sys, 'frozen'):
|
||||||
|
return wx.Bitmap(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../../images", filename)))
|
||||||
|
else:
|
||||||
|
return wx.Bitmap(os.path.normpath(os.path.join(os.path.split(__file__)[0], "../images", filename)))
|
||||||
|
|
||||||
class Toolbar(wx.ToolBar):
|
class Toolbar(wx.ToolBar):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(Toolbar, self).__init__(parent, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
|
super(Toolbar, self).__init__(parent, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
|
||||||
@ -52,8 +59,8 @@ class Toolbar(wx.ToolBar):
|
|||||||
class ToggleButton(buttons.GenBitmapToggleButton):
|
class ToggleButton(buttons.GenBitmapToggleButton):
|
||||||
def __init__(self, parent, profileSetting, bitmapFilenameOn, bitmapFilenameOff,
|
def __init__(self, parent, profileSetting, bitmapFilenameOn, bitmapFilenameOff,
|
||||||
helpText='', id=-1, callback=None, size=(20,20)):
|
helpText='', id=-1, callback=None, size=(20,20)):
|
||||||
self.bitmapOn = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOn))
|
self.bitmapOn = getBitmapImage(bitmapFilenameOn)
|
||||||
self.bitmapOff = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOff))
|
self.bitmapOff = getBitmapImage(bitmapFilenameOff)
|
||||||
|
|
||||||
super(ToggleButton, self).__init__(parent, id, self.bitmapOff, size=size)
|
super(ToggleButton, self).__init__(parent, id, self.bitmapOff, size=size)
|
||||||
|
|
||||||
@ -114,8 +121,8 @@ class ToggleButton(buttons.GenBitmapToggleButton):
|
|||||||
class RadioButton(buttons.GenBitmapButton):
|
class RadioButton(buttons.GenBitmapButton):
|
||||||
def __init__(self, parent, group, bitmapFilenameOn, bitmapFilenameOff,
|
def __init__(self, parent, group, bitmapFilenameOn, bitmapFilenameOff,
|
||||||
helpText='', id=-1, callback=None, size=(20,20)):
|
helpText='', id=-1, callback=None, size=(20,20)):
|
||||||
self.bitmapOn = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOn))
|
self.bitmapOn = getBitmapImage(bitmapFilenameOn)
|
||||||
self.bitmapOff = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOff))
|
self.bitmapOff = getBitmapImage(bitmapFilenameOff)
|
||||||
|
|
||||||
super(RadioButton, self).__init__(parent, id, self.bitmapOff, size=size)
|
super(RadioButton, self).__init__(parent, id, self.bitmapOff, size=size)
|
||||||
|
|
||||||
@ -176,7 +183,7 @@ class RadioButton(buttons.GenBitmapButton):
|
|||||||
class NormalButton(buttons.GenBitmapButton):
|
class NormalButton(buttons.GenBitmapButton):
|
||||||
def __init__(self, parent, callback, bitmapFilename,
|
def __init__(self, parent, callback, bitmapFilename,
|
||||||
helpText='', id=-1, size=(20,20)):
|
helpText='', id=-1, size=(20,20)):
|
||||||
self.bitmap = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilename))
|
self.bitmap = getBitmapImage(bitmapFilename)
|
||||||
super(NormalButton, self).__init__(parent, id, self.bitmap, size=size)
|
super(NormalButton, self).__init__(parent, id, self.bitmap, size=size)
|
||||||
|
|
||||||
self.helpText = helpText
|
self.helpText = helpText
|
||||||
|
@ -7,7 +7,13 @@ sys.path.append('./cura_sf/')
|
|||||||
build_exe_options = {"packages": [
|
build_exe_options = {"packages": [
|
||||||
'encodings.utf_8',
|
'encodings.utf_8',
|
||||||
"OpenGL", "OpenGL.arrays", "OpenGL.platform",
|
"OpenGL", "OpenGL.arrays", "OpenGL.platform",
|
||||||
], "excludes": [], "optimize": 0}
|
], "excludes": [], "optimize": 0, "include_files": [
|
||||||
|
('images', 'images'),
|
||||||
|
('cura.py', 'cura.py'),
|
||||||
|
('__init__.py', '__init__.py'),
|
||||||
|
('util', 'util'),
|
||||||
|
('cura_sf', 'cura_sf')
|
||||||
|
]}
|
||||||
|
|
||||||
# GUI applications require a different base on Windows (the default is for a
|
# GUI applications require a different base on Windows (the default is for a
|
||||||
# console application).
|
# console application).
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import division
|
|||||||
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
|
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
|
||||||
import __init__
|
import __init__
|
||||||
|
|
||||||
import ConfigParser, os, traceback, math, re, zlib, base64, time
|
import ConfigParser, os, traceback, math, re, zlib, base64, time, sys
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
## Default settings when none are found.
|
## Default settings when none are found.
|
||||||
@ -170,7 +170,11 @@ preferencesDefaultSettings = {
|
|||||||
|
|
||||||
## Profile functions
|
## Profile functions
|
||||||
def getDefaultProfilePath():
|
def getDefaultProfilePath():
|
||||||
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))
|
basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
||||||
|
#If we have a frozen python install, we need to step out of the library.zip
|
||||||
|
if hasattr(sys, 'frozen'):
|
||||||
|
basePath = os.path.normpath(os.path.join(basePath, ".."))
|
||||||
|
return os.path.normpath(os.path.join(basePath, "current_profile.ini"))
|
||||||
|
|
||||||
def loadGlobalProfile(filename):
|
def loadGlobalProfile(filename):
|
||||||
#Read a configuration file as global config
|
#Read a configuration file as global config
|
||||||
@ -273,7 +277,8 @@ globalPreferenceParser = None
|
|||||||
|
|
||||||
def getPreferencePath():
|
def getPreferencePath():
|
||||||
basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
|
||||||
if os.path.basename(basePath) == 'library.zip':
|
#If we have a frozen python install, we need to step out of the library.zip
|
||||||
|
if hasattr(sys, 'frozen'):
|
||||||
basePath = os.path.normpath(os.path.join(basePath, ".."))
|
basePath = os.path.normpath(os.path.join(basePath, ".."))
|
||||||
return os.path.normpath(os.path.join(basePath, "preferences.ini"))
|
return os.path.normpath(os.path.join(basePath, "preferences.ini"))
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ def runSlice(fileNames):
|
|||||||
print "* Failed to find pypy, so sliced with python! *"
|
print "* Failed to find pypy, so sliced with python! *"
|
||||||
print "************************************************"
|
print "************************************************"
|
||||||
else:
|
else:
|
||||||
subprocess.call([pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), fileName])
|
subprocess.call(getSliceCommand(fileName))
|
||||||
|
|
||||||
def getExportFilename(filename, ext = "gcode"):
|
def getExportFilename(filename, ext = "gcode"):
|
||||||
return "%s_export.%s" % (filename[: filename.rfind('.')], ext)
|
return "%s_export.%s" % (filename[: filename.rfind('.')], ext)
|
||||||
@ -146,7 +146,13 @@ def getSliceCommand(filename):
|
|||||||
pypyExe = getPyPyExe()
|
pypyExe = getPyPyExe()
|
||||||
if pypyExe == False:
|
if pypyExe == False:
|
||||||
pypyExe = sys.executable
|
pypyExe = sys.executable
|
||||||
cmd = [pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString()]
|
|
||||||
|
#In case we have a frozen exe, then argv[0] points to the executable, but we want to give pypy a real script file.
|
||||||
|
if hasattr(sys, 'frozen'):
|
||||||
|
mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "cura.py"))
|
||||||
|
else:
|
||||||
|
mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1]))
|
||||||
|
cmd = [pypyExe, mainScriptFile, '-p', profile.getGlobalProfileString()]
|
||||||
cmd.append(filename)
|
cmd.append(filename)
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user