comparison Gtk/gui.py @ 22:7bd4ca56607d

bug fix: Mutable default arguments
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Tue, 30 Sep 2014 17:16:50 +0200
parents f7e0cc58737f
children 65e7ae0d0e63
comparison
equal deleted inserted replaced
21:f7e0cc58737f 22:7bd4ca56607d
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 ## File gui.py 2 ## File gui.py
3 ## This file is part of pyArq-Presupuestos. 3 ## This file is part of pyArq-Presupuestos.
4 ## 4 ##
5 ## Copyright (C) 2010 Miguel Ángel Bárcena Rodríguez 5 ## Copyright (C) 2010-2014 Miguel Ángel Bárcena Rodríguez
6 ## <miguelangel@obraencurso.es> 6 ## <miguelangel@obraencurso.es>
7 ## 7 ##
8 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify 8 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by 9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation, either version 3 of the License, or 10 ## the Free Software Foundation, either version 3 of the License, or
912 # TODO: * The panes can be ordered as the user wishes 912 # TODO: * The panes can be ordered as the user wishes
913 # TODO: * Panes in windows 913 # TODO: * Panes in windows
914 # TODO: * pane types 914 # TODO: * pane types
915 # TODO: * General budget properties (is better a dialog?) 915 # TODO: * General budget properties (is better a dialog?)
916 916
917 def __init__(self, mainWindow, budget, path_record=(0,)): 917 def __init__(self, mainWindow, budget, path_record=None):
918 """__init__(mainWindow, budget, path_record=(0,)) 918 """__init__(mainWindow, budget, path_record=None)
919 919
920 mainWindow: MainWindow object 920 mainWindow: MainWindow object
921 budget: "base.Budget" object 921 budget: "base.Budget" object
922 path_record: the active path record 922 path_record: the active path record
923 923
929 self.__history_back: 929 self.__history_back:
930 self.__history_forward: 930 self.__history_forward:
931 self.__back_menu: a gtk.Menu 931 self.__back_menu: a gtk.Menu
932 self.__forward_menu: a gtk.Menu 932 self.__forward_menu: a gtk.Menu
933 """ 933 """
934 if path_record is None:
935 path_record = (0,)
934 #TODO: __panes_list should come from config file... 936 #TODO: __panes_list should come from config file...
935 self.__mainWindow = mainWindow 937 self.__mainWindow = mainWindow
936 self.__widget = gtk.VBox() 938 self.__widget = gtk.VBox()
937 self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure", 939 self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure",
938 "RecordDescription" ]] 940 "RecordDescription" ]]
1088 _item.clear() 1090 _item.clear()
1089 else: 1091 else:
1090 # Thre is only one item in the page, it can not be closed 1092 # Thre is only one item in the page, it can not be closed
1091 pass 1093 pass
1092 1094
1093 def _itemsFactory(self, list_paned, pane_path=(0,)): 1095 def _itemsFactory(self, list_paned, pane_path=None):
1094 """_itemsFactory(list_paned, pane_path(0,)) 1096 """_itemsFactory(list_paned, pane_path=None)
1095 1097
1096 list_paned: list in "__panes_list" format 1098 list_paned: list in "__panes_list" format
1097 [ "v" or "h", panel1_type, panel2_type] 1099 [ "v" or "h", panel1_type, panel2_type]
1098 which contains the info for create the widgets. 1100 which contains the info for create the widgets.
1099 panel types: 1101 panel types:
1105 * "CompanyView" 1107 * "CompanyView"
1106 pane_path: tuple that represents the item path in the page 1108 pane_path: tuple that represents the item path in the page
1107 1109
1108 Creates the items and widgets and returns the main item 1110 Creates the items and widgets and returns the main item
1109 """ 1111 """
1112 if pane_path is None:
1113 pane_path = (0,)
1110 if not isinstance(list_paned , list): 1114 if not isinstance(list_paned , list):
1111 raise ValueError, _("The value must be a list") 1115 raise ValueError, _("The value must be a list")
1112 if list_paned[0] == "v" or list_paned[0] == "h": 1116 if list_paned[0] == "v" or list_paned[0] == "h":
1113 if len(list_paned) != 3: 1117 if len(list_paned) != 3:
1114 raise ValueError, _("Incorrect len") 1118 raise ValueError, _("Incorrect len")
2193 active_path_record: Read. Active path record 2197 active_path_record: Read. Active path record
2194 Methods: 2198 Methods:
2195 runMessage 2199 runMessage
2196 """ 2200 """
2197 2201
2198 def __init__(self, budget, page, pane_path, path_record=(0,)): 2202 def __init__(self, budget, page, pane_path, path_record=None):
2199 """__init__(budget, page, pane_path, path_record=(0,)) 2203 """__init__(budget, page, pane_path, path_record=None)
2200 2204
2201 budget: budget showed ("base.Budget" object) 2205 budget: budget showed ("base.Budget" object)
2202 page: weak reference from Page instance which creates this class 2206 page: weak reference from Page instance which creates this class
2203 pane_path: tuple that represents the path of the List in the Page 2207 pane_path: tuple that represents the path of the List in the Page
2204 path_record: the record path that must be showed 2208 path_record: the record path that must be showed
2244 * Sets the selection properties 2248 * Sets the selection properties
2245 * Connects the events 2249 * Connects the events
2246 """ 2250 """
2247 # TODO: to group all columns in a dicctionary 2251 # TODO: to group all columns in a dicctionary
2248 # Budget 2252 # Budget
2253 if path_record is None:
2254 parh_record = (0,)
2249 if not isinstance(budget, base.Budget): 2255 if not isinstance(budget, base.Budget):
2250 raise ValueError, _("Argument must be a Budget object") 2256 raise ValueError, _("Argument must be a Budget object")
2251 self.__budget = budget 2257 self.__budget = budget
2252 self.__page = page 2258 self.__page = page
2253 self.__pane_path = pane_path 2259 self.__pane_path = pane_path
2821 active_path_record: Read. Path of the active record in the budget 2827 active_path_record: Read. Path of the active record in the budget
2822 Methods: 2828 Methods:
2823 runMessage 2829 runMessage
2824 """ 2830 """
2825 2831
2826 def __init__(self, budget, page, pane_path, path_record=(0,)): 2832 def __init__(self, budget, page, pane_path, path_record=None):
2827 """__init__(budget, page, pane_path, path_record=(0,)) 2833 """__init__(budget, page, pane_path, path_record=None)
2828 2834
2829 budget: budget: budget showed ("base.Budget" object) 2835 budget: budget: budget showed ("base.Budget" object)
2830 page: weak reference from Page instance which creates this class 2836 page: weak reference from Page instance which creates this class
2831 pane_path: tuple that represents the path of the List in the Page 2837 pane_path: tuple that represents the path of the List in the Page
2832 path_record: path of the active record in the budget 2838 path_record: path of the active record in the budget
2871 * Sets te the column headers values 2877 * Sets te the column headers values
2872 * Sets the selection properties 2878 * Sets the selection properties
2873 * Connects the events 2879 * Connects the events
2874 """ 2880 """
2875 # Seting init args 2881 # Seting init args
2882 if path_record is None:
2883 path_record = (0,)
2876 if not isinstance(budget, base.Budget): 2884 if not isinstance(budget, base.Budget):
2877 raise ValueError, _("Argument must be a Budget object") 2885 raise ValueError, _("Argument must be a Budget object")
2878 self.__budget = budget 2886 self.__budget = budget
2879 self.__page = page 2887 self.__page = page
2880 self.__pane_path = pane_path 2888 self.__pane_path = pane_path
3409 Methods: 3417 Methods:
3410 runMessage 3418 runMessage
3411 """ 3419 """
3412 # TODO: make standar: "DecompositonList and Description" 3420 # TODO: make standar: "DecompositonList and Description"
3413 3421
3414 def __init__(self, budget, page, pane_path, path_record=(0,)): 3422 def __init__(self, budget, page, pane_path, path_record=None):
3415 """__init__(budget, page, pane_path, path_record=(0,)) 3423 """__init__(budget, page, pane_path, path_record=None)
3416 3424
3417 budget: the budget (base.obra object) 3425 budget: the budget (base.obra object)
3418 page: weak reference from Page instance which creates this class 3426 page: weak reference from Page instance which creates this class
3419 pane_path: the path position of the description in the page 3427 pane_path: the path position of the description in the page
3420 path_record: the path of the active record 3428 path_record: the path of the active record
3430 self.__widget: the main pane widget, a gtk.ScrolledWindow() 3438 self.__widget: the main pane widget, a gtk.ScrolledWindow()
3431 3439
3432 Creates an shows the scroledwindow that contain the description text 3440 Creates an shows the scroledwindow that contain the description text
3433 of the record to be showed in a pane. 3441 of the record to be showed in a pane.
3434 """ 3442 """
3443 if path_record is None:
3444 path_record = (0,)
3435 self.__budget = budget 3445 self.__budget = budget
3436 self.__page = page 3446 self.__page = page
3437 self.__pane_path = pane_path 3447 self.__pane_path = pane_path
3438 self.__active_path_record = path_record 3448 self.__active_path_record = path_record
3439 _budget = budget 3449 _budget = budget
3590 active_path_record: The active path record 3600 active_path_record: The active path record
3591 Methods: 3601 Methods:
3592 runMessage 3602 runMessage
3593 """ 3603 """
3594 3604
3595 def __init__(self, budget, page, pane_path, path_record=(0,)): 3605 def __init__(self, budget, page, pane_path, path_record=None):
3596 """__init__(budget, page, pane_path, path_record=(0,)) 3606 """__init__(budget, page, pane_path, path_record=None)
3597 3607
3598 budget: the budget (base.obra object) 3608 budget: the budget (base.obra object)
3599 page: weak reference from Page instance which creates this class 3609 page: weak reference from Page instance which creates this class
3600 pane_path: the path position of the description in the page 3610 pane_path: the path position of the description in the page
3601 path_record: the path of the active record 3611 path_record: the path of the active record
3616 self.__widget: main widget, a gtk.VBox() 3626 self.__widget: main widget, a gtk.VBox()
3617 3627
3618 Creates an shows the scroledwindow that contain the description text 3628 Creates an shows the scroledwindow that contain the description text
3619 of the record to be showed in a pane. 3629 of the record to be showed in a pane.
3620 """ 3630 """
3631 if path_record is None:
3632 path_record = (0,)
3621 self.__budget = budget 3633 self.__budget = budget
3622 self.__page = page 3634 self.__page = page
3623 self.__pane_path = pane_path 3635 self.__pane_path = pane_path
3624 self.__active_path_record = path_record 3636 self.__active_path_record = path_record
3625 _budget = budget 3637 _budget = budget
3937 active_code: The active code of the record 3949 active_code: The active code of the record
3938 Methods: 3950 Methods:
3939 runMessage 3951 runMessage
3940 """ 3952 """
3941 3953
3942 def __init__(self, budget, page, pane_path, path_record=(0,)): 3954 def __init__(self, budget, page, pane_path, path_record=None):
3943 """__init__(budget, page, pane_path, path_record=(0,)) 3955 """__init__(budget, page, pane_path, path_record=None)
3944 3956
3945 budget: the budget (base.obra object) 3957 budget: the budget (base.obra object)
3946 page: weak reference from Page instance which creates this class 3958 page: weak reference from Page instance which creates this class
3947 pane_path: the path position of the description in the page 3959 pane_path: the path position of the description in the page
3948 path_record: the path of the active record 3960 path_record: the path of the active record
3956 self.__widget: main widget, a gtk.ScrolledWindow 3968 self.__widget: main widget, a gtk.ScrolledWindow
3957 3969
3958 Creates an shows the scroledwindow that contain icon files 3970 Creates an shows the scroledwindow that contain icon files
3959 of the record to be showed in a pane. 3971 of the record to be showed in a pane.
3960 """ 3972 """
3973 if path_record is None:
3974 path_record = (0,)
3961 self.__budget = budget 3975 self.__budget = budget
3962 self.__page = page 3976 self.__page = page
3963 self.__pane_path = pane_path 3977 self.__pane_path = pane_path
3964 self.__active_path_record = path_record 3978 self.__active_path_record = path_record
3965 self.__active_code = budget.getCode(self.__active_path_record) 3979 self.__active_code = budget.getCode(self.__active_path_record)
4180 budget: Read. Budget to show, base.budget instance. 4194 budget: Read. Budget to show, base.budget instance.
4181 Methods: 4195 Methods:
4182 runMessage 4196 runMessage
4183 """ 4197 """
4184 4198
4185 def __init__(self, budget, page, pane_path, path_record=(0,)): 4199 def __init__(self, budget, page, pane_path, path_record=None):
4186 """__init__(budget, page, pane_path, path_record=(0,)) 4200 """__init__(budget, page, pane_path, path_record=None)
4187 4201
4188 budget: budget: budget showed ("base.Budget" object) 4202 budget: budget: budget showed ("base.Budget" object)
4189 page: weak reference from Page instance which creates this class 4203 page: weak reference from Page instance which creates this class
4190 pane_path: tuple that represents the path of the List in the Page 4204 pane_path: tuple that represents the path of the List in the Page
4191 path_record: path of the active record in the budget 4205 path_record: path of the active record in the budget
4199 self.__treestore: to store companys data 4213 self.__treestore: to store companys data
4200 self.__option_View: OptionView object 4214 self.__option_View: OptionView object
4201 4215
4202 Creates an shows the scroledwindow that contain the company data. 4216 Creates an shows the scroledwindow that contain the company data.
4203 """ 4217 """
4218 if path_record is None:
4219 path_record = (0,)
4204 self.__selection = None 4220 self.__selection = None
4205 # Seting init args 4221 # Seting init args
4206 if not isinstance(budget, base.Budget): 4222 if not isinstance(budget, base.Budget):
4207 raise ValueError, _("Argument must be a Budget object") 4223 raise ValueError, _("Argument must be a Budget object")
4208 self.__budget = budget 4224 self.__budget = budget