wxglade_hmi/wxglade_hmi.py
changeset 1742 92932cd370a4
parent 1741 dd94b9a68c61
child 1745 f9d32913bad4
equal deleted inserted replaced
1741:dd94b9a68c61 1742:92932cd370a4
    63             path = os.path.dirname(fileName)
    63             path = os.path.dirname(fileName)
    64             return path
    64             return path
    65         except ImportError:
    65         except ImportError:
    66             pass
    66             pass
    67 
    67 
    68         defLibDir="/usr/share/wxglade"
    68         defLibDir = "/usr/share/wxglade"
    69         if os.path.isdir(defLibDir):
    69         if os.path.isdir(defLibDir):
    70             path = defLibDir
    70             path = defLibDir
    71 
    71 
    72         return path
    72         return path
    73 
    73 
    87 
    87 
    88     def CTNGenerate_C(self, buildpath, locations):
    88     def CTNGenerate_C(self, buildpath, locations):
    89 
    89 
    90         hmi_frames = []
    90         hmi_frames = []
    91 
    91 
    92         wxgfile_path=self._getWXGLADEpath()
    92         wxgfile_path = self._getWXGLADEpath()
    93         if os.path.exists(wxgfile_path):
    93         if os.path.exists(wxgfile_path):
    94             wxgfile = open(wxgfile_path, 'r')
    94             wxgfile = open(wxgfile_path, 'r')
    95             wxgtree = minidom.parse(wxgfile)
    95             wxgtree = minidom.parse(wxgfile)
    96             wxgfile.close()
    96             wxgfile.close()
    97 
    97 
   102                         "class": node.getAttribute("class"),
   102                         "class": node.getAttribute("class"),
   103                         "handlers": [
   103                         "handlers": [
   104                             hnode.firstChild.data for hnode in
   104                             hnode.firstChild.data for hnode in
   105                             node.getElementsByTagName("handler")]})
   105                             node.getElementsByTagName("handler")]})
   106 
   106 
   107             hmipyfile_path=os.path.join(self._getBuildPath(), "hmi.py")
   107             hmipyfile_path = os.path.join(self._getBuildPath(), "hmi.py")
   108             if wx.Platform == '__WXMSW__':
   108             if wx.Platform == '__WXMSW__':
   109                 wxgfile_path = "\"%s\"" % wxgfile_path
   109                 wxgfile_path = "\"%s\"" % wxgfile_path
   110                 wxghmipyfile_path = "\"%s\"" % hmipyfile_path
   110                 wxghmipyfile_path = "\"%s\"" % hmipyfile_path
   111             else:
   111             else:
   112                 wxghmipyfile_path = hmipyfile_path
   112                 wxghmipyfile_path = hmipyfile_path
   118 
   118 
   119         else:
   119         else:
   120             define_hmi = ""
   120             define_hmi = ""
   121 
   121 
   122         declare_hmi = "\n".join(["%(name)s = None\n" % x +
   122         declare_hmi = "\n".join(["%(name)s = None\n" % x +
   123                           "\n".join(["%(class)s.%(h)s = %(h)s"%
   123                           "\n".join(["%(class)s.%(h)s = %(h)s" %
   124                             dict(x, h=h) for h in x['handlers']])
   124                             dict(x, h=h) for h in x['handlers']])
   125                                 for x in hmi_frames])
   125                                 for x in hmi_frames])
   126         global_hmi = ("global %s\n" % ",".join(
   126         global_hmi = ("global %s\n" % ",".join(
   127                          [x["name"] for x in hmi_frames])
   127                          [x["name"] for x in hmi_frames])
   128                       if len(hmi_frames) > 0 else "")
   128                       if len(hmi_frames) > 0 else "")