changeset 25:189f8274aecd

gui. switch navigation menu on switch page
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Mon, 20 May 2019 13:18:33 +0200
parents 2b393934f1db
children 16f91684686b
files Generic/base.py Generic/fiebdc.py Generic/globalVars.py Gtk/gui.py
diffstat 4 files changed, 323 insertions(+), 199 deletions(-) [+]
line wrap: on
line diff
--- a/Generic/base.py	Fri May 03 11:11:00 2019 +0200
+++ b/Generic/base.py	Mon May 20 13:18:33 2019 +0200
@@ -418,7 +418,7 @@
         Sets the code, must be a valid code
         """
         if not utils.is_valid_code(code)[0]:
-            raise ValueError( utils.mapping(_("Invalid code: $1"),(str(code),)) )
+            raise ValueError(utils.mapping(_("Invalid code: $1"),(str(code),)))
         self.__code = code
 
     def getSynonyms(self):
@@ -1004,7 +1004,7 @@
 
     def setCertification(self, certification):
         if not (certification is None or isinstance(certification, list)):
-            raise ValueError( _("Certification atribute must be a list or None") )
+            raise ValueError(_("Certification atribute must be a list or None"))
         self.__certification = certification
 
     def getRealCost(self):
@@ -1028,7 +1028,7 @@
 
     def setCostPlanned(self, cost_planned):
         if not (cost_planned is None or  isinstance(cost_planned, list)):
-            raise ValueError( _("Cost Planned atribute must be a list or None") )
+            raise ValueError(_("Cost Planned atribute must be a list or None"))
         self.__cost_planned = cost_planned
 
     position = property(getPosition, setPosition, None,
@@ -1661,7 +1661,7 @@
         "DRA": Number of decimal places of the yield in a decompositon of a
             auxiliar element.
             Number of decimal places of the result of the multiplication of 
-            the yield and the factor in a descomposition of a auxilar element.Decimales
+            the yield and the factor in a descomposition of a auxilar element.
             Default: 3 decimal places.
         "DP": Number of decimal places of the price of a budget.
             Default: 2 decimal places.
@@ -1926,7 +1926,8 @@
             The records can have diferent prices for diferent ages, geografical
             places, ...
         +-- __title_index: A integer. The active group of Prices and Decimals.
-        +-- __sheet_sections: sheet sections dictionary { sheet_code : sheet_title }
+        +-- __sheet_sections: sheet sections dictionary
+                   { sheet_code : sheet_title }
         +-- __sheet_fields: sheet fields dictionary { field_code : field_title }
         +-- __sheet_paragraphs: sheet paragraphs dictionary 
                            { paragraph_code : paragraph_text}
@@ -2190,7 +2191,7 @@
                 datetime.date(*date)
             self.__date = date
         else:
-            raise  TypeError( utils.mapping(_("Invalid Date: $1"),(str(date),)) )
+            raise  TypeError(utils.mapping(_("Invalid Date: $1"),(str(date),)))
 
     def setComment(self, comment):
         """setOwner(self, comment)
@@ -2244,7 +2245,8 @@
             datetime.date(*certificate_date)
             self.__budgetCerficateDate = certificate_date
         else:
-            raise  ValueError( _("Budget certificate Date must be a valid Date.") )
+            _str = _("Budget certificate Date must be a valid Date.")
+            raise  ValueError(_str)
 
     def setTitleList(self, title_list):
         """setTitleList(self, title_list)
@@ -2481,7 +2483,7 @@
             if code == None: # No root
                 print( "No-estructured measures. Adding root record " +  
                 str(self.setRecord("root", [], 0, "", "", [0.0,], [(1,1,1970)],
-                                     0, "") ))
+                                     0, "") ).encode("utf8"))
                 code = self.getRoot()
 
         if not utils.is_valid_code(code)[0]:
@@ -2499,9 +2501,10 @@
         for _parent_code in _all_parent_list:
             if _parent_code in _all_child_list:
                 # TODO: change return to except
-                print(utils.mapping(_("Circular Decomposition, parent code: "\
-                      "$1, child code: $2, repeated code: $3"),
-                      (str(code), str(child_code), str(_parent_code))) )
+                _str = _("Circular Decomposition, parent code: "\
+                         "$1, child code: $2, repeated code: $3")
+                print(utils.mapping(_str, (str(code), str(child_code),
+                                           str(_parent_code))).encode("utf8") )
                 return
 
         # Creating reference to parent code in child record
@@ -2520,19 +2523,24 @@
             _child_number = len(_record.children)
             if position == -1: # New child
                 position = _child_number
-            if position == -2: # No-estructured measures or empty position (error in FIEBDC file)
+            # No-estructured measures or empty position (error in FIEBDC file)
+            if position == -2: 
                 positions = _record.getChildPositions(child_code)
                 if len(positions) == 1:
                     position = positions[0]
-                    print(utils.mapping(_("No-estructured measure or empty position. Parent Code: "\
-                          "$1, Child code: $2, Position: $3"),(str(code), str(child_code), str(position))) )
+                    _str = _("No-estructured measure or empty position. " \
+                             "Parent Code: $1, Child code: $2, Position: $3")
+                    print(utils.mapping(_str,(str(code), str(child_code),
+                                        str(position))).encode("utf8") )
                 else:
                     position = _child_number
-                    print(utils.mapping(_("No-estructured measure or empty position. "\
-                          "Repeated child in unspecified position. "\
-                          "It is impossible to determine the position. "\
-                          "New child is added in the decomposition. "\
-                          "Parent code: $1, Child code: $2, Position: $3"),(str(code), str(child_code), str(position))) )
+                    _str = _("No-estructured measure or empty position. "\
+                             "Repeated child in unspecified position. "\
+                             "It is impossible to determine the position. "\
+                             "New child is added in the decomposition. "\
+                             "Parent code: $1, Child code: $2, Position: $3")
+                    print(utils.mapping(_str,(str(code), str(child_code),
+                                        str(position))).encode("utf8") )
             if position == _child_number:
                 # The record do not have the child
                 if not isinstance(factor, float): factor = 1.0
@@ -2568,21 +2576,27 @@
                     _measure.label = label
             else:
                 # TODO: change return for except
-                print(utils.mapping(_("Error: Invalid child position in "
-                      "decomposition. Parent code: $1 Child code: $2 "\
-                      "Position: $3"), (str(code), str(child_code), str(position))) )
+                _str = _("Error: Invalid child position in "
+                         "decomposition. Parent code: $1 Child code: $2 "\
+                         "Position: $3")
+                print(utils.mapping(_str, (str(code), str(child_code),
+                                    str(position))).encode("utf8") )
                 return
         else:
-            if child_code == "" : 
-                print(utils.mapping(_("Error: Empty child code. Parent code: "\
-                      "$1 Position: $2"), (str(code), str(position))) )
+            if child_code == "" :
+                _str = _("Error: Empty child code. Parent code: "\
+                         "$1 Position: $2")
+                print(utils.mapping(_str, (str(code),
+                                           str(position))).encode("utf8") )
                 return
             if position == -1:
                 position = 0
             elif position != 0:
-                print(utils.mapping(_("Error: Invalid child position in "\
-                      "decomposition. Parent code: $1 Child code: $2 "\
-                      "Position: $3"), (str(code), str(child_code), str(position))) )
+                _str = _("Error: Invalid child position in "\
+                         "decomposition. Parent code: $1 Child code: $2 "\
+                         "Position: $3")
+                print(utils.mapping(_str, (str(code), str(child_code),
+                                    str(position))).encode("utf8") )
                 return
             if not isinstance(factor, float):
                 factor = 1.0
@@ -2676,7 +2690,8 @@
         Sests the description text of a record
         """
         if not utils.is_valid_code(code)[0]:
-            raise ValueError( utils.mapping(_("Invalid record: $1"), (str(code),)) )
+            _str = _("Invalid record: $1")
+            raise ValueError( utils.mapping(_str, (str(code),)) )
         if not code in self.__records:
             _record = self.setRecord(code, [], "", "", "", [], [],
                                      "", "")
@@ -2739,9 +2754,10 @@
             if self.__root is None:
                 self.__root = code
             else:
-                print(_("Only can be one root record") )
+                print(_("Only can be one root record").encode("utf8") )
                 return
-                # TODO: If the root is created in settree. No-estructured measures
+                # TODO: If the root is created in settree.
+                #       No-estructured measures
                 # TODO  Rewrite root values
         # retake previous values.
         # TODO: test synonyms
@@ -2976,7 +2992,8 @@
         if not isinstance(paragraph_dict, dict):
             raise ValueError( _("The paragraph dict must be a dictionary") )
         for paragraph_code in paragraph_dict.keys():
-            self.setSheetParagraph( paragraph_code, paragraph_dict[paragraph_code])
+            self.setSheetParagraph(paragraph_code,
+                                   paragraph_dict[paragraph_code])
 
     def setSheetRecord(self, record_code, field, section_dict):
         if not isinstance(record_code, str):
@@ -2988,9 +3005,11 @@
         #-#
         # TODO: Add a empty record?
         if not self.hasRecord(record_code):
-            print(utils.mapping(_("Error: The budget do not have this record "\
-                "code and can not be added the sheet text in the field $1. "\
-                "Record Code: $2"), ( str(field), str(record_code))) )
+            _str = _("Error: The budget do not have this record "\
+                   "code and can not be added the sheet text in the field $1. "\
+                   "Record Code: $2")
+            print(utils.mapping(_str, ( str(field),
+                                str(record_code))).encode("utf8") )
             return
         #-#
         if not self.hasSheetField(field):
@@ -3014,7 +3033,7 @@
         if not self.hasRecord(record_code):
             print(utils.mapping(_("Error: The budget do not have the record "\
                 "code $1 and can not be added the file: $2"),
-                (str(record_code), str(filepath))) )
+                (str(record_code), str(filepath))).encode("utf8") )
             return
         #-#
         _record = self.getRecord(record_code)
@@ -3152,13 +3171,13 @@
             print(utils.mapping(_("Error: The budget do not have the record "\
                 "code $1 and can not be added the Parametric select comment: "\
                 "$2"),
-                (str(record_code), str(comment))) )
+                (str(record_code), str(comment))).encode("utf8") )
             return
         _record = self.getRecord(record_code)
         if not isinstance(_record, ParametricRecord):
             print(utils.mapping(_("Error: The Record $1 is not a "\
                 "Parametric Record and can not have Parametric comment"),
-                (str(record_code),)) )
+                (str(record_code),)).encode("utf8") )
         else:
             _record.select_comment = comment
 
@@ -3174,13 +3193,13 @@
         if not self.hasRecord(record_code):
             print(utils.mapping(_("Error: The budget do not have the record "\
                 "code $1 and can not be seted the summary: $2"),
-                (str(record_code), str(summary))) )
+                (str(record_code), str(summary))).encode("utf8") )
             return
         _record = self.getRecord(record_code)
         if not isinstance(_record, ParametricRecord):
             print(utils.mapping(_("Error: The Record $1 is not a "\
                 "Parametric Record and can not have Parametric summary"),
-                (str(record_code),)) )
+                (str(record_code),)).encode("utf8") )
         else:
             self.getRecord(record_code).parametric_summary = summary
 
@@ -3196,13 +3215,13 @@
         if not self.hasRecord(record_code):
             print(utils.mapping(_("Error: The budget do not have the record "\
                 "code $1 and can not be seted the text: $2"),
-                (str(record_code), str(text))) )
+                (str(record_code), str(text))).encode("utf8") )
             return
         _record = self.getRecord(record_code)
         if not isinstance(_record, ParametricRecord):
             print(utils.mapping(_("Error: The Record $1 is not a "\
                 "Parametric Record and can not have Parametric text"),
-                (str(record_code),)) )
+                (str(record_code),)).encode("utf8") )
         else:
             self.getRecord(record_code).parametric_text = text
 
@@ -3726,7 +3745,7 @@
             raise ValueError( utils.mapping(_("Invalid Hierarchy ($1) "\
                   "The hierarchy must be -1, 0, 1, 2"), (str(hierarchy),)) )
         elif hierarchy == "":
-            print("Hierarchy temporarily set to an empty string")
+            print("Hierarchy temporarily set to an empty string".encode("utf8"))
         #TODO Check empty Hierarchy in Generic.fiebdc.Read._testBudget
         self.__hierarchy = hierarchy
 
--- a/Generic/fiebdc.py	Fri May 03 11:11:00 2019 +0200
+++ b/Generic/fiebdc.py	Mon May 20 13:18:33 2019 +0200
@@ -147,27 +147,39 @@
         if it is posible return a valid code else return a empty string.
         """
         if not isinstance(code, unicode):
-            print(_("Invalid code, it must be a unicode string") )
+            _str = _("Invalid code, it must be a unicode string")
+            print(_str.encode("utf-8") )
             return u""
         # Valid chararcter: A-Z a-z 0-9 ñ Ñ . $ # % & _ 
         # "valid_code" : "[^A-Za-z0-9ñÑ.$#%&_]"
         _ucode = self.__pattern["valid_code"].sub(u"_", code)
         if _ucode != code:
             try:
-                print(utils.mapping(_("The code '$1' have invalid characters, replaced by '$2'."),
-                               (code.encode("utf8"),_ucode.encode("utf8"))) )
+                _tstr = _("The code '$1' have invalid characters," \
+                         " replaced by '$2'.")
+                print(utils.mapping(_tstr, (code.encode("utf8"),
+                                    _ucode.encode("utf8"))) )
             except:
-                print(utils.mapping(_("The code '$1' have invalid characters and can not be encoded in utf8."), (code,)) )
+                _tstr = _("The code '$1' have invalid characters and can not" \
+                         " be encoded in utf8.")
+                print(utils.mapping(_tstr, (code,)).encode("utf-8") )
             
             if len(_ucode) == 0:
-                _normalize_code = ''.join((c for c in unicodedata.normalize('NFD', _ucode) if unicodedata.category(c) != 'Mn'))
-                # from http://www.leccionespracticas.com/uncategorized/eliminar-tildes-con-python-solucionado/
+                _normalize_code = ""
+                for c in unicodedata.normalize('NFD', _ucode):
+                    if unicodedata.category(c) != 'Mn':
+                        _normalize_code.join(c)
+                #_normalize_code = ''.join((c for c in unicodedata.normalize(
+                # 'NFD', _ucode) if unicodedata.category(c) != 'Mn'))
+                # from http://www.leccionespracticas.com/uncategorized/
+                #      eliminar-tildes-con-python-solucionado/
                 _ucode = self.__pattern["valid_code"].sub(u"", _normalize_code)
                 if len(_ucode) == 0:
                     _hash_code = hashlib.sha256()
                     _hash_code.update(code.encode('utf-8'))
                     _hexdigest_code = _hash_code.hexdigest()
-                    _ucode = self.__pattern["valid_code"].sub(u"", _hexdigest_code)
+                    _p_valid_code = self.__pattern["valid_code"]
+                    _ucode = _p_valid_code.sub(u"", _hexdigest_code)
             code = _ucode
         if code == u"##":
             # root code is an empty code : set to ROOT
@@ -185,7 +197,8 @@
             # only one charecter # % or &
             if sum([code.count(c) for c in u'#%&']) > 1:
                 print(utils.mapping(_("The code '$1' contains special "\
-                                      "characters repeated."),(code.encode("utf8"),)) )
+                      "characters repeated."),
+                      (code.encode("utf8"),)).encode("utf-8") )
                 _i = min([code.find(c) for c in u'#%&'])
                 code = code[:_i+1] + \
                         self.__pattern["special_char"].sub(u"", code[_i+1:])
@@ -388,7 +401,8 @@
             self.__statistics.A += 1
             self._parseA(_field_list)
         else:
-            print(utils.mapping(_("FIEBDC. Unknow record: $1"),(record[:100],)))
+            print(utils.mapping(_("FIEBDC. Unknow record: $1"),
+                                  (record[:100],)).encode("utf-8"))
             self.__statistics.unknow += 1
 
     def _parseV(self, field_list):
@@ -409,9 +423,10 @@
         if self.__statistics.records != 1:
             print(utils.mapping(_("The 'V' record (Property and Version) "\
                     "must be the first record in the file but it is the "\
-                    "number: $1"), (str(self.__statistics.records),)) )
+                    "number: $1"),
+                    (str(self.__statistics.records),)).encode("utf-8") )
             print(_("The default values were taken and this V record is "\
-                  "ignored") )
+                  "ignored").encode("utf-8") )
             return
         # _____number of fields_____
         # Any INFORMATION after last field separator is ignored
@@ -444,7 +459,8 @@
         _file_format = _version_date[0]
         if _file_format in self.__format_list:
             self.__file_format = _file_format
-            print(utils.mapping(_("FIEBDC format: $1"),(_file_format,)) )
+            print(utils.mapping(_("FIEBDC format: $1"),
+                                  (_file_format,)).encode("utf-8") )
 
         if len(_version_date) > 1:
             _date = _version_date[1]
@@ -454,7 +470,8 @@
                     self.__budget.setDate(_parsed_date)
         # _____Generator_____
         # ignored field
-        print(utils.mapping(_("FIEBDC file generated by $1"),(_generator,)) )
+        print(utils.mapping(_("FIEBDC file generated by $1"),
+                            (_generator,)).encode("utf-8") )
         # _____Header_Title_____
         _header_title = _header_title.split(u"\\")
         _header_title = [_title.strip() for _title in _header_title]
@@ -795,7 +812,7 @@
             _code = _codes[0]
             _synonyms = [synonym.encode("utf8") for synonym in _codes]
         else:
-            print(_("Record C without a valid code") )
+            print(_("Record C without a valid code").encode("utf-8") )
             return
         # _____Unit_____
         # nothing to do
@@ -874,7 +891,8 @@
                 _type = 0
             else:
                 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
-                      (_type.encode("utf8"), _code.encode("utf8"))) )
+                      (_type.encode("utf8"),
+                       _code.encode("utf8"))).encode("utf-8") )
                 _type = 0
                 _subtype = u""
         elif _hierarchy == 1:
@@ -886,7 +904,8 @@
                 _type = 0
             else:
                 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
-                      (_type.encode("utf8"), _code.encode("utf8"))) )
+                      (_type.encode("utf8"),
+                       _code.encode("utf8"))).encode("utf-8") )
                 _type = 0
                 _subtype = u""
         else:
@@ -914,7 +933,8 @@
                 _type = 0
             else:
                 print(utils.mapping(_("Incorrect type ($1) in the code $2"),
-                      (_type.encode("utf8"), _code.encode("utf8"))) )
+                      (_type.encode("utf8"),
+                       _code.encode("utf8"))).encode("utf-8") )
                 _type = 0
                 _subtype = u""
         self.__budget.setRecord(_code.encode("utf8"), _synonyms, _hierarchy,
@@ -971,7 +991,8 @@
                           "descomposition of the record $1, the factor "\
                           "of the child $2 must be a float number and "\
                           "can not be $3, seted default value 1.0"),
-                          (_code.encode("utf8"), _child_code.encode("utf8"), _factor.encode("utf8"))) )
+                          (_code.encode("utf8"), _child_code.encode("utf8"),
+                           _factor.encode("utf8"))).encode("utf-8") )
                     _factor = 1.0
             #____yield___
             if _yield != u"":
@@ -982,7 +1003,8 @@
                           "descomposition of the record $1, the yield of "\
                           "the child $2, must be a float number and can"\
                           "not be $3,  seted default value 1.0"),
-                           (_code.encode("utf8"), _child_code.encode("utf8"), _factor.encode("utf8"))) )
+                           (_code.encode("utf8"), _child_code.encode("utf8"),
+                            _factor.encode("utf8"))).encode("utf-8") )
                     _yield = 1.0
             if _child_code != u"" and _code != u"":
                 _children_list.append([_child_code, _factor, _yield ])
@@ -990,7 +1012,8 @@
                 _position = _child_index / 3
             else: #_record_type == "Y"
                 _position = -1
-            self.__budget.setTree(_code.encode("utf8"), _child_code.encode("utf8"), _position, _factor, 
+            self.__budget.setTree(_code.encode("utf8"),
+                _child_code.encode("utf8"), _position, _factor, 
                 _yield, "", "", "", "")
             _child_index = _child_index + 3
             interface.updateGui()
@@ -1068,11 +1091,13 @@
             _parent_code = None
         else:
             print(utils.mapping(_("Invalid codes in $1 record, codes $2"),
-                  (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                  (_record_type.encode("utf8"),
+                   _codes.encode("utf8"))).encode("utf-8") )
             return
         if _child_code == u"":
             print(utils.mapping(_("Empty child code in $1 record, codes: "\
-                  "$2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                  "$2"), (_record_type.encode("utf8"),
+                   _codes.encode("utf8"))).encode("utf-8") )
             return
         if _parent_code == None:
             # Empty parent code. No-estructured measures.
@@ -1092,7 +1117,8 @@
                 _path = int(_path)
             except ValueError:
                 print(utils.mapping(_("Invalid path in $1 record, "\
-                      "codes $2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                      "codes $2"), (_record_type.encode("utf8"),
+                       _codes.encode("utf8"))).encode("utf-8") )
                 return
             if _path > 0:
                 _path -= 1
@@ -1104,7 +1130,8 @@
         except ValueError:
             print(utils.mapping(_("Invalid Total Measure value in $1 "\
                   "record, codes $2. Total fixed to 0."),
-                  (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                  (_record_type.encode("utf8"),
+                   _codes.encode("utf8"))).encode("utf-8") )
             _total = 0
         # _____Measure lines_____
         _lines = _lines.split(u"\\")
@@ -1125,7 +1152,8 @@
                 if self.__pattern["formula"].match(_comment):
                     print(utils.mapping(_("The comment is not a formula or "\
                           "its have invalid characters, in the $1 record, "\
-                          "codes $2"), (_record_type.encode("utf8"), _codes.encode("utf8"))) )
+                          "codes $2"), (_record_type.encode("utf8"),
+                           _codes.encode("utf8"))).encode("utf-8") )
                     return
                 else:
                     _formula = _comment.encode("utf8")
@@ -1150,7 +1178,8 @@
                 if _height != u"": _height = float(_height)
             except ValueError:
                 print(utils.mapping(_("The measure values are not float "\
-                      "numbers, code $1"), (_codes.encode("utf8"),)) )
+                      "numbers, code $1"),
+                      (_codes.encode("utf8"),)).encode("utf-8") )
                 return
             # Prevent subfield units remains empty.
             if (_units == u"" and (_length != u"" or _width != u""
@@ -1160,7 +1189,8 @@
                                _length, _width, _height, _formula])
             _line_index = _line_index + 6
         self.__budget.setTree(_parent_code, _child_code.encode("utf8"), _path, "", "",
-                           _total, _line_list, _label.encode("utf8"), _record_type.encode("utf8"))
+                           _total, _line_list, _label.encode("utf8"),
+                           _record_type.encode("utf8"))
         self.__statistics.valid = self.__statistics.valid + 1
 
     def _parseW(self, field_list):
@@ -1197,7 +1227,9 @@
             _field_code = self.delete_control_space(_field_code)
             # _____section_title_____
             if _field_code != u"":
-                _field_dict[_field_code.encode("utf8")] = _field_title.encode("utf8")
+                _e_field_code = _field_code.encode("utf8")
+                _e_field_title = _field_title.encode("utf8")
+                _field_dict[_e_field_code] = _e_field_title
             _field_index = _field_index + 2
         self.__budget.setSheetFields(_field_dict)
         self.__statistics.valid = self.__statistics.valid +1
@@ -1247,7 +1279,9 @@
                 # _____section_title_____
                 _section_title = self.delete_control_space(_section_title)
                 if _section_code != u"":
-                    _section_dict[_section_code.encode("utf8")] = _section_title.encode("utf8")
+                    _e_section_code = _section_code.encode("utf8")
+                    _e_section_title = _section_title.encode("utf8")
+                    _section_dict[_e_section_code] = _e_section_title
                 _section_index = _section_index + 2
             self.__budget.setSheetSections(_section_dict)
             self.__statistics.valid = self.__statistics.valid +1
@@ -1267,7 +1301,8 @@
             _scodes_text = field_list[1]
             if _scodes_text == u"":
                 # TODO: rtf and html files
-                print("Html and rtf files not yet implemented in ~L record" )
+                _str = "Html and rtf files not yet implemented in ~L record"
+                print(_str.encode("utf-8") )
             else:
                 # _____Section-code_Section-text_____
                 # last \ is erased
@@ -1288,11 +1323,15 @@
                     if _section_code != u"" and _section_text != u"":
                         #-# paragraph #-#
                         _paragraph_code = _record_code + _section_code + u"*"
-                        _paragraph_dict[ _paragraph_code.encode("utf8") ] = _section_text.encode("utf8")
-                        _section_dict[_section_code.encode("utf8")] = _paragraph_code.encode("utf8")
+                        _e_paragraph_code = _paragraph_code.encode("utf8")
+                        _e_section_text = _section_text.encode("utf8")
+                        _paragraph_dict[_e_paragraph_code] = _e_section_text
+                        _e_section_code = _section_code.encode("utf8")
+                        _section_dict[_e_section_code] = _e_paragraph_code
                     _section_index = _section_index + 2
                 self.__budget.setSheetParagraphs(_paragraph_dict)
-                self.__budget.setSheetRecord(_record_code.encode("utf8"), "*", _section_dict)
+                self.__budget.setSheetRecord(_record_code.encode("utf8"), "*",
+                                             _section_dict)
                 self.__statistics.valid = self.__statistics.valid +1
     
     def _parseQ(self, field_list):
@@ -1350,10 +1389,13 @@
                     else:
                         _section_dict = {}
                         _field_dict[_field_key] = _section_dict
-                    _section_dict[_section_code.encode("utf8")] = _paragraph_code.encode("utf8")
+                    _e_section_code = _section_code.encode("utf8")
+                    _e_paragraph_code = _paragraph_code.encode("utf8")
+                    _section_dict[_e_section_code] = _e_paragraph_code
             _section_index = _section_index + 3
         for _field, _section_dict in _field_dict.iteritems():
-            self.__budget.setSheetRecord(_record_code.encode("utf8"), _field.encode("utf8"), _section_dict)
+            self.__budget.setSheetRecord(_record_code.encode("utf8"),
+                                         _field.encode("utf8"), _section_dict)
         self.__statistics.valid = self.__statistics.valid +1
     
     def _parseJ(self, field_list):
@@ -1382,9 +1424,11 @@
         _paragraph_text = field_list[1]
         if _paragraph_text == u"":
             # TODO: rtf and html files
-            print("Html and rtf files not yet implemented in ~J record" )
+            _str = "Html and rtf files not yet implemented in ~J record"
+            print(_str.encode("utf-8") )
         else:
-            self.__budget.setSheetParagraph(paragraph_code.encode("utf8"), paragraph_text.encode("utf8"))
+            self.__budget.setSheetParagraph(paragraph_code.encode("utf8"),
+                                            paragraph_text.encode("utf8"))
             self.__statistics.valid = self.__statistics.valid +1
     
     def _parseG(self, field_list):
@@ -1450,10 +1494,11 @@
                     _tested_grafic_file_list.append(_grafic_file_path_ll)
                 else:
                     print(utils.mapping(_("The file $1 do not exist"),
-                        (_grafic_file_path.decode("utf8"),)) )
+                        (_grafic_file_path.decode("utf8"),)).encode("utf-8") )
         if len(_grafic_file_list) > 0:
             for _grafic_file in _tested_grafic_file_list:
-                self.__budget.addFile(_record_code.encode("utf8"), _grafic_file, "img", "")
+                self.__budget.addFile(_record_code.encode("utf8"),
+                                      _grafic_file, "img", "")
             self.__statistics.valid = self.__statistics.valid +1
     
     def _parseE(self, field_list):
@@ -1530,11 +1575,16 @@
                _postal_code != u"" or _town != u"" or _province != u"" or \
                _country != u"" or _phone != u"" or _fax != u"" or \
                _contact_person != u"":
-                _local_offices.append([_type.encode("utf8"), _subname.encode("utf8"),
-                                       _address.encode("utf8"), _postal_code.encode("utf8"),
-                                       _town.encode("utf8"), _province.encode("utf8"),
-                                       _country.encode("utf8"), _phone_list,
-                                       _fax_list, _contact_person.encode("utf8")])
+                _local_offices.append([_type.encode("utf8"),
+                                       _subname.encode("utf8"),
+                                       _address.encode("utf8"),
+                                       _postal_code.encode("utf8"),
+                                       _town.encode("utf8"),
+                                       _province.encode("utf8"),
+                                       _country.encode("utf8"),
+                                       _phone_list,
+                                       _fax_list,
+                                       _contact_person.encode("utf8")])
             _local_offices_index = _local_offices_index + 10
         # _____cif web email_____
         _c_w_e = self.delete_control_space(field_list[4])
@@ -1590,7 +1640,8 @@
                 _ti_description = _field_2_list[_ti_index+1]
                 _ti_unit = _field_2_list[_ti_index+2]
                 if _ti_code != "":
-                    self.__budget.addTecInfo(_ti_code.encode("utf8"), _ti_description.encode("utf8"),
+                    self.__budget.addTecInfo(_ti_code.encode("utf8"), 
+                                             _ti_description.encode("utf8"),
                                              _ti_unit.encode("utf8"))
                 _ti_index = _ti_index + 3
         else:
@@ -1607,7 +1658,8 @@
                 if _ti_code != u"" and _ti_value != u"":
                     _ti_dict[_ti_code.encode("utf8")] = _ti_value.encode("utf8")
                 _ti_index = _ti_index + 2
-            self.__budget.setTecnicalInformation(_record_code.encode("utf8"), _ti_dict)
+            self.__budget.setTecnicalInformation(_record_code.encode("utf8"),
+                                                 _ti_dict)
         self.__statistics.valid = self.__statistics.valid +1
 
     def _parseF(self, field_list):
@@ -1618,8 +1670,6 @@
             1- Record code
             2- { Type \ { Filenames; } \ [Description] }
         """
-        print("parseF")
-        print(field_list)
         # _____Number of fields_____
         # The record must have at least 3 fields
         if len(field_list) < 3:
@@ -1647,7 +1697,6 @@
             _files_list.extend[u""]*(3 - len(_files_list)%3)
         _file_index = 0
         _tested_files_list = []
-        print(_files_list)
         while _file_index < len(_files_list)-3:
             _type = _files_list[_file_index].replace(u" ",u"")
             ## _types = {
@@ -1665,16 +1714,13 @@
             ##                  "etc. de empresa"),
             ##          "11": _("certificado/s de empresa"),
             ##          "12": _("obras realizadas")}
-            _types = [u"0", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"10",
-                      u"11", u"12"]
+            _types = [u"0", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8",
+                      u"9", u"10", u"11", u"12"]
             if not _type in _types:
                 _type = u"0"
             _filenames = _files_list[_file_index + 1]
             _description = _files_list[_file_index + 2]
             _file_index += 3
-            print(u"type: " + _type)
-            print(u"filenames: " + _filenames)
-            print(u"_description: " + _description)
             if len(_filenames) and _filenames[-1] == u";":
                 _files = _files[:-1]
             _filenames_list = _filenames.split(u";")
@@ -1702,23 +1748,28 @@
                     _file_path_lu = os.path.join(_path, _lu)
                     _file_path_ll = os.path.join(_path, _ll)
                     if os.path.exists(_file_path_uu):
-                        _tested_files_list.append([_file_path_uu, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_uu,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     elif os.path.exists(_grafic_file_path_ul):
-                        _tested_files_list.append([_file_path_ul, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_ul,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     elif os.path.exists(_grafic_file_path_lu):
-                        _tested_files_list.append([_file_path_lu, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_lu,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     elif os.path.exists(_grafic_file_path_ll):
-                        _tested_files_list.append([_file_path_ll, _type.encode("utf8"),
+                        _tested_files_list.append([_file_path_ll,
+                                                   _type.encode("utf8"),
                                                    _description.encode("utf8")])
                     else:
                         print(utils.mapping(_("The file $1 do not exist"),
-                            (_file_path,)) )
+                            (_file_path,)).encode("utf-8") )
         if len(_tested_files_list) > 0:
             for _file in _tested_files_list:
-                self.__budget.addFile(_record_code.encode("utf8"), _file[0], _file[1], _file[2])
+                self.__budget.addFile(_record_code.encode("utf8"), _file[0],
+                                      _file[1], _file[2])
         self.__statistics.valid = self.__statistics.valid +1
 
     def _parseB(self, field_list):
@@ -1820,14 +1871,14 @@
                     field_list = field_list[0:3]
                 field_list = field_list[1:]
                 if len(field_list) != 2:
-                    print(_("PyArq hates parametric DLLs") )
+                    print(_("PyArq hates parametric DLLs").encode("utf-8") )
                     return
         else:
             return
         # _____Description_____
         _description = field_list[1]
         if _description == u"":
-            print(_("PyArq hates parametric DLLs") )
+            print(_("PyArq hates parametric DLLs").encode("utf-8") )
             return
         # Adding last end of line
         _description = _description + u"\r\n"
@@ -1885,7 +1936,8 @@
                         if index1 % 2 != 0:
                             _parcial_line = u'"' + _list[index1]
                         else:
-                            _parcial_line =  u'"' + _list[index1].replace(u" ",u"")
+                            _parcial_line = _list[index1].replace(u" ",u"")
+                            _parcial_line = u'"' + _parcial_line
                         _final_line = _final_line + _parcial_line
                     _line = _final_line[1:]
                     _lines[index] = _line
@@ -1911,7 +1963,9 @@
                             _pass_line = _pass_line + 1
                         _search = self.__pattern["var"].search(_line)
                         if _search is not None:
-                            _var = _search.groups()[0] + u" = " + _search.groups()[1]
+                            _var0 = _search.groups()[0]
+                            _var1 = _search.groups()[1]
+                            _var = _var0 + u" = " + _var1
                             #print("__VAR__" + str(_var) )
                             pass
                         else:
@@ -1922,27 +1976,43 @@
                         #_patern = "(^[^:]*):(.*)$"
                         _search = self.__pattern["descomposition"].search(_line)
                         if _search is not None:
-                            _var = _search.groups()[0] + u":" + _search.groups()[1]
+                            _var0 = _search.groups()[0]
+                            _var1 = _search.groups()[1]
+                            _var = _var0  + u":" + _var1
                             #print( "__Descomposición__" + str(_var) )
                             pass
                         else:
                             #print("no __Descomposición__", _line )
                             pass
                     else:
-                        print("Parametric: code: " + _family_code.encode("utf8") )
-                        print("******* Desconocido *** : " + _line )
-                        if index-10 > 0: print("-11 : " + _lines[index-11].encode("utf8") )
-                        if index-10 > 0: print("-10 : " + _lines[index-10].encode("utf8") )
-                        if index-9 > 0: print("-9 : " + _lines[index-9].encode("utf8") )
-                        if index-8 > 0: print("-8 : " + _lines[index-8].encode("utf8") )
-                        if index-7 > 0: print("-7 : " + _lines[index-7].encode("utf8") )
-                        if index-6 > 0: print("-6 : " + _lines[index-6].encode("utf8") )
-                        if index-5 > 0: print("-5 : " + _lines[index-5].encode("utf8") )
-                        if index-4 > 0: print("-4 : " + _lines[index-4].encode("utf8") )
-                        if index-3 > 0: print("-3 : " + _lines[index-3].encode("utf8") )
-                        if index-2 > 0: print("-2 : " + _lines[index-2].encode("utf8") )
-                        if index-1 > 0: print("-1 : " + _lines[index-1].encode("utf8") )
-                        print("-0 :" + _lines[index-0] )
+                        _str = "Parametric: code: " + \
+                               _family_code.encode("utf8")
+                        print(_str.encode("utf-8") )
+                        _str = "******* Desconocido *** : " + _line
+                        print(_str.encode("utf-8") )
+                        if index-10 > 0:
+                            print("-11 : " + _lines[index-11].encode("utf8") )
+                        if index-10 > 0:
+                            print("-10 : " + _lines[index-10].encode("utf8") )
+                        if index-9 > 0:
+                            print("-9 : " + _lines[index-9].encode("utf8") )
+                        if index-8 > 0:
+                            print("-8 : " + _lines[index-8].encode("utf8") )
+                        if index-7 > 0:
+                            print("-7 : " + _lines[index-7].encode("utf8") )
+                        if index-6 > 0:
+                            print("-6 : " + _lines[index-6].encode("utf8") )
+                        if index-5 > 0:
+                            print("-5 : " + _lines[index-5].encode("utf8") )
+                        if index-4 > 0:
+                            print("-4 : " + _lines[index-4].encode("utf8") )
+                        if index-3 > 0:
+                            print("-3 : " + _lines[index-3].encode("utf8") )
+                        if index-2 > 0:
+                            print("-2 : " + _lines[index-2].encode("utf8") )
+                        if index-1 > 0:
+                            print("-1 : " + _lines[index-1].encode("utf8") )
+                        print(("-0 :" + _lines[index-0]).encode("utf-8") )
                         pass
                 else:
                     _parameter_list = _line.split(u"\\")[1:-1]
@@ -1951,16 +2021,19 @@
                            _parameter_list[0] == u"COMENTARIO":
                             #print( "__COMENTARIO__" + _parameter_list[1])
                             self.__budget.setParametricSelectComment(
-                                _family_code.encode("utf8"), _parameter_list[1].encode("utf8"))
+                                _family_code.encode("utf8"),
+                                _parameter_list[1].encode("utf8"))
                         elif _parameter_list[0] == u"R" or \
                            _parameter_list[0] == u"RESUMEN":
                             #print( "__RESUMEN__" + _parameter_list[1])
-                            self.__budget.setParametricSummary(_family_code.encode("utf8"),
+                            self.__budget.setParametricSummary(
+                                _family_code.encode("utf8"),
                                 _parameter_list[1].encode("utf8"))
                         elif _parameter_list[0] == u"T" or \
                            _parameter_list[0] == u"TEXTO":
                             #print( "__TEXTO__" + _parameter_list[1])
-                            self.__budget.setParametricText(_family_code.encode("utf8"),
+                            self.__budget.setParametricText(
+                                _family_code.encode("utf8"),
                                 _parameter_list[1].encode("utf8"))
                         elif _parameter_list[0] == u"P" or \
                            _parameter_list[0] == u"PLIEGO":
@@ -2017,16 +2090,18 @@
         try:
             _file =  open(self.__filename, 'r')
         except IOError:
-            print( utils.mapping("IOError: $1", (self.__filename,)) )
+            _str = utils.mapping("IOError: $1", (self.__filename,))
+            print( _str.encode("utf-8") )
             return None
         _filesize = float(os.path.getsize(self.__filename))
         if _filesize == 0.0:
-            print( utils.mapping("Empty File: $1", (self.__filename,)) )
+            _str = utils.mapping("Empty File: $1", (self.__filename,))
+            print( _str.encode("utf-8") )
             # Todo: Create empty budget
             return None
         self.__budget.filename = self.__filename
         interface.readFile_send_message(utils.mapping(_("Loading file $1"),
-                         (self.__filename,)))
+                         (self.__filename,)).encode("utf-8"))
         interface.readFile_progress(_file.tell() / _filesize)
         _buffer = _file.read(1000)
         interface.updateGui()
@@ -2047,21 +2122,21 @@
                     self.__character_set = self.__character_sets_dict[_version]
                     interface.readFile_send_message(utils.mapping(
                         _("FIEBDC character encoding: $1"),
-                          (self.__character_set,)))
+                          (self.__character_set,)).encode("utf8"))
                 else:
                     interface.readFile_send_message(utils.mapping(
                         _("This Character encoding do not exist in "\
                           "FIEBDC3! Default Character encoding: $1"),
-                          (self.__character_set,)))
+                          (self.__character_set,)).encode("utf-8"))
             else:
                 interface.readFile_send_message(utils.mapping(_(
                          "This V record dot have a character encoding! "\
                          "Default character encoding: $1"),
-                         (self.__character_set,)))
+                         (self.__character_set,)).encode("utf-8"))
         else:
             interface.readFile_send_message(utils.mapping(_(
                   "Not 'V' record in File! Default character encoding: "\
-                  "$1"), (self.__character_set,)))
+                  "$1"), (self.__character_set,)).encode("utf-8"))
         _buffer = unicode(_buffer, self.__character_set)
         interface.updateGui()
         # Any INFORMATION between the beginning of the file and the
@@ -2107,11 +2182,13 @@
         else:
             self.__statistics.time = time.time()-_time
             if self.__statistics.O > 0:
-                interface.readFile_send_message(
-                    utils.mapping(_("$1 unsuported record type O: "\
-                    "Comercial Relationship"), (str(self.__statistics.O,))))
+                _str = utils.mapping(
+                    _("$1 unsuported record type O: Comercial Relationship"),
+                    (str(self.__statistics.O,)))
+                interface.readFile_send_message(_str.encode("utf-8"))
             if self.__statistics.valid == 0:
-                interface.readFile_send_message(_("This file is not a valid FIBDC3 file"))
+                _str = _("This file is not a valid FIBDC3 file")
+                interface.readFile_send_message(_str.encode("utf-8"))
                 return None
             interface.readFile_end()
             self._testBudget(self.__budget, interface)
@@ -2124,7 +2201,7 @@
         Test and repair budget object after read it from bc3 file
         """
         # TODO: more to do here
-        print( _("Testing budget ...") )
+        print( _("Testing budget ...").encode("utf-8") )
         # Add price to records without price
         _iter = budget.iter()
         _titlelist = budget.getTitleList()[1]
@@ -2143,7 +2220,7 @@
                     _price = [0.0, _root.getDate(_len_prices + _index)]
                     budget.addPriceToRecord(_price,_record)
             interface.updateGui()
-        print( _("End Test") )
+        print(_("End Test").encode("utf-8"))
 
     def delete_control_space(self, text):
         text = self.delete_control(text)
@@ -2201,7 +2278,7 @@
         
         print( message )
         """
-        print( message )
+        print( message.encode("utf-8") )
 
     def readFile_progress(self, percent):
         """progress(percent)
@@ -2218,8 +2295,8 @@
         The readFile method end successfully
         """
         self.endSuccessfully == True
-        print(self.__statistics)
-        print("progreso = " + str(self.__progress))
+        print(self.__statistics.encode("utf-8"))
+        print(("progreso = " + str(self.__progress)).encode("utf-8"))
 
     def readFile_cancel(self):
         """readFile_cancel()
@@ -2227,8 +2304,8 @@
         The readFile method is canceled
         """
         self.endSuccessfully == False
-        print( _("Process terminated") )
-        print("progreso = " + str(self.__progress))
+        print( _("Process terminated").encode("utf-8") )
+        print(("progreso = " + str(self.__progress)).encode("utf-8"))
 
     def updateGui(self):
         """updateGui(self)
@@ -2305,11 +2382,10 @@
             self.time = 0.0
 
     def __str__(self):
-        return self.str().encode("utf8")
+        return self.str()
 
     def str(self):
-
-        return utils.mapping(_("Time to load: $1 seconds"),
+        _str = utils.mapping(_("Time to load: $1 seconds"),
                 (("%.2f" %(self.time)),)) + "\n" + \
                utils.mapping(_("Records/Valid Records: $1/$2"), 
                (str(self.records), str(self.valid))) + "\n" +\
@@ -2334,4 +2410,5 @@
                "F: %s\n" %(self.F,) + \
                "A: %s\n" %(self.A,) + \
                "?: %s\n" %(self.unknow,)
+        return _str.encode("utf8")
 
--- a/Generic/globalVars.py	Fri May 03 11:11:00 2019 +0200
+++ b/Generic/globalVars.py	Mon May 20 13:18:33 2019 +0200
@@ -27,7 +27,7 @@
 
 name = "pyArq Presupuestos"
 version = "v0.0.0"
-changeset = "c24"
+changeset = "c25"
 baseversion = 0
 
 # path: Paths where find the program files needed
--- a/Gtk/gui.py	Fri May 03 11:11:00 2019 +0200
+++ b/Gtk/gui.py	Mon May 20 13:18:33 2019 +0200
@@ -77,7 +77,8 @@
 _pixbufIcons = []
 for _icon in _icons:
     if os.path.exists(globalVars.getAppPath(_icon)):
-        _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(globalVars.getAppPath(_icon))
+        _icon_file = globalVars.getAppPath(_icon)
+        _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(_icon_file)
         _pixbufIcons.append(_pixbufIcon)
     else:
         print(utils.mapping(_("The icon file does not exist. '$1'"),
@@ -104,7 +105,8 @@
     Constructor:
         App()
     Ancestry:
-    +-- Gtk.Application https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html
+    +-- Gtk.Application 
+        https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html
       +-- App
     Atributes:
     Methods:
@@ -141,7 +143,7 @@
         Shows new appplication windows.
         """
         _mainWindow = MainWindow(self, self.filesToOpen )
-        _mainWindow.window.present_with_time(GLib.get_monotonic_time() / 1000)
+        _mainWindow.window.present_with_time(Gtk.get_current_event_time())
 
     def do_startup(self):
         """do_startup()
@@ -192,7 +194,8 @@
         if win_menu:
             _win_menu = Gio.Menu()
             _win_submenu_file = Gio.Menu.new()
-            _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"), "win.ImportFiebdc")
+            _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"),
+                                                "win.ImportFiebdc")
             _import_fiebdc.set_icon(Gio.Icon.new_for_string("document-open"))
             _win_submenu_file.append_item(_import_fiebdc)
         
@@ -223,7 +226,7 @@
         Shows new appplication windows.
         """
         _mainWindow = MainWindow(self, [])
-        _mainWindow.window.present_with_time(GLib.get_monotonic_time() / 1000)
+        _mainWindow.window.present_with_time(Gtk.get_current_event_time())
 
     def _on_about(self, action, param):
         """_on_about(action, param)
@@ -240,7 +243,7 @@
         _aboutDialog.set_license_type(Gtk.License(3))
         _aboutDialog.set_comments(base.comments)
         _aboutDialog.connect("response", self._on_close_aboutdialog)
-        _aboutDialog.present_with_time(GLib.get_monotonic_time() / 1000)
+        _aboutDialog.present_with_time(Gtk.get_current_event_time())
 
     def _on_close_aboutdialog(self, action, parameter):
         """on_close_aboutdialog(action, param)
@@ -388,7 +391,8 @@
         # Import Fiebdc
         _gtk_image = Gtk.Image.new_from_icon_name("document-open",1)
         _gtk_image.show()
-        _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image , _("Import Fiebdc"))
+        _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image, 
+                                                  _("Import Fiebdc"))
         _ImportFiebdc_button.set_tooltip_text(_("Import Fiebdc"))
         _ImportFiebdc_button.set_is_important(False)        # label not shown
         _toolbar.insert(_ImportFiebdc_button, -1)
@@ -419,7 +423,8 @@
         # Go Forward
         _gtk_image = Gtk.Image.new_from_icon_name("go-next",1)
         _gtk_image.show()
-        self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image ,_("Forward"))
+        self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image,
+                                                         _("Forward"))
         self.__goForward_button.set_tooltip_text(_("Forward"))
         self.__goForward_button.set_is_important(False)        # label not shown
         _toolbar.insert(self.__goForward_button, -1)
@@ -538,7 +543,7 @@
         self.__GoToRoot_action.set_enabled(False)
         self.__navigation_is_enabled = False
 
-    def _switch_page(self, notebook, page, page_num,):
+    def _switch_page(self, notebook, page, page_num):
         """_switch_page(notebook, page, page_num)
          
         Method connected to the "switch-page" signal of the notebook widget
@@ -559,7 +564,9 @@
         elif isinstance(_page, Page):
             if not self.__navigation_is_enabled:
                 self.__navigation_is_enabled = True
-                self._checkButtonsSensitive(page_num)
+            self.__goBack_button.set_menu(_page.back_menu)
+            self.__goForward_button.set_menu(_page.forward_menu)
+            self._checkButtonsSensitive(page_num)
 
     def _main(self):
         """main()
@@ -957,7 +964,8 @@
         self.closeTabButton.set_is_important(False)        # label not shown
         self.__title.add(self.closeTabButton)
         self.closeTabButton.hide()
-        self.__closeTabId = self.closeTabButton.connect("clicked", self.on_close_button)
+        self.__closeTabId = self.closeTabButton.connect("clicked",
+                                                        self.on_close_button)
         # Statusbar
         self.__statusbar = Gtk.Statusbar()
         self.__statuscontext = self.__statusbar.get_context_id("Statusbar")
@@ -1272,8 +1280,8 @@
         self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical
         self.__widget.props.margin = 5
         #TODO: __panes_list should come from gui config file...
-        # "DecompositionList" "RecordDescription" "Measure" "Sheet of Conditions"
-        # "FileView" "CompanyView"
+        # "DecompositionList" "RecordDescription" "Measure"
+        # "Sheet of Conditions" "FileView" "CompanyView"
         self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure",
             "RecordDescription" ]]
         self.__main_item = None
@@ -1330,7 +1338,8 @@
         """sendMessageTo(pane, message, pane_path, arg=None)
         pane: the receiver pane
         message: string message
-        pane_path: tuple that represents the pane pane_path which emits the message
+        pane_path: tuple that represents the pane pane_path which emits
+                   the message
         arg: arguments for the message
         
         Sends a message to a pane
@@ -1470,17 +1479,18 @@
             _item = View( "RecordDescription", self.__budget,weakref.ref(self),
                 pane_path, self.__active_path_record, True)
         elif list_paned[0] == "Measure":
-            _item = View( "Measure", self.__budget, weakref.ref(self), pane_path,
-                self.__active_path_record, True)
+            _item = View("Measure", self.__budget, weakref.ref(self),
+                         pane_path, self.__active_path_record, True)
         elif list_paned[0] == "Sheet of Conditions":
-            _item  = View("Sheet of Conditions", self.__budget, weakref.ref(self), pane_path,
+            _item  = View("Sheet of Conditions",
+                          self.__budget, weakref.ref(self), pane_path,
                 self.__active_path_record)
         elif list_paned[0] == "FileView":
-            _item  = View("FileView", self.__budget, weakref.ref(self), pane_path,
-                self.__active_path_record)
+            _item  = View("FileView", self.__budget, weakref.ref(self),
+                          pane_path, self.__active_path_record)
         elif list_paned[0] == "CompanyView":
-            _item  = View("CompanyView", self.__budget, weakref.ref(self), pane_path,
-                self.__active_path_record)
+            _item  = View("CompanyView", self.__budget, weakref.ref(self),
+                          pane_path, self.__active_path_record)
         else:
             _item = None
             raise ValueError( utils.mapping(_("Incorrect item $1"),
@@ -1926,7 +1936,7 @@
         _hbox.add(_combobox)
         _invisible = Gtk.Grid()
         _invisible.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
-        _invisible.set_property("hexpand", True) # widget expand horizontal space
+        _invisible.set_property("hexpand", True) # expand horizontal space
         _invisible.show()
         _hbox.add(_invisible)
         # TODO : Set thist with config
@@ -1964,10 +1974,12 @@
         self.__connected_button = Gtk.ToolButton()
         _icon_connected = Gtk.Image()
         if self.__connected:
-            _icon_connected.set_from_file(globalVars.getAppPath("CONNECTED-ICON"))
+            _icon_path = globalVars.getAppPath("CONNECTED-ICON")
+            _icon_connected.set_from_file(_icon_path)
             self.__connected_button.set_tooltip_text(_("Disconnect view"))
         else:
-            _icon_connected.set_from_file(globalVars.getAppPath("DISCONNECTED-ICON"))
+            _icon_path = globalVars.getAppPath("DISCONNECTED-ICON")
+            _icon_connected.set_from_file(_icon_path)
             self.__connected_button.set_tooltip_text(_("Connect view"))
         _icon_connected.show()
         self.__connected_button.set_icon_widget(_icon_connected)
@@ -2082,7 +2094,8 @@
         _menu_view.append(_item_close)
         _item_close.connect("activate",self._closeItem_from_menu)
         _item_close.show()
-        _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1), Gtk.get_current_event())
+        _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1),
+                                   Gtk.get_current_event())
 
     def _split_view(self, widget, orientation):
         """_menu_view(orientation)
@@ -2582,7 +2595,7 @@
         path_record: the record path that must be showed
         
         self.__budget: budget showed ("base.Budget" object)
-        self.__wr_page: weak reference from Page instance which creates this class
+        self.__wr_page: weak reference from Page instance which creates self
         self.__pane_path: tuple that represents the path of the List in the Page
         self.__liststore: list model which store the list data
             (Gtk.ListStore object)
@@ -2645,7 +2658,8 @@
         self.__treeview.show()
         # Scrolled_window
         self.__scrolled_window = Gtk.ScrolledWindow()
-        self.__scrolled_window.set_property("expand", True) # widget expand all space
+        # widget expand all space
+        self.__scrolled_window.set_property("expand", True) 
         self.__scrolled_window.set_policy(Gtk.PolicyType(1),
                                         Gtk.PolicyType(1)) # 1 Automatic
         self.__scrolled_window.add(self.__treeview)
@@ -2818,8 +2832,10 @@
         """
         return False
 
-    def _controlSelection(self, selection, model, path, path_currently_selected, *data):
-        """_controlSelection(selection)
+    def _controlSelection(self, selection, model, path,
+                          path_currently_selected, *data):
+        """_controlSelection(selection, model, path,
+                             path_currently_selected, *data)
         
         selection: treeselection
         
@@ -2889,10 +2905,13 @@
             _parent_code = self.budget.getCode(self.__active_path_record[:-1])
             _parent_record = self.__budget.getRecord(_parent_code)
             _amount = _budget.getStrAmount(self.__active_path_record)
-        self.__code_column.set_title(_("Code") + chr(10) + "[" + _code.decode("utf8") + "]")
-        self.__unit_column.set_title(_("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]")
-        self.__description_column.set_title(
-           _("Description") + chr(10) + "[" + _description.decode("utf8") + "]")
+        _str = _("Code") + chr(10) + "[" + _code.decode("utf8") + "]"
+        self.__code_column.set_title(_str)
+        _str = _("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]"
+        self.__unit_column.set_title(_str)
+        _str = _("Description") + chr(10) + "[" + \
+               _description.decode("utf8") + "]"
+        self.__description_column.set_title(_str)
         self.__measure_column.set_title(
             _("Measure") + chr(10) + "[" + _stryield + "]")
         self.__price_column.set_title(
@@ -3272,7 +3291,8 @@
         self.__treeview.show()
         # Scrolled_window
         self.__scrolled_window = Gtk.ScrolledWindow()
-        self.__scrolled_window.set_property("expand", True) # widget expand all space
+        # widget expand all space
+        self.__scrolled_window.set_property("expand", True) 
         self.__scrolled_window.set_policy(Gtk.PolicyType(1),
                                           Gtk.PolicyType(1)) # 1 Automatic
         self.__scrolled_window.add(self.__treeview)
@@ -3451,8 +3471,10 @@
         """
         return False
 
-    def _controlSelection(self, selection, model, path, path_currently_selected, *data):
-        """_controlSelection(selection)
+    def _controlSelection(self, selection, model, path,
+                          path_currently_selected, *data):
+        """_controlSelection(selection, model, path,
+                             path_currently_selected, *data)
         
         selection: treeselection
         
@@ -3797,7 +3819,7 @@
         path_record: the path of the active record
         
         self.__budget: the budget (base.obra object)
-        self.__wr_page: weak reference from Page instance which creates this class
+        self.__wr_page: weak reference from Page instance which creates self
         self.__pane_path: the path position of the description in the page
         self.__active_path_recordthe path of the active record
 
@@ -3822,7 +3844,7 @@
         _scrollwindow.set_property("expand", True) # widget expand all space
         _scrollwindow.set_policy(Gtk.PolicyType(1),
                                         Gtk.PolicyType(1)) # 1 Automatic
-        _scrollwindow.set_shadow_type(1) # NONE 0, IN 1, OUT 2, ETCHED_IN 3,ETCHED_OUT 4
+        _scrollwindow.set_shadow_type(1) # IN 1
         _textview = Gtk.TextView()
         _textview.set_wrap_mode(2) # 2 Word
         _textview.set_hexpand(True)
@@ -3981,7 +4003,7 @@
         path_record: the path of the active record
         
         self.__budget: the budget (base.obra object)
-        self.__wr_page: weak reference from Page instance which creates this class
+        self.__wr_page: weak reference from Page instance which creates self
         self.__pane_path: the path position of the description in the page
         self.__active_path_record: the path of the active record
         self.__label: The Gtk.label with the title of the pane
@@ -4038,7 +4060,8 @@
         _field_scrollwindow = Gtk.ScrolledWindow()
         _field_scrollwindow.set_policy(Gtk.PolicyType(1),
                                         Gtk.PolicyType(1)) # 1 Automatic
-        _field_scrollwindow.set_property("hexpand", True) # widget expand all space
+        # widget expand all space
+        _field_scrollwindow.set_property("hexpand", True)
         _field_scrollwindow.add(self.__field_treeview)
         _field_scrollwindow.set_size_request(-1, 80)
         _field_scrollwindow.show()
@@ -4061,7 +4084,8 @@
         _section_scrollwindow = Gtk.ScrolledWindow()
         _section_scrollwindow.set_policy(Gtk.PolicyType(1),
                                         Gtk.PolicyType(1)) # 1 Automatic
-        _section_scrollwindow.set_property("hexpand", True) # widget expand all space
+        # widget expand all space
+        _section_scrollwindow.set_property("hexpand", True)
         _section_scrollwindow.set_size_request(-1, 90)
         _section_scrollwindow.add(self.__section_treeview)
         _section_scrollwindow.show()
@@ -4129,7 +4153,8 @@
             _section_list = _sheet.getSections(self.__field_selection)
             for _section in _section_list:
                 _section_text = self.__budget.getSheetSection(_section)
-                _iter = self.__section_liststore.append([_section, _section_text])
+                _iter = self.__section_liststore.append([_section,
+                                                         _section_text])
             _treeselection = self.__section_treeview.get_selection()
             _treeselection.select_path(0)
 
@@ -4192,7 +4217,8 @@
         section in showed
         """
         _treeiter = self.__section_liststore.get_iter(path)
-        self.__section_selection = self.__section_liststore.get_value(_treeiter, 0)
+        self.__section_selection = self.__section_liststore.get_value(_treeiter,
+                                                                      0)
         self._setText()
         return True
 
@@ -4335,7 +4361,7 @@
         pane_path: the tuple that identifies the pane in the notebook page
         budget: The budget (base.obra object)
         active_path_record: Read.
-        wr_page: Read-Write. weak reference from Page instance which creates this class
+        wr_page: Read-Write. weak reference from Page instance
     Methods:
         runMessage
     """
@@ -4349,7 +4375,7 @@
         path_record: the path of the active record
         
         self.__budget: the budget (base.obra object)
-        self.__wr_page: weak reference from Page instance which creates this class
+        self.__wr_page: weak reference from Page instance which creates self
         self.__pane_path: the path position of the description in the page
         self.__active_path_record: the path of the active record
         self.__active_code: the code of the active record
@@ -4401,8 +4427,8 @@
                 _event_box = Gtk.LinkButton()
                 _file_icon = Gtk.Image()
                 # "image", "wmf", "dxf", "pdf" , "video",
-                # "office-document", "office-presentation", "office-spreadsheet",
-                # "html", "rtf", "txt", ""
+                # "office-document", "office-presentation",
+                # "office-spreadsheet", "html", "rtf", "txt", ""
                 # icon
                 if _filetype in ["image", "wmf"]:
                     try:
@@ -4641,7 +4667,7 @@
         active_path_record: Read. Path of the active record in the budget
         widget: Read. Window that contains the main widget, a Gtk.Paned
         pane_path: Read-Write. Pane page identifier
-        wr_page: Read-Write. weak reference from Page instance which creates this class
+        wr_page: Read-Write. weak reference from Page instance
         budget: Read. Budget to show, base.budget instance.
     Methods:
         runMessage
@@ -4657,7 +4683,7 @@
         
         self.__selection: "company" or "office" selected treeview
         self.__budget: budget: budget showed ("base.Budget" object)
-        self.__wr_page: weak reference from Page instance which creates this class
+        self.__wr_page: weak reference from Page instance
         self.__pane_path: tuple that represents the path of the List in the Page
         self.__active_path_record: path of the active record in the budget
         self.__widget: main widget, a Gtk.Paned
@@ -4791,8 +4817,10 @@
                 _values = [_office.officeType, _office.subname]
                 self.__treestore.append(_treeiter, _values)
 
-    def _controlSelection(self, selection, model, path, path_currently_selected, *data):
-        """_controlSelection(selection, model, path, path_currently_selected, *data)
+    def _controlSelection(self, selection, model, path,
+                          path_currently_selected, *data):
+        """_controlSelection(selection, model, path,
+                             path_currently_selected, *data)
         
         selection: selection
         
@@ -5083,7 +5111,7 @@
         _treeselection.set_select_function(self._controlSelection)
         # labels
         _frame = Gtk.Frame()
-        _frame.set_shadow_type(2) # NONE 0, IN 1, OUT 2, ETCHED_IN 3,ETCHED_OUT 4
+        _frame.set_shadow_type(2) # OUT 2
         _vbox2 = Gtk.Grid()
         _vbox2.set_orientation(Gtk.Orientation(1)) # 1 Vertical
         _frame.add(_vbox2)