svgui/svgui.py
changeset 2442 b13f021c68a5
parent 1853 47a3f39bead0
child 2620 063391cd313d
equal deleted inserted replaced
2441:c553769a65af 2442:b13f021c68a5
    91 
    91 
    92         res = ([], "", False)
    92         res = ([], "", False)
    93 
    93 
    94         svgfile = self._getSVGpath()
    94         svgfile = self._getSVGpath()
    95         if os.path.exists(svgfile):
    95         if os.path.exists(svgfile):
    96             res += (("gui.svg", file(svgfile, "rb")),)
    96             res += (("gui.svg", open(svgfile, "rb")),)
    97 
    97 
    98         svguiserverfile = open(self._getSVGUIserverpath(), 'r')
    98         svguiserverfile = open(self._getSVGUIserverpath(), 'r')
    99         svguiservercode = svguiserverfile.read()
    99         svguiservercode = svguiserverfile.read()
   100         svguiserverfile.close()
   100         svguiserverfile.close()
   101 
   101 
   109         svguilibfile.write("pyjslib();\nsvguilib();\n")
   109         svguilibfile.write("pyjslib();\nsvguilib();\n")
   110         svguilibfile.write(open(os.path.join(fpath, "pyjs", "lib", "json.js"), 'r').read())
   110         svguilibfile.write(open(os.path.join(fpath, "pyjs", "lib", "json.js"), 'r').read())
   111         svguilibfile.write(open(os.path.join(fpath, "livesvg.js"), 'r').read())
   111         svguilibfile.write(open(os.path.join(fpath, "livesvg.js"), 'r').read())
   112         svguilibfile.close()
   112         svguilibfile.close()
   113         jsmodules = {"LiveSVGPage": "svguilib.js"}
   113         jsmodules = {"LiveSVGPage": "svguilib.js"}
   114         res += (("svguilib.js", file(svguilibpath, "rb")),)
   114         res += (("svguilib.js", open(svguilibpath, "rb")),)
   115 
   115 
   116         runtimefile_path = os.path.join(buildpath, "runtime_%s.py" % location_str)
   116         runtimefile_path = os.path.join(buildpath, "runtime_%s.py" % location_str)
   117         runtimefile = open(runtimefile_path, 'w')
   117         runtimefile = open(runtimefile_path, 'w')
   118         runtimefile.write(svguiservercode % {"svgfile": "gui.svg"})
   118         runtimefile.write(svguiservercode % {"svgfile": "gui.svg"})
   119         runtimefile.write("""
   119         runtimefile.write("""
   126         """ % {"location": location_str,
   126         """ % {"location": location_str,
   127                "svgui_class": "SVGUI_HMI",
   127                "svgui_class": "SVGUI_HMI",
   128                "jsmodules": str(jsmodules)})
   128                "jsmodules": str(jsmodules)})
   129         runtimefile.close()
   129         runtimefile.close()
   130 
   130 
   131         res += (("runtime_%s.py" % location_str, file(runtimefile_path, "rb")),)
   131         res += (("runtime_%s.py" % location_str, open(runtimefile_path, "rb")),)
   132 
   132 
   133         return res
   133         return res
   134 
   134 
   135     def _ImportSVG(self):
   135     def _ImportSVG(self):
   136         dialog = wx.FileDialog(self.GetCTRoot().AppFrame, _("Choose a SVG file"), os.getcwd(), "",  _("SVG files (*.svg)|*.svg|All files|*.*"), wx.OPEN)
   136         dialog = wx.FileDialog(self.GetCTRoot().AppFrame, _("Choose a SVG file"), os.getcwd(), "",  _("SVG files (*.svg)|*.svg|All files|*.*"), wx.OPEN)