Beispiel #1
0
 def update_from_editor(self, widget=None):
     ed = self.Editor
     if not ed.data_editor.is_changed:
         print("Pas de modif")
         return
     if not ed.xml_status == -1:
         ed.data_editor.set_xml_structure()
     root = ed.data_editor.XML.getroot()
     function.indent(root)
     print(tostring(root).decode())
     ed.data_editor.is_changed = False
     ed.update_editor_title(False)
Beispiel #2
0
    def _save(self, widget=None):
        """Enregistre les modifications de la librairie des profilés dans le fichier utilisateur"""
        if not self.edited_cell is None:
            editable, path, col = self.edited_cell
            self.treestore[path][col] = editable.get_text()
            self.edited_cell = None
        iter = self.treestore.get_iter_first()
        li_data = []
        # les dictionnaires ne permettent pas de conserver l'ordre
        li_string = []
        for n in range(self.treestore.iter_n_children(None)):
            self._get_rows(self.treestore, iter, li_data, li_string)
            iter = self.treestore.iter_next(iter)

        # création du xml
        string = '<data pyBar="%s" version="%s"></data>' % (Const.SITE_URL,
                                                            Const.VERSION)
        xml = ET.ElementTree(ET.fromstring(string))
        root = xml.getroot()
        prec = 0
        prec_node = root
        parents = {0: root}
        for i, key in enumerate(li_string):
            n = len(key.split(':'))
            type = li_data[i][0]
            name = "%s" % li_data[i][1]
            if n == prec:  # meme niveau, meme parent
                parent = parents[n - 1]
            elif n == prec + 1:  # niveau inférieur
                parent = prec_node
                parents[prec] = prec_node
            else:
                parent = parents[n - 1]
            if type == True:
                node = ET.SubElement(parent, "group", {"id": name})
            else:
                node = ET.SubElement(parent, "profil", {"id": name})
                masse = "%s" % li_data[i][2].replace(',', '.')
                section = "%s" % li_data[i][3].replace(',', '.')
                igz = "%s" % li_data[i][4].replace(',', '.')
                h = "%s" % li_data[i][5].replace(',', '.')
                v = "%s" % li_data[i][6].replace(',', '.')
                node.set("m", masse)
                node.set("s", section)
                node.set("igz", igz)
                node.set("h", h)
                if not v == '':
                    node.set("v", v)
            prec_node = node
            prec = n
        function.indent(root)
        self._write_data(xml, root, Const.PROFILFILELIBRARY)
        self.has_changed = False
 def update_from_editor(self, widget=None):
     ed = self.Editor
     if not ed.data_editor.is_changed:
         print("Pas de modif")
         return
     if not ed.xml_status == -1:
         ed.data_editor.set_xml_structure()
     root = ed.data_editor.XML.getroot()
     function.indent(root)
     print(tostring(root).decode())
     ed.data_editor.is_changed = False
     ed.update_editor_title(False)
  def _save(self, widget=None):
    """Enregistre les modifications de la librairie des profilés dans le fichier utilisateur"""
    if not self.edited_cell is None:
      editable, path, col = self.edited_cell
      self.treestore[path][col] = editable.get_text()
      self.edited_cell = None
    iter = self.treestore.get_iter_first()
    li_data = []
    # les dictionnaires ne permettent pas de conserver l'ordre
    li_string = []
    for n in range(self.treestore.iter_n_children(None)):
      self._get_rows(self.treestore, iter, li_data, li_string)
      iter = self.treestore.iter_next(iter)

    # création du xml
    string = '<data pyBar="%s" version="%s"></data>' % (Const.SITE_URL, Const.VERSION)
    xml = ET.ElementTree(ET.fromstring(string))
    root = xml.getroot()
    prec = 0
    prec_node = root
    parents = {0: root}
    for i, key in enumerate(li_string):
      n = len(key.split(':'))
      type = li_data[i][0]
      name = "%s" % li_data[i][1]
      if n == prec: # meme niveau, meme parent
        parent = parents[n-1]
      elif n == prec + 1: # niveau inférieur
        parent = prec_node
        parents[prec] = prec_node
      else:
        parent = parents[n-1]
      if type == True:
        node = ET.SubElement(parent, "group", {"id": name})
      else:
        node = ET.SubElement(parent, "profil", {"id": name})
        masse = "%s" % li_data[i][2].replace(',', '.')
        section = "%s" % li_data[i][3].replace(',', '.')
        igz = "%s" % li_data[i][4].replace(',', '.')
        h = "%s" % li_data[i][5].replace(',', '.')
        v = "%s" % li_data[i][6].replace(',', '.')
        node.set("m", masse)
        node.set("s", section)
        node.set("igz", igz)
        node.set("h", h)
        if not v == '':
          node.set("v", v)
      prec_node = node
      prec = n
    function.indent(root)
    self._write_data(xml, root, Const.PROFILFILELIBRARY)
    self.has_changed = False
  def _save(self, widget=None):
    """Enregistre les modifications de la librairie dans le fichier utilisateur"""
    iter = self.treestore.get_iter_first()
    li_data = []
    # les dictionnaires ne permettent pas de conserver l'ordre
    li_string = []
    for n in range(self.treestore.iter_n_children(None)):
      self._get_rows(self.treestore, iter, li_data, li_string)
      iter = self.treestore.iter_next(iter)

    # création du xml
    string = '<data pyBar="%s" version="%s"></data>' % (Const.SITE_URL, Const.VERSION)
    xml = ET.ElementTree(ET.fromstring(string))
    root = xml.getroot()
    prec = 0
    prec_node = root
    parents = {0: root}
    for i, key in enumerate(li_string):
      n = len(key.split(':'))
      type = li_data[i][0]
      name = "%s" % li_data[i][1]
      if n == prec: # meme niveau, meme parent
        parent = parents[n-1]
      elif n == prec + 1: # niveau inférieur
        parent = prec_node
        parents[prec] = prec_node
      else:
        parent = parents[n-1]
      if type == True:
        node = ET.SubElement(parent, "group", {"id": name})
      else:
        node = ET.SubElement(parent, "materiau", {"id": name})
        E = "%s" % li_data[i][2].replace(',', '.')
        mv = "%s" % li_data[i][3].replace(',', '.')
        a = "%s" % li_data[i][4].replace(',', '.')
        node.set("young", E)
        node.set("mv", mv)
        node.set("alpha", a)
      prec_node = node
      prec = n
    function.indent(root)
    self._write_data(xml, root, Const.MATFILELIBRARY)
    self.has_changed = False