diff -r c8e008b8cefe -r 72a826dfcfbb svgui/svgui.py --- a/svgui/svgui.py Wed Mar 13 12:34:55 2013 +0900 +++ b/svgui/svgui.py Wed Jul 31 10:45:07 2013 +0900 @@ -5,12 +5,13 @@ from POULibrary import POULibrary from docutil import open_svg +from py_ext import PythonFileCTNMixin class SVGUILibrary(POULibrary): def GetLibraryPath(self): return os.path.join(os.path.split(__file__)[0], "pous.xml") -class SVGUI: +class SVGUI(PythonFileCTNMixin): ConfNodeMethods = [ {"bitmap" : "ImportSVG", @@ -26,13 +27,21 @@ def ConfNodePath(self): return os.path.join(os.path.dirname(__file__)) - def _getSVGpath(self): - # define name for IEC raw code file - return os.path.join(self.CTNPath(), "gui.svg") + def _getSVGpath(self, project_path=None): + if project_path is None: + project_path = self.CTNPath() + # define name for SVG file containing gui layout + return os.path.join(project_path, "gui.svg") def _getSVGUIserverpath(self): return os.path.join(os.path.dirname(__file__), "svgui_server.py") + def OnCTNSave(self, from_project_path=None): + if from_project_path is not None: + shutil.copyfile(self._getSVGpath(from_project_path), + self._getSVGpath()) + return PythonFileCTNMixin.OnCTNSave(self, from_project_path) + def CTNGenerate_C(self, buildpath, locations): """ Return C code generated by iec2c compiler @@ -72,10 +81,10 @@ runtimefile = open(runtimefile_path, 'w') runtimefile.write(svguiservercode % {"svgfile" : "gui.svg"}) runtimefile.write(""" -def _runtime_%(location)s_begin(): +def _runtime_%(location)s_start(): website.LoadHMI(%(svgui_class)s, %(jsmodules)s) -def _runtime_%(location)s_cleanup(): +def _runtime_%(location)s_stop(): website.UnLoadHMI() """ % {"location": location_str,