confnodes/python/modules/svgui/svgui.py
changeset 718 5d4dc150b956
parent 717 1c23952dbde1
equal deleted inserted replaced
717:1c23952dbde1 718:5d4dc150b956
    20          "tooltip" : _("Create HMI"),
    20          "tooltip" : _("Create HMI"),
    21          "method" : "_StartInkscape"},
    21          "method" : "_StartInkscape"},
    22     ]
    22     ]
    23 
    23 
    24     def ConfNodePath(self):
    24     def ConfNodePath(self):
    25         return os.path.join(self.PlugParent.ConfNodePath(), "modules", self.PlugType)
    25         return os.path.join(self.CTNParent.ConfNodePath(), "modules", self.CTNType)
    26 
    26 
    27     def _getSVGpath(self):
    27     def _getSVGpath(self):
    28         # define name for IEC raw code file
    28         # define name for IEC raw code file
    29         return os.path.join(self.PlugPath(), "gui.svg")
    29         return os.path.join(self.CTNPath(), "gui.svg")
    30 
    30 
    31     def _getSVGUIserverpath(self):
    31     def _getSVGUIserverpath(self):
    32         return os.path.join(os.path.dirname(__file__), "svgui_server.py")
    32         return os.path.join(os.path.dirname(__file__), "svgui_server.py")
    33 
    33 
    34     def PlugGenerate_C(self, buildpath, locations):
    34     def CTNGenerate_C(self, buildpath, locations):
    35         """
    35         """
    36         Return C code generated by iec2c compiler 
    36         Return C code generated by iec2c compiler 
    37         when _generate_softPLC have been called
    37         when _generate_softPLC have been called
    38         @param locations: ignored
    38         @param locations: ignored
    39         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
    39         @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND
    85         res += (("runtime_%s.py"%location_str, file(runtimefile_path,"rb")),)
    85         res += (("runtime_%s.py"%location_str, file(runtimefile_path,"rb")),)
    86         
    86         
    87         return res
    87         return res
    88 
    88 
    89     def _ImportSVG(self):
    89     def _ImportSVG(self):
    90         dialog = wx.FileDialog(self.GetPlugRoot().AppFrame, _("Choose a SVG file"), os.getcwd(), "",  _("SVG files (*.svg)|*.svg|All files|*.*"), wx.OPEN)
    90         dialog = wx.FileDialog(self.GetCTRoot().AppFrame, _("Choose a SVG file"), os.getcwd(), "",  _("SVG files (*.svg)|*.svg|All files|*.*"), wx.OPEN)
    91         if dialog.ShowModal() == wx.ID_OK:
    91         if dialog.ShowModal() == wx.ID_OK:
    92             svgpath = dialog.GetPath()
    92             svgpath = dialog.GetPath()
    93             if os.path.isfile(svgpath):
    93             if os.path.isfile(svgpath):
    94                 shutil.copy(svgpath, self._getSVGpath())
    94                 shutil.copy(svgpath, self._getSVGpath())
    95             else:
    95             else:
    96                 self.GetPlugRoot().logger.write_error(_("No such SVG file: %s\n")%svgpath)
    96                 self.GetCTRoot().logger.write_error(_("No such SVG file: %s\n")%svgpath)
    97         dialog.Destroy()  
    97         dialog.Destroy()  
    98 
    98 
    99     def _StartInkscape(self):
    99     def _StartInkscape(self):
   100         svgfile = self._getSVGpath()
   100         svgfile = self._getSVGpath()
   101         open_inkscape = True
   101         open_inkscape = True
   102         if not self.GetPlugRoot().CheckProjectPathPerm():
   102         if not self.GetCTRoot().CheckProjectPathPerm():
   103             dialog = wx.MessageDialog(self.GetPlugRoot().AppFrame,
   103             dialog = wx.MessageDialog(self.GetCTRoot().AppFrame,
   104                                       _("You don't have write permissions.\nOpen Inkscape anyway ?"),
   104                                       _("You don't have write permissions.\nOpen Inkscape anyway ?"),
   105                                       _("Open Inkscape"),
   105                                       _("Open Inkscape"),
   106                                       wx.YES_NO|wx.ICON_QUESTION)
   106                                       wx.YES_NO|wx.ICON_QUESTION)
   107             open_inkscape = dialog.ShowModal() == wx.ID_YES
   107             open_inkscape = dialog.ShowModal() == wx.ID_YES
   108             dialog.Destroy()
   108             dialog.Destroy()