else:\r
self.offsetX += float(e.GetX() - self.oldX) * self.zoom / self.GetSize().GetHeight() * 2\r
self.offsetY -= float(e.GetY() - self.oldY) * self.zoom / self.GetSize().GetHeight() * 2\r
+ \r
+ #Workaround for buggy ATI cards.\r
size = self.GetSizeTuple()\r
self.SetSize((size[0]+1, size[1]))\r
self.SetSize((size[0], size[1]))\r
# 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):
def __init__(self, parent):
super(Toolbar, self).__init__(parent, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
class ToggleButton(buttons.GenBitmapToggleButton):
def __init__(self, parent, profileSetting, bitmapFilenameOn, bitmapFilenameOff,
helpText='', id=-1, callback=None, size=(20,20)):
- self.bitmapOn = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOn))
- self.bitmapOff = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOff))
+ self.bitmapOn = getBitmapImage(bitmapFilenameOn)
+ self.bitmapOff = getBitmapImage(bitmapFilenameOff)
super(ToggleButton, self).__init__(parent, id, self.bitmapOff, size=size)
class RadioButton(buttons.GenBitmapButton):
def __init__(self, parent, group, bitmapFilenameOn, bitmapFilenameOff,
helpText='', id=-1, callback=None, size=(20,20)):
- self.bitmapOn = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOn))
- self.bitmapOff = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOff))
+ self.bitmapOn = getBitmapImage(bitmapFilenameOn)
+ self.bitmapOff = getBitmapImage(bitmapFilenameOff)
super(RadioButton, self).__init__(parent, id, self.bitmapOff, size=size)
class NormalButton(buttons.GenBitmapButton):
def __init__(self, parent, callback, bitmapFilename,
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)
self.helpText = helpText
build_exe_options = {"packages": [
'encodings.utf_8',
"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
# console application).
#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.\r
import __init__\r
\r
-import ConfigParser, os, traceback, math, re, zlib, base64, time\r
+import ConfigParser, os, traceback, math, re, zlib, base64, time, sys\r
\r
#########################################################\r
## Default settings when none are found.\r
\r
## Profile functions\r
def getDefaultProfilePath():\r
- return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))\r
+ basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
+ #If we have a frozen python install, we need to step out of the library.zip\r
+ if hasattr(sys, 'frozen'):\r
+ basePath = os.path.normpath(os.path.join(basePath, ".."))\r
+ return os.path.normpath(os.path.join(basePath, "current_profile.ini"))\r
\r
def loadGlobalProfile(filename):\r
#Read a configuration file as global config\r
\r
def getPreferencePath():\r
basePath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))\r
- if os.path.basename(basePath) == 'library.zip':\r
+ #If we have a frozen python install, we need to step out of the library.zip\r
+ if hasattr(sys, 'frozen'):\r
basePath = os.path.normpath(os.path.join(basePath, ".."))\r
return os.path.normpath(os.path.join(basePath, "preferences.ini"))\r
\r
print "* Failed to find pypy, so sliced with python! *"
print "************************************************"
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"):
return "%s_export.%s" % (filename[: filename.rfind('.')], ext)
pypyExe = getPyPyExe()
if pypyExe == False:
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)
return cmd