svghmi/svghmi.py
changeset 3498 cf4e6a7d40f8
parent 3399 95e0b926a8c3
child 3499 72ee59ff959c
equal deleted inserted replaced
3497:1b8906ca2a50 3498:cf4e6a7d40f8
   297         on_hmitree_update(hmi_tree_root)
   297         on_hmitree_update(hmi_tree_root)
   298 
   298 
   299         return ret
   299         return ret
   300 
   300 
   301 if wx.Platform == '__WXMSW__':
   301 if wx.Platform == '__WXMSW__':
   302     browser_launch_cmd="cmd.exe /c 'start msedge {url}'"
   302     default_cmds={
       
   303         "launch":"cmd.exe /c 'start msedge {url}'",
       
   304         "watchdog":"cmd.exe /k 'echo watchdog for {url} !'"}
   303 else:
   305 else:
   304     browser_launch_cmd="chromium {url}"
   306     default_cmds={
       
   307         "launch":"chromium {url}",
       
   308         "watchdog":"echo Watchdog for {name} !"}
   305 
   309 
   306 class SVGHMI(object):
   310 class SVGHMI(object):
   307     XSD = """<?xml version="1.0" encoding="utf-8" ?>
   311     XSD = """<?xml version="1.0" encoding="utf-8" ?>
   308     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   312     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   309       <xsd:element name="SVGHMI">
   313       <xsd:element name="SVGHMI">
   310         <xsd:complexType>
   314         <xsd:complexType>
   311           <xsd:attribute name="OnStart" type="xsd:string" use="optional" default="%s"/>
   315           <xsd:attribute name="OnStart" type="xsd:string" use="optional" default="%(launch)s"/>
   312           <xsd:attribute name="OnStop" type="xsd:string" use="optional" default=""/>
   316           <xsd:attribute name="OnStop" type="xsd:string" use="optional" default=""/>
   313           <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional" default=""/>
   317           <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional" default="%(watchdog)s"/>
   314           <xsd:attribute name="EnableWatchdog" type="xsd:boolean" use="optional" default="false"/>
   318           <xsd:attribute name="EnableWatchdog" type="xsd:boolean" use="optional" default="false"/>
   315           <xsd:attribute name="WatchdogInitial" use="optional" default="30">
   319           <xsd:attribute name="WatchdogInitial" use="optional" default="30">
   316             <xsd:simpleType>
   320             <xsd:simpleType>
   317                 <xsd:restriction base="xsd:integer">
   321                 <xsd:restriction base="xsd:integer">
   318                     <xsd:minInclusive value="2"/>
   322                     <xsd:minInclusive value="2"/>
   340             </xsd:simpleType>
   344             </xsd:simpleType>
   341           </xsd:attribute>
   345           </xsd:attribute>
   342         </xsd:complexType>
   346         </xsd:complexType>
   343       </xsd:element>
   347       </xsd:element>
   344     </xsd:schema>
   348     </xsd:schema>
   345     """%browser_launch_cmd
   349     """%default_cmds
   346 
   350 
   347     EditorType = SVGHMIEditor
   351     EditorType = SVGHMIEditor
   348 
   352 
   349     ConfNodeMethods = [
   353     ConfNodeMethods = [
   350         {
   354         {
   397 
   401 
   398     def OnCTNSave(self, from_project_path=None):
   402     def OnCTNSave(self, from_project_path=None):
   399         if from_project_path is not None:
   403         if from_project_path is not None:
   400             shutil.copyfile(self._getSVGpath(from_project_path),
   404             shutil.copyfile(self._getSVGpath(from_project_path),
   401                             self._getSVGpath())
   405                             self._getSVGpath())
   402             shutil.copyfile(self._getPOTpath(from_project_path),
   406 
   403                             self._getPOTpath())
   407             potpath = self._getPOTpath(from_project_path)
   404             # XXX TODO copy .PO files
   408             if os.path.isfile(potpath):
       
   409                 shutil.copyfile(potpath, self._getPOTpath())
       
   410                 # copy .PO files
       
   411                 for _name, pofile in GetPoFiles(from_project_path):
       
   412                     shutil.copy(pofile, self.CTNPath())
   405         return True
   413         return True
   406 
   414 
   407     def GetSVGGeometry(self):
   415     def GetSVGGeometry(self):
   408         self.ProgressStart("inkscape", "collecting SVG geometry (Inkscape)")
   416         self.ProgressStart("inkscape", "collecting SVG geometry (Inkscape)")
   409         # invoke inskscape -S, csv-parse output, produce elements
   417         # invoke inskscape -S, csv-parse output, produce elements