Mercurial > pyarq-presupuestos
comparison Gtk/gui.py @ 26:16f91684686b default tip
Upgrade to python 3. Keep python 2/3 compatibility
| author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
|---|---|
| date | Tue, 18 Jun 2019 17:50:23 +0200 |
| parents | 189f8274aecd |
| children |
comparison
equal
deleted
inserted
replaced
| 25:189f8274aecd | 26:16f91684686b |
|---|---|
| 44 | 44 |
| 45 # Modules | 45 # Modules |
| 46 | 46 |
| 47 # python 2/3 compatibility | 47 # python 2/3 compatibility |
| 48 from __future__ import absolute_import, division, print_function, unicode_literals | 48 from __future__ import absolute_import, division, print_function, unicode_literals |
| 49 | 49 from builtins import str as text |
| 50 from six import text_type | |
| 51 | |
| 52 def textinp2(textstring): | |
| 53 """textinp2(textstring) | |
| 54 | |
| 55 python2 decode textstring with utf-8 | |
| 56 python3 raise except and do nothing with textstring | |
| 57 | |
| 58 return textstring | |
| 59 | |
| 60 All output gtk string must be passed by textinp2 | |
| 61 """ | |
| 62 try: | |
| 63 # python2 works, python3 raise except and do nothing with textstring | |
| 64 textstring = text(textstring, "utf-8") | |
| 65 except TypeError: | |
| 66 pass | |
| 67 return textstring | |
| 68 | |
| 50 # Standar Modules | 69 # Standar Modules |
| 51 import sys | 70 import sys |
| 52 import os | 71 import os |
| 53 import time | 72 import time |
| 54 | 73 |
| 79 if os.path.exists(globalVars.getAppPath(_icon)): | 98 if os.path.exists(globalVars.getAppPath(_icon)): |
| 80 _icon_file = globalVars.getAppPath(_icon) | 99 _icon_file = globalVars.getAppPath(_icon) |
| 81 _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(_icon_file) | 100 _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(_icon_file) |
| 82 _pixbufIcons.append(_pixbufIcon) | 101 _pixbufIcons.append(_pixbufIcon) |
| 83 else: | 102 else: |
| 84 print(utils.mapping(_("The icon file does not exist. '$1'"), | 103 _tuni = _("The icon file does not exist. '$1'") |
| 85 (str(globalVars.getAppPath(_icon)),)) ) | 104 _uni = utils.mapping(_tuni, (globalVars.getAppPath(_icon),)) |
| 105 print(_uni ) | |
| 86 if len(_pixbufIcons) > 0: | 106 if len(_pixbufIcons) > 0: |
| 87 Gtk.Window.set_default_icon_list(_pixbufIcons) | 107 Gtk.Window.set_default_icon_list(_pixbufIcons) |
| 88 | 108 |
| 89 else: | 109 else: |
| 90 print(utils.mapping(_("The icon file does not exist. '$1'"), | 110 _tuni = _("The icon file does not exist. '$1'") |
| 91 (str(globalVars.getAppPath("ICON")),)) ) | 111 _uni = utils.mapping(_tuni, (globalVars.getAppPath("ICON"),)) |
| 112 print(_uni ) | |
| 92 | 113 |
| 93 # Autodetect desktop | 114 # Autodetect desktop |
| 94 if globalVars.desktop["autodetect"]: | 115 if globalVars.desktop["autodetect"]: |
| 95 openwith.autodetect_desktop() | 116 openwith.autodetect_desktop() |
| 96 print(utils.mapping(_("pyArq-Presupuestos running on $1"), | 117 _tuni = _("pyArq-Presupuestos running on $1") |
| 97 (globalVars.desktop["desktop"],))) | 118 _uni = utils.mapping(_tuni, (globalVars.desktop["desktop"],)) |
| 119 print(_uni) | |
| 98 | 120 |
| 99 | 121 |
| 100 class App(Gtk.Application): | 122 class App(Gtk.Application): |
| 101 """gui.App: | 123 """gui.App: |
| 102 | 124 |
| 657 page.clear() | 679 page.clear() |
| 658 self.__notebook.remove_page(_page_num) | 680 self.__notebook.remove_page(_page_num) |
| 659 if len(self.__page_list) == 0: | 681 if len(self.__page_list) == 0: |
| 660 self._disable_navigation() | 682 self._disable_navigation() |
| 661 else: | 683 else: |
| 662 raise IndexError( _("The page is not in the page list") ) | 684 _tuni = _("The page is not in the page list") |
| 685 _str = _tuni.encode("utf-8") | |
| 686 raise IndexError(_str) | |
| 663 | 687 |
| 664 def _menuitemGoToRoot(self, action, parameter): | 688 def _menuitemGoToRoot(self, action, parameter): |
| 665 """_menuitemGoToRoot(action, parameter) | 689 """_menuitemGoToRoot(action, parameter) |
| 666 | 690 |
| 667 action: the action where the event is emitted from | 691 action: the action where the event is emitted from |
| 827 | 851 |
| 828 filename: the filename to open | 852 filename: the filename to open |
| 829 If the selected file has a bc3 extension | 853 If the selected file has a bc3 extension |
| 830 _launchProgressWindow is called | 854 _launchProgressWindow is called |
| 831 """ | 855 """ |
| 832 _file = filename | 856 _file = filename # string in python 2, unicode in python 3 |
| 833 if sys.getfilesystemencoding(): | 857 if sys.getfilesystemencoding(): |
| 834 _file = _file.decode(sys.getfilesystemencoding()) | 858 try: |
| 859 # python2 works, python3 raise except and do nothing with _file | |
| 860 _file = text(filename, sys.getfilesystemencoding()) | |
| 861 except TypeError: | |
| 862 pass | |
| 835 self.__file = _file | 863 self.__file = _file |
| 836 _filename = os.path.basename(self.__file) | 864 _filename = os.path.basename(self.__file) |
| 837 _filename_ext = _filename.split(".")[-1] | 865 _filename_ext = _filename.split(".")[-1] |
| 838 if (self.__filetype == "budget" or self.__filetype == "database") and \ | 866 if (self.__filetype == "budget" or self.__filetype == "database") and \ |
| 839 _filename_ext != "bc3" and _filename_ext != "BC3": | 867 _filename_ext != "bc3" and _filename_ext != "BC3": |
| 1006 | 1034 |
| 1007 percent: Percentage executed. | 1035 percent: Percentage executed. |
| 1008 | 1036 |
| 1009 Sets progress | 1037 Sets progress |
| 1010 """ | 1038 """ |
| 1011 _progress = str(int(round(100 * percent,0))) | 1039 _progress = text(int(round(100 * percent,0))) |
| 1012 self.__progress = percent | 1040 self.__progress = percent |
| 1013 | 1041 |
| 1014 def readFile_send_message(self, message): | 1042 def readFile_send_message(self, message): |
| 1015 """readFile_send_message(message) | 1043 """readFile_send_message(message) |
| 1016 | 1044 |
| 1092 if self.__children is None or self.__children.isCanceled() == True: | 1120 if self.__children is None or self.__children.isCanceled() == True: |
| 1093 self.__cancel[0] = True | 1121 self.__cancel[0] = True |
| 1094 return False | 1122 return False |
| 1095 else: | 1123 else: |
| 1096 self.__progress_bar.set_fraction(self.__progress) | 1124 self.__progress_bar.set_fraction(self.__progress) |
| 1097 _text = "%s%%" %str(int(round(100 * self.__progress,0))) | 1125 _text = "%s%%" %text(int(round(100 * self.__progress,0))) |
| 1098 self.__progress_bar.set_text(_text) | 1126 self.__progress_bar.set_text(_text) |
| 1099 return True | 1127 return True |
| 1100 | 1128 |
| 1101 def _updateLabel(self, _time): | 1129 def _updateLabel(self, _time): |
| 1102 """_updateLabel(_time) | 1130 """_updateLabel(_time) |
| 1458 | 1486 |
| 1459 Creates the items and widgets and returns the main item | 1487 Creates the items and widgets and returns the main item |
| 1460 """ | 1488 """ |
| 1461 if pane_path is None: | 1489 if pane_path is None: |
| 1462 pane_path = (0,) | 1490 pane_path = (0,) |
| 1463 if not isinstance(list_paned , list): | 1491 if not isinstance(list_paned, list): |
| 1464 raise ValueError( _("The value must be a list") ) | 1492 _tuni = _("The value must be a list") |
| 1493 _str = _tuni.encode("utf-8") | |
| 1494 raise ValueError(_str) | |
| 1465 if list_paned[0] == "v" or list_paned[0] == "h": | 1495 if list_paned[0] == "v" or list_paned[0] == "h": |
| 1466 if len(list_paned) != 3: | 1496 if len(list_paned) != 3: |
| 1467 raise ValueError( _("Incorrect len") ) | 1497 _tuni = _("Incorrect len") |
| 1468 if not isinstance(list_paned[1],list): | 1498 _str = _tuni.encode("utf-8") |
| 1499 raise ValueError(_str) | |
| 1500 if not isinstance(list_paned[1], list): | |
| 1469 list_paned[1] = [list_paned[1]] | 1501 list_paned[1] = [list_paned[1]] |
| 1470 if not isinstance(list_paned[2],list): | 1502 if not isinstance(list_paned[2], list): |
| 1471 list_paned[2] = [list_paned[2]] | 1503 list_paned[2] = [list_paned[2]] |
| 1472 _item1 = self._itemsFactory(list_paned[1],pane_path + (0,)) | 1504 _item1 = self._itemsFactory(list_paned[1], pane_path + (0,)) |
| 1473 _item2 = self._itemsFactory(list_paned[2],pane_path + (1,)) | 1505 _item2 = self._itemsFactory(list_paned[2], pane_path + (1,)) |
| 1474 _item = Paned(list_paned[0], pane_path, _item1, _item2) | 1506 _item = Paned(list_paned[0], pane_path, _item1, _item2) |
| 1475 elif list_paned[0] == "DecompositionList": | 1507 elif list_paned[0] == "DecompositionList": |
| 1476 _item = View( "DecompositionList", self.__budget, | 1508 _item = View("DecompositionList", self.__budget, |
| 1477 weakref.ref(self), pane_path, self.__active_path_record, True) | 1509 weakref.ref(self), pane_path, self.__active_path_record, True) |
| 1478 elif list_paned[0] == "RecordDescription": | 1510 elif list_paned[0] == "RecordDescription": |
| 1479 _item = View( "RecordDescription", self.__budget,weakref.ref(self), | 1511 _item = View("RecordDescription", self.__budget,weakref.ref(self), |
| 1480 pane_path, self.__active_path_record, True) | 1512 pane_path, self.__active_path_record, True) |
| 1481 elif list_paned[0] == "Measure": | 1513 elif list_paned[0] == "Measure": |
| 1482 _item = View("Measure", self.__budget, weakref.ref(self), | 1514 _item = View("Measure", self.__budget, weakref.ref(self), |
| 1483 pane_path, self.__active_path_record, True) | 1515 pane_path, self.__active_path_record, True) |
| 1484 elif list_paned[0] == "Sheet of Conditions": | 1516 elif list_paned[0] == "Sheet of Conditions": |
| 1485 _item = View("Sheet of Conditions", | 1517 _item = View("Sheet of Conditions", |
| 1486 self.__budget, weakref.ref(self), pane_path, | 1518 self.__budget, weakref.ref(self), pane_path, |
| 1487 self.__active_path_record) | 1519 self.__active_path_record) |
| 1488 elif list_paned[0] == "FileView": | 1520 elif list_paned[0] == "FileView": |
| 1489 _item = View("FileView", self.__budget, weakref.ref(self), | 1521 _item = View("FileView", self.__budget, weakref.ref(self), |
| 1490 pane_path, self.__active_path_record) | 1522 pane_path, self.__active_path_record) |
| 1491 elif list_paned[0] == "CompanyView": | 1523 elif list_paned[0] == "CompanyView": |
| 1492 _item = View("CompanyView", self.__budget, weakref.ref(self), | 1524 _item = View("CompanyView", self.__budget, weakref.ref(self), |
| 1493 pane_path, self.__active_path_record) | 1525 pane_path, self.__active_path_record) |
| 1494 else: | 1526 else: |
| 1495 _item = None | 1527 _item = None |
| 1496 raise ValueError( utils.mapping(_("Incorrect item $1"), | 1528 _tuni = _("Incorrect item $1") |
| 1497 (str(list_paned[0]),)) ) | 1529 _uni = utils.mapping(_tuni, (text(list_paned[0]),)) |
| 1530 _str = _uni.encode("utf-8") | |
| 1531 raise ValueError(_str) | |
| 1498 return _item | 1532 return _item |
| 1499 | 1533 |
| 1500 def _setActivePathRecord(self, path_record): | 1534 def _setActivePathRecord(self, path_record): |
| 1501 """_setActivePathRecord(path_record) | 1535 """_setActivePathRecord(path_record) |
| 1502 | 1536 |
| 1507 if path_record != self.__active_path_record: | 1541 if path_record != self.__active_path_record: |
| 1508 if self.__budget.hasPath(path_record): | 1542 if self.__budget.hasPath(path_record): |
| 1509 self.__active_path_record = path_record | 1543 self.__active_path_record = path_record |
| 1510 self._appendHistory(path_record) | 1544 self._appendHistory(path_record) |
| 1511 else: | 1545 else: |
| 1512 raise ValueError( utils.mapping(_("The budget does not have "\ | 1546 _tuni = _("The budget does not have the path record: $1") |
| 1513 "the path record: $1"), (str(path_record),)) ) | 1547 _uni = utils.mapping(_tuni, (text(path_record),)) |
| 1548 _str = _uni.encode("utf-8") | |
| 1549 raise ValueError(_str) | |
| 1514 | 1550 |
| 1515 def _appendHistory(self, path): | 1551 def _appendHistory(self, path): |
| 1516 """_appendHistory(path)) | 1552 """_appendHistory(path)) |
| 1517 | 1553 |
| 1518 path: the new active path record | 1554 path: the new active path record |
| 1642 Creates and return a menuItem to go to the record | 1678 Creates and return a menuItem to go to the record |
| 1643 """ | 1679 """ |
| 1644 _code = self.budget.getCode(record_path) | 1680 _code = self.budget.getCode(record_path) |
| 1645 _record = self.budget.getRecord(_code) | 1681 _record = self.budget.getRecord(_code) |
| 1646 _summary = _record.summary | 1682 _summary = _record.summary |
| 1647 _text = _code.decode("utf8") + " " + _summary.decode("utf8") | 1683 _text = _code + " " + _summary |
| 1648 if len(_text) > 30: | 1684 if len(_text) > 30: |
| 1649 _text = _text[:27] + "..." | 1685 _text = _text[:27] + "..." |
| 1650 _icon = self._getImage(_record) | 1686 _icon = self._getImage(_record) |
| 1651 _grid = Gtk.Grid() | 1687 _grid = Gtk.Grid() |
| 1652 _grid.set_orientation(Gtk.Orientation(0)) # 0 Horizontal | 1688 _grid.set_orientation(Gtk.Orientation(0)) # 0 Horizontal |
| 1923 active_path_record) | 1959 active_path_record) |
| 1924 _combobox.set_active(5) | 1960 _combobox.set_active(5) |
| 1925 _view_icon = Gtk.Image() | 1961 _view_icon = Gtk.Image() |
| 1926 _view_icon.set_from_file(globalVars.getAppPath("COMPANY-ICON")) | 1962 _view_icon.set_from_file(globalVars.getAppPath("COMPANY-ICON")) |
| 1927 else: | 1963 else: |
| 1928 raise ValueError( _(utils.mapping("Invalid type of View: $1", | 1964 _tuni = _("Invalid type of View: $1") |
| 1929 view_type)) ) | 1965 _uni = utils.mapping(_tuni, view_type) |
| 1966 _str = _uni.encode("utf-8") | |
| 1967 raise ValueError(_str) | |
| 1930 _view_icon.show() | 1968 _view_icon.show() |
| 1931 _combobox.connect("changed", self._change_combo) | 1969 _combobox.connect("changed", self._change_combo) |
| 1932 _combobox.show() | 1970 _combobox.show() |
| 1933 self.__widget.add(_hbox) | 1971 self.__widget.add(_hbox) |
| 1934 self.__widget.add(self.__view.widget) | 1972 self.__widget.add(self.__view.widget) |
| 2256 Creates and shows a new Gtk.Paned | 2294 Creates and shows a new Gtk.Paned |
| 2257 """ | 2295 """ |
| 2258 self.__orientation = orientation | 2296 self.__orientation = orientation |
| 2259 if not isinstance(item1.widget, Gtk.Widget) or \ | 2297 if not isinstance(item1.widget, Gtk.Widget) or \ |
| 2260 not isinstance(item2.widget, Gtk.Widget): | 2298 not isinstance(item2.widget, Gtk.Widget): |
| 2261 raise ValueError( _("The item must be a widget object.") ) | 2299 _tuni = _("The item must be a widget object.") |
| 2300 _str = _tuni.encode("utf-8") | |
| 2301 raise ValueError(_str) | |
| 2262 if orientation == "v": | 2302 if orientation == "v": |
| 2263 self.__widget = Gtk.Paned.new(Gtk.Orientation(1)) | 2303 self.__widget = Gtk.Paned.new(Gtk.Orientation(1)) |
| 2264 self.__widget.set_wide_handle(True) | 2304 self.__widget.set_wide_handle(True) |
| 2265 elif orientation == "h": | 2305 elif orientation == "h": |
| 2266 self.__widget = Gtk.Paned.new(Gtk.Orientation(0)) | 2306 self.__widget = Gtk.Paned.new(Gtk.Orientation(0)) |
| 2267 self.__widget.set_wide_handle(True) | 2307 self.__widget.set_wide_handle(True) |
| 2268 else: | 2308 else: |
| 2269 raise ValueError( _("Invalid orientation.") ) | 2309 _tuni = _("Invalid orientation.") |
| 2310 _str = _tuni.encode("utf-8") | |
| 2311 raise ValueError(_str) | |
| 2270 self.__widget.pack1(item1.widget,True,False) | 2312 self.__widget.pack1(item1.widget,True,False) |
| 2271 self.__widget.pack2(item2.widget,True,False) | 2313 self.__widget.pack2(item2.widget,True,False) |
| 2272 self.__widget.show() | 2314 self.__widget.show() |
| 2273 self.__items = [item1, item2] | 2315 self.__items = [item1, item2] |
| 2274 self.__pane_path = pane_path | 2316 self.__pane_path = pane_path |
| 2636 * Connects the events | 2678 * Connects the events |
| 2637 """ | 2679 """ |
| 2638 # TODO: to group all columns in a dicctionary | 2680 # TODO: to group all columns in a dicctionary |
| 2639 # Budget | 2681 # Budget |
| 2640 if not isinstance(budget, base.Budget): | 2682 if not isinstance(budget, base.Budget): |
| 2641 raise ValueError( _("Argument must be a Budget object") ) | 2683 _tuni = _("Argument must be a Budget object") |
| 2684 _str = _tuni.encode("utf-8") | |
| 2685 raise ValueError(_str) | |
| 2642 self.__budget = budget | 2686 self.__budget = budget |
| 2643 self.__wr_page = wr_page | 2687 self.__wr_page = wr_page |
| 2644 self.__pane_path = pane_path | 2688 self.__pane_path = pane_path |
| 2645 # ListStore | 2689 # ListStore |
| 2646 self.__liststore = Gtk.ListStore(object | 2690 self.__liststore = Gtk.ListStore(object |
| 2903 _amount = _price | 2947 _amount = _price |
| 2904 else: | 2948 else: |
| 2905 _parent_code = self.budget.getCode(self.__active_path_record[:-1]) | 2949 _parent_code = self.budget.getCode(self.__active_path_record[:-1]) |
| 2906 _parent_record = self.__budget.getRecord(_parent_code) | 2950 _parent_record = self.__budget.getRecord(_parent_code) |
| 2907 _amount = _budget.getStrAmount(self.__active_path_record) | 2951 _amount = _budget.getStrAmount(self.__active_path_record) |
| 2908 _str = _("Code") + chr(10) + "[" + _code.decode("utf8") + "]" | 2952 _str = _("Code") + chr(10) + "[" + _code + "]" |
| 2909 self.__code_column.set_title(_str) | 2953 self.__code_column.set_title(_str) |
| 2910 _str = _("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]" | 2954 _str = _("Unit") + chr(10) + "[" + _unit + "]" |
| 2911 self.__unit_column.set_title(_str) | 2955 self.__unit_column.set_title(_str) |
| 2912 _str = _("Description") + chr(10) + "[" + \ | 2956 _str = _("Description") + chr(10) + "[" + \ |
| 2913 _description.decode("utf8") + "]" | 2957 _description + "]" |
| 2914 self.__description_column.set_title(_str) | 2958 self.__description_column.set_title(_str) |
| 2915 self.__measure_column.set_title( | 2959 self.__measure_column.set_title( |
| 2916 _("Measure") + chr(10) + "[" + _stryield + "]") | 2960 _("Measure") + chr(10) + "[" + _stryield + "]") |
| 2917 self.__price_column.set_title( | 2961 self.__price_column.set_title( |
| 2918 _("Price") + chr(10) + "[" + _price + "]") | 2962 _("Price") + chr(10) + "[" + _price + "]") |
| 2919 self.__amount_column.set_title( | 2963 self.__amount_column.set_title( |
| 2920 _("Amount") + chr(10) + "[" + str(_amount) + "]") | 2964 _("Amount") + chr(10) + "[" + text(_amount) + "]") |
| 2921 | 2965 |
| 2922 def _setListstoreValues(self, path_record): | 2966 def _setListstoreValues(self, path_record): |
| 2923 """_setListstoreValues(path_record) | 2967 """_setListstoreValues(path_record) |
| 2924 | 2968 |
| 2925 path_record: Record path in the budget | 2969 path_record: Record path in the budget |
| 2926 Sets the liststore record values from a path record | 2970 Sets the liststore record values from a path record |
| 2927 """ | 2971 """ |
| 2928 self.__liststore.clear() | 2972 self.__liststore.clear() |
| 2929 _budget = self.__budget | 2973 _budget = self.__budget |
| 2930 if not _budget.hasPath(path_record): | 2974 if not _budget.hasPath(path_record): |
| 2931 raise ValueError( _("Invalid path") ) | 2975 _tuni = _("Invalid path") |
| 2976 _str = _tuni.encode("utf-8") | |
| 2977 raise ValueError(_str) | |
| 2932 else: | 2978 else: |
| 2933 _parent_code = _budget.getCode(path_record) | 2979 _parent_code = _budget.getCode(path_record) |
| 2934 for N,_code in enumerate(_budget.getchildren(_parent_code)): | 2980 for N,_code in enumerate(_budget.getchildren(_parent_code)): |
| 2935 _decomposition = _budget.getNDecomposition(_parent_code, N) | 2981 _decomposition = _budget.getNDecomposition(_parent_code, N) |
| 2936 _record = _budget.getRecord(_code) | 2982 _record = _budget.getRecord(_code) |
| 2975 _row_path = tree_model.get_path(iter) | 3021 _row_path = tree_model.get_path(iter) |
| 2976 _global_row_path = self.__active_path_record + (_row_path[0],) | 3022 _global_row_path = self.__active_path_record + (_row_path[0],) |
| 2977 _number = _row_path[-1] | 3023 _number = _row_path[-1] |
| 2978 _record = tree_model[_row_path][0] | 3024 _record = tree_model[_row_path][0] |
| 2979 if column is self.__index_column: | 3025 if column is self.__index_column: |
| 2980 cell_renderer.set_property('text', str(_number + 1)) | 3026 cell_renderer.set_property('text', text(_number + 1)) |
| 2981 self.__index_column.get_cells()[1].set_property( | 3027 self.__index_column.get_cells()[1].set_property( |
| 2982 'cell-background', lcolor[_number % 2]) | 3028 'cell-background', lcolor[_number % 2]) |
| 2983 elif column is self.__code_column: | 3029 elif column is self.__code_column: |
| 2984 # if the record is a chapter | 3030 # if the record is a chapter |
| 2985 if tree_model.get_value(iter, 0).recordType.hierarchy == 1: | 3031 if tree_model.get_value(iter, 0).recordType.hierarchy == 1: |
| 3006 elif column is self.__amount_column: | 3052 elif column is self.__amount_column: |
| 3007 _parent_code = self.budget.getCode(self.__active_path_record) | 3053 _parent_code = self.budget.getCode(self.__active_path_record) |
| 3008 _parent_record = self.__budget.getRecord(_parent_code) | 3054 _parent_record = self.__budget.getRecord(_parent_code) |
| 3009 _amount = self.budget.getStrAmount( | 3055 _amount = self.budget.getStrAmount( |
| 3010 self.__active_path_record + (_number,)) | 3056 self.__active_path_record + (_number,)) |
| 3011 cell_renderer.set_property('text', str(_amount)) | 3057 cell_renderer.set_property('text', text(_amount)) |
| 3012 elif column is self.__type_column: | 3058 elif column is self.__type_column: |
| 3013 _hierarchy = tree_model[_row_path][0].recordType.hierarchy | 3059 _hierarchy = tree_model[_row_path][0].recordType.hierarchy |
| 3014 _type = tree_model[_row_path][0].recordType.type | 3060 _type = tree_model[_row_path][0].recordType.type |
| 3015 _subtype = tree_model[_row_path][0].recordType.subtype | 3061 _subtype = tree_model[_row_path][0].recordType.subtype |
| 3016 if _hierarchy == 1: | 3062 if _hierarchy == 1: |
| 3270 """ | 3316 """ |
| 3271 # Seting init args | 3317 # Seting init args |
| 3272 if path_record is None: | 3318 if path_record is None: |
| 3273 path_record = (0,) | 3319 path_record = (0,) |
| 3274 if not isinstance(budget, base.Budget): | 3320 if not isinstance(budget, base.Budget): |
| 3275 raise ValueError( _("Argument must be a Budget object") ) | 3321 _tuni = _("Argument must be a Budget object") |
| 3322 _str = _tuni.encode("utf-8") | |
| 3323 raise ValueError(_str) | |
| 3276 self.__budget = budget | 3324 self.__budget = budget |
| 3277 self.__wr_page = page | 3325 self.__wr_page = page |
| 3278 self.__pane_path = pane_path | 3326 self.__pane_path = pane_path |
| 3279 if not isinstance(path_record, tuple): | 3327 if not isinstance(path_record, tuple): |
| 3280 print(_("Record path must be a tuple") ) | 3328 print(_("Record path must be a tuple") ) |
| 3525 Sets the headers column values | 3573 Sets the headers column values |
| 3526 """ | 3574 """ |
| 3527 _measure = self.__budget.getMeasure(self.__active_path_record) | 3575 _measure = self.__budget.getMeasure(self.__active_path_record) |
| 3528 _DS = self.__budget.getDecimals("DS") | 3576 _DS = self.__budget.getDecimals("DS") |
| 3529 _total = _measure.measure | 3577 _total = _measure.measure |
| 3530 _total_str = ("%." + str(abs(_DS)) + "f" ) % _total | 3578 _total_str = ("%." + text(abs(_DS)) + "f" ) % _total |
| 3531 self.columns[1].set_title(_("Type")) # Σ parcial Σ total | 3579 self.columns[1].set_title(_("Type")) # Σ parcial Σ total |
| 3532 self.columns[2].set_title(_("Comment")) | 3580 self.columns[2].set_title(_("Comment")) |
| 3533 self.columns[3].set_title(_("N\n(a)")) | 3581 self.columns[3].set_title(_("N\n(a)")) |
| 3534 self.columns[4].set_title(_("Length\n(b)")) | 3582 self.columns[4].set_title(_("Length\n(b)")) |
| 3535 self.columns[5].set_title(_("Width\n(c)")) | 3583 self.columns[5].set_title(_("Width\n(c)")) |
| 3545 Sets the liststore record values from a path record | 3593 Sets the liststore record values from a path record |
| 3546 """ | 3594 """ |
| 3547 self.__liststore.clear() | 3595 self.__liststore.clear() |
| 3548 _budget = self.__budget | 3596 _budget = self.__budget |
| 3549 if not _budget.hasPath(path_record): | 3597 if not _budget.hasPath(path_record): |
| 3550 raise ValueError( _("Invalid path") ) | 3598 _tuni = _("Invalid path") |
| 3599 _str = _tuni.encode("utf-8") | |
| 3600 raise ValueError(_str) | |
| 3551 else: | 3601 else: |
| 3552 _measure = _budget.getMeasure(path_record) | 3602 _measure = _budget.getMeasure(path_record) |
| 3553 if isinstance(_measure, base.Measure): | 3603 if isinstance(_measure, base.Measure): |
| 3554 _lines = _measure.lines | 3604 _lines = _measure.lines |
| 3555 for _line in _lines: | 3605 for _line in _lines: |
| 3556 _values = [ _line ] | 3606 _values = [ _line ] |
| 3557 _treeiter = self.__liststore.append(_values) | 3607 _treeiter = self.__liststore.append(_values) |
| 3558 else: | 3608 else: |
| 3559 raise ValueError( utils.mapping(_("measure must be a Measure "\ | 3609 _tuni = _("measure must be a Measure object. Type: $1") |
| 3560 "object. Type: $1"), (str(type(_measure)),)) ) | 3610 _uni = utils.mapping(_tuni, (text(type(_measure)),)) |
| 3611 _str = _tuni.encode("utf-8") | |
| 3612 raise ValueError(_str) | |
| 3561 | 3613 |
| 3562 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): | 3614 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): |
| 3563 """_colorCell(column, cell_renderer, tree_model, iter, lcolor) | 3615 """_colorCell(column, cell_renderer, tree_model, iter, lcolor) |
| 3564 | 3616 |
| 3565 column: the Gtk.TreeViewColumn in the treeview | 3617 column: the Gtk.TreeViewColumn in the treeview |
| 3585 and text for index and amount columns. | 3637 and text for index and amount columns. |
| 3586 """ | 3638 """ |
| 3587 _row_path = tree_model.get_path(iter) | 3639 _row_path = tree_model.get_path(iter) |
| 3588 _number = _row_path[-1] | 3640 _number = _row_path[-1] |
| 3589 if column is self.__index_column: | 3641 if column is self.__index_column: |
| 3590 cell_renderer.set_property('text', str(_number + 1)) | 3642 cell_renderer.set_property('text', text(_number + 1)) |
| 3591 self.__index_column.get_cells()[1].set_property( | 3643 self.__index_column.get_cells()[1].set_property( |
| 3592 'cell-background', lcolor[_number % 2]) | 3644 'cell-background', lcolor[_number % 2]) |
| 3593 elif column is self.__linetype_column: | 3645 elif column is self.__linetype_column: |
| 3594 _measure = tree_model[_row_path][0] | 3646 _measure = tree_model[_row_path][0] |
| 3595 _type = _measure.lineType | 3647 _type = _measure.lineType |
| 3603 else: #elif _type == 3: | 3655 else: #elif _type == 3: |
| 3604 cell_renderer.set_property("pixbuf", | 3656 cell_renderer.set_property("pixbuf", |
| 3605 self.__calculatedline_icon) | 3657 self.__calculatedline_icon) |
| 3606 elif column is self.__comment_column: | 3658 elif column is self.__comment_column: |
| 3607 _measure = tree_model[_row_path][0] | 3659 _measure = tree_model[_row_path][0] |
| 3608 _comment = str(_measure.comment) | 3660 _comment = text(_measure.comment) |
| 3609 cell_renderer.set_property('text', _comment) | 3661 cell_renderer.set_property('text', _comment) |
| 3610 elif column is self.__units_column: | 3662 elif column is self.__units_column: |
| 3611 _measure = tree_model[_row_path][0] | 3663 _measure = tree_model[_row_path][0] |
| 3612 _units = _measure.units | 3664 _units = _measure.units |
| 3613 if isinstance(_units, float): | 3665 if isinstance(_units, float): |
| 3614 _DN = self.__budget.getDecimals("DN") | 3666 _DN = self.__budget.getDecimals("DN") |
| 3615 _units = ("%." + str(abs(_DN)) + "f" ) % _units | 3667 _units = ("%." + text(abs(_DN)) + "f" ) % _units |
| 3616 cell_renderer.set_property('text', _units) | 3668 cell_renderer.set_property('text', _units) |
| 3617 elif column is self.__length_column: | 3669 elif column is self.__length_column: |
| 3618 _measure = tree_model[_row_path][0] | 3670 _measure = tree_model[_row_path][0] |
| 3619 _length = _measure.length | 3671 _length = _measure.length |
| 3620 if isinstance(_length, float): | 3672 if isinstance(_length, float): |
| 3621 _DD = self.__budget.getDecimals("DD") | 3673 _DD = self.__budget.getDecimals("DD") |
| 3622 _length = ("%." + str(abs(_DD)) + "f" ) % _length | 3674 _length = ("%." + text(abs(_DD)) + "f" ) % _length |
| 3623 cell_renderer.set_property('text', _length) | 3675 cell_renderer.set_property('text', _length) |
| 3624 elif column is self.__width_column: | 3676 elif column is self.__width_column: |
| 3625 _measure = tree_model[_row_path][0] | 3677 _measure = tree_model[_row_path][0] |
| 3626 _width = _measure.width | 3678 _width = _measure.width |
| 3627 if isinstance(_width, float): | 3679 if isinstance(_width, float): |
| 3628 _DD = self.__budget.getDecimals("DD") | 3680 _DD = self.__budget.getDecimals("DD") |
| 3629 _width = ("%." + str(abs(_DD)) + "f" ) % _width | 3681 _width = ("%." + text(abs(_DD)) + "f" ) % _width |
| 3630 cell_renderer.set_property('text', _width) | 3682 cell_renderer.set_property('text', _width) |
| 3631 elif column is self.__height_column: | 3683 elif column is self.__height_column: |
| 3632 _measure = tree_model[_row_path][0] | 3684 _measure = tree_model[_row_path][0] |
| 3633 _height = _measure.height | 3685 _height = _measure.height |
| 3634 if isinstance(_height, float): | 3686 if isinstance(_height, float): |
| 3635 _DD = self.__budget.getDecimals("DD") | 3687 _DD = self.__budget.getDecimals("DD") |
| 3636 _height = ("%." + str(abs(_DD)) + "f" ) % _height | 3688 _height = ("%." + text(abs(_DD)) + "f" ) % _height |
| 3637 cell_renderer.set_property('text', _height) | 3689 cell_renderer.set_property('text', _height) |
| 3638 elif column is self.__formula_column: | 3690 elif column is self.__formula_column: |
| 3639 _measure = tree_model[_row_path][0] | 3691 _measure = tree_model[_row_path][0] |
| 3640 _formula = _measure.formula | 3692 _formula = _measure.formula |
| 3641 cell_renderer.set_property('text', _formula) | 3693 cell_renderer.set_property('text', _formula) |
| 3646 if _type == 1 or _type == 2: | 3698 if _type == 1 or _type == 2: |
| 3647 _parcial = "" | 3699 _parcial = "" |
| 3648 else: | 3700 else: |
| 3649 if isinstance(_parcial, float): | 3701 if isinstance(_parcial, float): |
| 3650 _DS = self.__budget.getDecimals("DS") | 3702 _DS = self.__budget.getDecimals("DS") |
| 3651 _parcial = ("%." + str(abs(_DS)) + "f" ) % _parcial | 3703 _parcial = ("%." + text(abs(_DS)) + "f" ) % _parcial |
| 3652 cell_renderer.set_property('text', _parcial) | 3704 cell_renderer.set_property('text', _parcial) |
| 3653 elif column is self.__subtotal_column: | 3705 elif column is self.__subtotal_column: |
| 3654 _measure_line = tree_model[_row_path][0] | 3706 _measure_line = tree_model[_row_path][0] |
| 3655 _type = _measure_line.lineType | 3707 _type = _measure_line.lineType |
| 3656 if _type == 1 or _type == 2: | 3708 if _type == 1 or _type == 2: |
| 3661 _color = globalVars.color["SUBTOTAL"] | 3713 _color = globalVars.color["SUBTOTAL"] |
| 3662 _subtotal = _measure_line.acumulated_subtotal | 3714 _subtotal = _measure_line.acumulated_subtotal |
| 3663 lcolor = [_color, _color] | 3715 lcolor = [_color, _color] |
| 3664 if isinstance(_subtotal, float): | 3716 if isinstance(_subtotal, float): |
| 3665 _DS = self.__budget.getDecimals("DS") | 3717 _DS = self.__budget.getDecimals("DS") |
| 3666 _subtotal= ("%." + str(abs(_DS)) + "f" ) % _subtotal | 3718 _subtotal= ("%." + text(abs(_DS)) + "f" ) % _subtotal |
| 3667 cell_renderer.set_property('text', _subtotal) | 3719 cell_renderer.set_property('text', _subtotal) |
| 3668 else: | 3720 else: |
| 3669 cell_renderer.set_property('text', "") | 3721 cell_renderer.set_property('text', "") |
| 3670 | 3722 |
| 3671 if self.__treeview.get_cursor() == (_row_path,column): | 3723 if self.__treeview.get_cursor() == (_row_path,column): |
| 3852 self.__textbuffer = _textview.get_buffer() | 3904 self.__textbuffer = _textview.get_buffer() |
| 3853 self.__textbuffer.set_text(_text) | 3905 self.__textbuffer.set_text(_text) |
| 3854 _textview.show() | 3906 _textview.show() |
| 3855 _vbox = Gtk.Grid() | 3907 _vbox = Gtk.Grid() |
| 3856 _vbox.set_orientation(Gtk.Orientation(1)) # 1 Vertical | 3908 _vbox.set_orientation(Gtk.Orientation(1)) # 1 Vertical |
| 3857 self.__label = Gtk.Label(utils.mapping(_("Description text of the "\ | 3909 _tuni = _("Description text of the record $1") |
| 3858 "record $1"), (str(self.__budget.getCode( | 3910 _ucode = self.__budget.getCode(self.__active_path_record) |
| 3859 self.__active_path_record)),))) | 3911 _uni = utils.mapping(_tuni, (_ucode,)) |
| 3912 self.__label = Gtk.Label(_uni) | |
| 3860 self.__label.set_alignment(0, 0) | 3913 self.__label.set_alignment(0, 0) |
| 3861 self.__label.show() | 3914 self.__label.show() |
| 3862 _vbox.add(self.__label) | 3915 _vbox.add(self.__label) |
| 3863 _vbox.add(_textview) | 3916 _vbox.add(_textview) |
| 3864 _vbox.show() | 3917 _vbox.show() |
| 3873 Set the new path code to show its description text. | 3926 Set the new path code to show its description text. |
| 3874 """ | 3927 """ |
| 3875 _budget = self.__budget | 3928 _budget = self.__budget |
| 3876 self.__active_path_record = path_record | 3929 self.__active_path_record = path_record |
| 3877 _code = _budget.getCode(self.__active_path_record) | 3930 _code = _budget.getCode(self.__active_path_record) |
| 3878 self.__label.set_text(utils.mapping(_("Description text of the record "\ | 3931 _tuni = _("Description text of the record $1") |
| 3879 "$1"), (_code.decode("utf8"),))) | 3932 _uni = utils.mapping(_tuni, (_code,)) |
| 3933 self.__label.set_text(_uni) | |
| 3880 _text = _budget.getRecord(_code).text | 3934 _text = _budget.getRecord(_code).text |
| 3881 self.__textbuffer.set_text(_text) | 3935 self.__textbuffer.set_text(_text) |
| 3882 | 3936 |
| 3883 def runMessage(self, message, pane_path, arg=None): | 3937 def runMessage(self, message, pane_path, arg=None): |
| 3884 """runMessage(message, pane_path, arg=None) | 3938 """runMessage(message, pane_path, arg=None) |
| 4027 self.__pane_path = pane_path | 4081 self.__pane_path = pane_path |
| 4028 self.__active_path_record = path_record | 4082 self.__active_path_record = path_record |
| 4029 _budget = budget | 4083 _budget = budget |
| 4030 _main_box = Gtk.Grid() | 4084 _main_box = Gtk.Grid() |
| 4031 _main_box.set_orientation(Gtk.Orientation(1)) # 1 Vertical | 4085 _main_box.set_orientation(Gtk.Orientation(1)) # 1 Vertical |
| 4032 self.__label = Gtk.Label(utils.mapping(_("Sheet of Conditions of the "\ | 4086 _tuni = _("Sheet of Conditions of the record $1") |
| 4033 "record $1"), (self.__budget.getCode( | 4087 _ucode = self.__budget.getCode(self.__active_path_record) |
| 4034 self.__active_path_record),))) | 4088 _uni = utils.mapping(_tuni, (_ucode,)) |
| 4089 self.__label = Gtk.Label(_uni) | |
| 4035 self.__label.set_xalign(0) | 4090 self.__label.set_xalign(0) |
| 4036 self.__label.set_yalign(0) | 4091 self.__label.set_yalign(0) |
| 4037 self.__label.show() | 4092 self.__label.show() |
| 4038 _frame = Gtk.Frame() | 4093 _frame = Gtk.Frame() |
| 4039 _frame.set_shadow_type(Gtk.ShadowType(1)) # 1 In | 4094 _frame.set_shadow_type(Gtk.ShadowType(1)) # 1 In |
| 4235 self.__section_liststore.clear() | 4290 self.__section_liststore.clear() |
| 4236 self.__textbuffer.set_text("") | 4291 self.__textbuffer.set_text("") |
| 4237 _budget = self.__budget | 4292 _budget = self.__budget |
| 4238 self.__active_path_record = path_record | 4293 self.__active_path_record = path_record |
| 4239 _code = _budget.getCode(self.__active_path_record) | 4294 _code = _budget.getCode(self.__active_path_record) |
| 4240 self.__label.set_text(utils.mapping(_("Sheet2 of Conditions of the "\ | 4295 _tuni = _("Sheet2 of Conditions of the record $1") |
| 4241 "record $1"), (_code,))) | 4296 _uni = utils.mapping(_tuni, (_code,)) |
| 4297 self.__label.set_text(_uni) | |
| 4242 self._setFields() | 4298 self._setFields() |
| 4243 | 4299 |
| 4244 def runMessage(self, message, pane_path, arg=None): | 4300 def runMessage(self, message, pane_path, arg=None): |
| 4245 """runMessage(message, pane_path, arg=None) | 4301 """runMessage(message, pane_path, arg=None) |
| 4246 | 4302 |
| 4695 if path_record is None: | 4751 if path_record is None: |
| 4696 path_record = (0,) | 4752 path_record = (0,) |
| 4697 self.__selection = None | 4753 self.__selection = None |
| 4698 # Seting init args | 4754 # Seting init args |
| 4699 if not isinstance(budget, base.Budget): | 4755 if not isinstance(budget, base.Budget): |
| 4700 raise ValueError( _("Argument must be a Budget object") ) | 4756 _tuni = _("Argument must be a Budget object") |
| 4757 _str = _tuni.encode("utf-8") | |
| 4758 raise ValueError(_str) | |
| 4701 self.__budget = budget | 4759 self.__budget = budget |
| 4702 self.__wr_page = wr_page | 4760 self.__wr_page = wr_page |
| 4703 self.__pane_path = pane_path | 4761 self.__pane_path = pane_path |
| 4704 self.__active_path_record = path_record | 4762 self.__active_path_record = path_record |
| 4705 # main widget | 4763 # main widget |
| 4834 The selection changes the company/office in the option treeview | 4892 The selection changes the company/office in the option treeview |
| 4835 """ | 4893 """ |
| 4836 if len(path) == 1: | 4894 if len(path) == 1: |
| 4837 # The selection is a company | 4895 # The selection is a company |
| 4838 _company_key = self.__treestore[path][0] | 4896 _company_key = self.__treestore[path][0] |
| 4897 _company_key = textinp2(_company_key) | |
| 4839 _company = self.__budget.getCompany(_company_key) | 4898 _company = self.__budget.getCompany(_company_key) |
| 4840 _selection = "company" | 4899 _selection = "company" |
| 4841 _values = _company.values | 4900 _values = _company.values |
| 4842 else: | 4901 else: |
| 4843 # The selection is a office | 4902 # The selection is a office |
| 4844 _company_key = self.__treestore[path[:1]][0] | 4903 _company_key = self.__treestore[path[:1]][0] |
| 4904 _company_key = textinp2(_company_key) | |
| 4845 _company = self.__budget.getCompany(_company_key) | 4905 _company = self.__budget.getCompany(_company_key) |
| 4846 _selection = "office" | 4906 _selection = "office" |
| 4847 _office = _company.offices[path[1]] | 4907 _office = _company.offices[path[1]] |
| 4848 _values = _office.values | 4908 _values = _office.values |
| 4849 if not self.__selection == _selection: | 4909 if not self.__selection == _selection: |
| 4875 """ | 4935 """ |
| 4876 _budget = self.__budget | 4936 _budget = self.__budget |
| 4877 if message == "change_active": | 4937 if message == "change_active": |
| 4878 if _budget.hasPath(arg): | 4938 if _budget.hasPath(arg): |
| 4879 _path_record = arg | 4939 _path_record = arg |
| 4880 self._showMessageRecord( _path_record) | 4940 self._showMessageRecord(_path_record) |
| 4881 pass | 4941 pass |
| 4882 elif message == "clear": | 4942 elif message == "clear": |
| 4883 self._clear() | 4943 self._clear() |
| 4884 | 4944 |
| 4885 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): | 4945 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): |
| 4908 and text for index and amount columns. | 4968 and text for index and amount columns. |
| 4909 """ | 4969 """ |
| 4910 _row_path = tree_model.get_path(iter) | 4970 _row_path = tree_model.get_path(iter) |
| 4911 _number = _row_path[-1] | 4971 _number = _row_path[-1] |
| 4912 if column is self.__index_column: | 4972 if column is self.__index_column: |
| 4913 cell_renderer.set_property('text', str(_number + 1)) | 4973 cell_renderer.set_property('text', text(_number + 1)) |
| 4914 self.__index_column.get_cells()[1].set_property( | 4974 self.__index_column.get_cells()[1].set_property( |
| 4915 'cell-background', lcolor[_number % 2]) | 4975 'cell-background', lcolor[_number % 2]) |
| 4916 if self.__treeview.get_cursor() == (_row_path,column): | 4976 if self.__treeview.get_cursor() == (_row_path,column): |
| 4917 cell_renderer.set_property('cell-background', | 4977 cell_renderer.set_property('cell-background', |
| 4918 globalVars.color["ACTIVE"]) | 4978 globalVars.color["ACTIVE"]) |
| 5269 if isinstance(_option, tuple) and len(_option) == 4: | 5329 if isinstance(_option, tuple) and len(_option) == 4: |
| 5270 _option_key = _option[0] | 5330 _option_key = _option[0] |
| 5271 _option_name = _option[1] | 5331 _option_name = _option[1] |
| 5272 _option_type = _option[2] | 5332 _option_type = _option[2] |
| 5273 _option_description = _option[3] | 5333 _option_description = _option[3] |
| 5274 #-# str and unicode | 5334 if isinstance(_option_key, text_type) and \ |
| 5275 if (isinstance(_option_key, str) or \ | 5335 isinstance(_option_name, text_type) and \ |
| 5276 isinstance(_option_key, unicode)) and \ | |
| 5277 (isinstance(_option_name, str) or\ | |
| 5278 isinstance(_option_name, unicode))and \ | |
| 5279 _option_type in self.__option_types.keys(): | 5336 _option_type in self.__option_types.keys(): |
| 5280 self.__liststore.append([_option_key, _option_name, "", | 5337 self.__liststore.append([_option_key, _option_name, "", |
| 5281 _option_type, _option_description]) | 5338 _option_type, _option_description]) |
| 5282 self.__option_dict[_option_key] = [_option_name, "", | 5339 self.__option_dict[_option_key] = [_option_name, "", |
| 5283 _option_type, _option_description] | 5340 _option_type, _option_description] |
| 5295 values: dictionary {option : value} | 5352 values: dictionary {option : value} |
| 5296 | 5353 |
| 5297 Sets the Options values | 5354 Sets the Options values |
| 5298 """ | 5355 """ |
| 5299 if isinstance(values, dict): | 5356 if isinstance(values, dict): |
| 5300 for _option, _value in values.iteritems(): | 5357 for (_option, _value) in values.items(): |
| 5301 if _option in self.__option_dict: | 5358 if _option in self.__option_dict: |
| 5302 _type = self.__option_dict[_option][2] | 5359 _type = self.__option_dict[_option][2] |
| 5303 if _type == "boolean": | 5360 if _type == "boolean": |
| 5304 if isinstance(_value, bool): | 5361 if isinstance(_value, bool): |
| 5305 _num = self.__option_list.index(_option) | 5362 _num = self.__option_list.index(_option) |
| 5317 _num = self.__option_list.index(_option) | 5374 _num = self.__option_list.index(_option) |
| 5318 _iter = self.__liststore.get_iter((_num,)) | 5375 _iter = self.__liststore.get_iter((_num,)) |
| 5319 self.__liststore.set_value(_iter, 2, _value) | 5376 self.__liststore.set_value(_iter, 2, _value) |
| 5320 self.__option_dict[_option][1] = _value | 5377 self.__option_dict[_option][1] = _value |
| 5321 elif _type == "string": | 5378 elif _type == "string": |
| 5322 if isinstance(_value, str): | 5379 if isinstance(_value, text_type): |
| 5323 _num = self.__option_list.index(_option) | 5380 _num = self.__option_list.index(_option) |
| 5324 _iter = self.__liststore.get_iter((_num,)) | 5381 _iter = self.__liststore.get_iter((_num,)) |
| 5325 self.__liststore.set_value(_iter, 2, _value) | 5382 self.__liststore.set_value(_iter, 2, _value) |
| 5326 self.__option_dict[_option][1] = _value | 5383 self.__option_dict[_option][1] = _value |
| 5327 else: | 5384 else: |
| 5338 self.__liststore.set_value(_iter, 2, _str_value) | 5395 self.__liststore.set_value(_iter, 2, _str_value) |
| 5339 self.__option_dict[_option][1] = _value | 5396 self.__option_dict[_option][1] = _value |
| 5340 else: | 5397 else: |
| 5341 print(_("Icorrect type, must be list") ) | 5398 print(_("Icorrect type, must be list") ) |
| 5342 elif _type == "color": | 5399 elif _type == "color": |
| 5343 if isinstance(_value, str): | 5400 if isinstance(_value, text_type): |
| 5344 if Gdk.RGBA().parse(_value): | 5401 if Gdk.RGBA().parse(_value): |
| 5345 print(_("Icorrect type, must be a parseable " \ | 5402 print(_("Icorrect type, must be a parseable " \ |
| 5346 "color") ) | 5403 "color") ) |
| 5347 else: | 5404 else: |
| 5348 _num = self.__option_list.index(_option) | 5405 _num = self.__option_list.index(_option) |
