# HG changeset patch # User Miguel Ángel Bárcena Rodríguez # Date 1290024356 -3600 # Node ID 55df0b15706b51bb4156f9c1021f755fa5749ff6 # Parent 0359329a1c26379ebd901e8dc664ea58e4c15f6a Docstrings and names in GTK/gui.py diff -r 0359329a1c26 -r 55df0b15706b Gtk/gui.py --- a/Gtk/gui.py Thu Nov 11 23:22:35 2010 +0100 +++ b/Gtk/gui.py Wed Nov 17 21:05:56 2010 +0100 @@ -32,7 +32,6 @@ The view can have diferente type of widgets to show the budget information. The DecompositionList class show the decompositon list information of a record The Measure class show the measure information of a record -The TextWindow class show the long description of a record The Sheet class class show the sheet of condition information of a record The views can send signal to the others. @@ -75,6 +74,7 @@ print utils.mapping(_("pyArq-Presupuestos running on $1"), (globalVars.desktop["desktop"],)) + class MainWindow(object): """gui.MainWindow: @@ -87,12 +87,11 @@ +-- object +-- MainWindow Atributes: - "window": Main window widget ("gtk.Window" object) + notebook: Read. notebook widget + pageList: Read. page list + budgetList: Read. budget list Methods: removePage - getNotebook - getPageList - getBudgetList """ # TODO:* Can choose open budget in new window # TODO:* gtk.Action for menu and toolbar @@ -131,11 +130,12 @@ ''' def __init__(self): - """def __init__(self) + """__init__() Initialize the atributes "__budget_list" and "__page_list" without data. Creates the widgets "window" and "__notebook". + self.__window: gtk.Window object self.__budget_temp_list: Temporal list of budgets self.__budget_list: List of budgets ("base.Budget" objects) self.__page_list: List of pages ("Page" object) @@ -147,20 +147,20 @@ self.__budget_list = [] self.__page_list = [] # Main window - self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) - self.window.set_default_size(771, 570) - self.window.set_title("Presupuestos") - self.window.set_border_width(0) - self.window.connect("destroy", self._destroy) - self.window.connect("delete_event", self._delete_event) + self.__window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.__window.set_default_size(771, 570) + self.__window.set_title("Presupuestos") + self.__window.set_border_width(0) + self.__window.connect("destroy", self._destroy) + self.__window.connect("delete_event", self._delete_event) # Vertical box _vbox1 = gtk.VBox(False, 0) - self.window.add(_vbox1) + self.__window.add(_vbox1) _vbox1.show() #Uimanager _uimanager = gtk.UIManager() _accelgroup = _uimanager.get_accel_group() - self.window.add_accel_group(_accelgroup) + self.__window.add_accel_group(_accelgroup) _general_action_group = gtk.ActionGroup("General") self.__general_action_group = _general_action_group _general_action_group.add_actions( @@ -205,17 +205,17 @@ self.__notebook.set_scrollable(True) self.__notebook.show() self._main() - + def _main(self): - """def main(self) + """main() Shows window and starts the GTK+ event processing loop. """ - self.window.show() + self.__window.show() gtk.main() - + def _addBudget(self, budget): - """def _addBudget(self, budget) + """_addBudget(budget) budget: "base.Budget" object @@ -228,7 +228,7 @@ self.__budget_list.append(_budget) def _appendPage(self): - """def _appendPage(self) + """_appendPage() Creates a new page (instance of "Page class") from the last budget in __budget_list, appends this page in the "__page_list" and shows the @@ -241,7 +241,7 @@ def _menuitemImportFiebdc(self, widget): - """def _menuitemImportFiebdc(self, widget) + """_menuitemImportFiebdc(widget) widget: the widget where the event is emitted from Callback to open a budget file. @@ -259,7 +259,7 @@ _read_method, _budget, _filename, _exit_method, _filetype) def _menuitemImportPriceDatabase(self, widget): - """def _menuitemImportPriceDatabase(self, widget) + """_menuitemImportPriceDatabase(widget) widget: the widget where the event is emitted from Callback to open a price database file. @@ -277,7 +277,7 @@ _read_method, _budget, _filename, _exit_method, _filetype) def _menuitemOpenPriceDatabase(self, widget): - """def _menuitemOpenPriceDatabase(self, widget) + """_menuitemOpenPriceDatabase(widget) widget: the widget where the event is emitted from Callback to open a price database from a durus file. @@ -295,7 +295,7 @@ _read_method, _budget, _filename, _exit_method, _filetype) def _menuitemClose(self, widget): - """def _menuitemClose(self, widget) + """_menuitemClose(widget) widget: the widget where the event is emitted from @@ -310,7 +310,7 @@ _page.close() def removePage(self, page_num): - """def removePage(self, page_num) + """removePage(page_num) page_num: The number Page to be removed @@ -326,7 +326,7 @@ self.__notebook.remove_page(page_num) def _menuitemGoToRoot(self, widget): - """def _menuitemGoToRoot(self, widget) + """_menuitemGoToRoot(widget) widget: the widget where the event is emitted from @@ -341,7 +341,7 @@ _page.propagateMessageFrom("change_active", (-1,), (0,)) def _menuitemGoUp(self, widget): - """def _menuitemGoUp(self, widget) + """_menuitemGoUp(widget) widget: the widget where the event is emitted from @@ -361,7 +361,7 @@ _up_path) def _menuitemGoDown(self, widget): - """def _menuitemGoToDown(self, widget) + """_menuitemGoToDown(widget) widget: the widget where the event is emitted from @@ -381,7 +381,7 @@ _up_path) def _menuitemGoPrevious(self, widget): - """def _menuitemGoPrevious(self, widget) + """_menuitemGoPrevious(widget) widget: the widget where the event is emitted from @@ -400,7 +400,7 @@ _previous_path) def _menuitemGoPosterior(self, widget): - """def _menuitemPosterior(self, widget) + """_menuitemPosterior(widget) widget: the widget where the event is emitted from @@ -419,7 +419,7 @@ _posterior_path) def _delete_event(self, widget, event): - """_delete_event(self, widget, event) + """_delete_event(widget, event) widget: the widget where the event is emitted from event: the "gtk.gdk.Event" @@ -433,7 +433,7 @@ return False # -> destroy def _destroy(self, widget): - """_destroy(self, widget) + """_destroy(widget) widget: the widget where the event is emitted from Method connected to "destroy" signal of main window widget @@ -445,27 +445,35 @@ """ gtk.main_quit() - def getNotebook(self): - """def getNotebook(self) + def _getNotebook(self): + """_getNotebook() Return the notebook widget """ return self.__notebook - def getPageList(self): - """def getPageList(self) + def _getPageList(self): + """_getPageList() Return the page list """ return self.__page_list - def getBudgetList(self): - """def getBudgetList(self) + def _getBudgetList(self): + """_getBudgetList() Return the budget list """ return self.__budget_list + notebook = property(_getNotebook, None, None, + "notebook object") + pageList = property(_getPageList, None, None, + "Page list") + budgetList = property(_getBudgetList, None, None, + "Budget list") + + class EmptyPage(object): """gui.EmptyPage: @@ -473,52 +481,34 @@ It creates and shows a page in the notebook while a budget is loaded. The page show the pyarq logo, loading time and a progress bar. Constructor: - gui.EmptyPage(self, mainWindow, readFileMethod, budget, filename, + gui.EmptyPage(mainWindow, readFileMethod, budget, filename, cancelMethod, filetype): + mainWindow: gui.Mainwindow object + readFileMethod: Method to read the selected file + budget: base.Budget object + filename: "file" + cancelMethod: Method to cancel the read method + filetype: "budget", "database" or "durus" Ancestry: +-- object +-- EmptyPage Atributes: - __mainWindow: gui.Mainwindow object - __readFileMethod: Method to read the selected file - __budget: base.Budget object - __filename: "file" - __cancelMethod: Method to cancel the read method - __filetype: "budget", "database" or "durus" - __children: the read thread - __progress: 0 to 1 progress - __widget: main widget, a gtk.VBox object - __main_item: None - __throbber: a gtk.Image - __animationThobber: a gtk.gdk.PixbufAnimation - __quietThobber: a pixbuf - __budget_icon: a gtk.gdk.pixbuf - __title: a gtk.HBox - __statusbar: a gtk.Statusbar - __statuscontext: the statusbar context - __progress_bar: a gtk.ProgressBar - + widget: Read. Main widget showed in the pane + title: Read. Page Title + filetype: Read. budget, basedata or durus Methods: - __init__ run progress stopLoading - _launchChildren - _launchTimeout - _updateProgressBar - _updateLabel - _autoClose threadFinishedSignal threadCanceled close clear - getWidget - getTitle - getFiletype """ + def __init__(self, mainWindow, readFileMethod, budget, filename, cancelMethod, filetype): - """def __init__(self, mainWindow, readFileMethod, budget, filename, + """__init__(mainWindow, readFileMethod, budget, filename, cancelMethod, filetype) mainWindow: gui.Mainwindow object @@ -527,6 +517,25 @@ filename: "file" cancelMethod: Method to cancel the read method filetype: "budget", "database" or "durus" + + self.__mainWindow: gui.Mainwindow object + self.__readFileMethod: Method to read the selected file + self.__budget: base.Budget object + self.__filename: "file" + self.__cancelMethod: Method to cancel the read method + self.__filetype: "budget", "database" or "durus" + self.__children: the read thread + self.__progress: 0 to 1 progress + self.__widget: main widget, a gtk.VBox object + self.__main_item: None + self.__throbber: a gtk.Image + self.__animationThobber: a gtk.gdk.PixbufAnimation + self.__quietThobber: a pixbuf + self.__budget_icon: a gtk.gdk.pixbuf + self.__title: a gtk.HBox + self.__statusbar: a gtk.Statusbar + self.__statuscontext: the statusbar context + self.__progress_bar: a gtk.ProgressBar """ self.__mainWindow = mainWindow self.__readFileMethod = readFileMethod @@ -586,22 +595,36 @@ self.__main_item = None def run(self): + """run() + + Launch clildren and timeouts + """ self.__statusbar.push(self.__statuscontext, _("Time: 0s")) self.__throbber.set_from_animation(self.__animationThobber) self._launchChildren() self._launchTimeout() def progress(self, percent): + """progress(percent) + + percent: Percentage executed. + + Sets progress + """ _progress = str(int(round(100 * percent,0))) self.__progress = percent def stopLoading(self): + """stopLoading() + + Stop progressbar + """ self.__throbber.set_from_pixbuf(self.__budget_icon) self.__progress_bar.hide() self.__statusbar.pop(self.__statuscontext) def _launchChildren(self): - """_launchChildren(self) + """_launchChildren() Launch the thread to read the file """ @@ -612,7 +635,7 @@ self.__children.start() def _launchTimeout(self): - """def _launchTimeout(self) + """_launchTimeout() Launch the timeouts: 1- update progress bar @@ -628,7 +651,7 @@ gobject.timeout_add(1000, self._autoClose) def _updateProgressBar(self): - """def _updateProgressBar(self) + """_updateProgressBar() update progress bar in a timeout If the thread end or is canceled the timeout is stoped @@ -643,7 +666,7 @@ return True def _updateLabel(self, _time): - """def _updateProgressBar(self) + """_updateProgressBar(_time) update time label in a timeout If the thread end or is canceled the timeout is stoped @@ -659,7 +682,7 @@ return True def _autoClose(self): - """def _updateProgressBar(self) + """_updateProgressBar() If the time label and progress bar timeouts are stoped the window is closed and ist tiemeout is stoped @@ -670,11 +693,11 @@ return True def threadFinishedSignal(self, budget): - """def closeWindow(self) - - Sets the __children atribute to None + """threadFinishedSignal(budget) + + Sets the self.__children to None This causes that the timeouts is ended. - This method is called from thread when it is finished + This method is called from thread when it finish """ self.__budget = budget self.__children = None @@ -684,11 +707,12 @@ for _child in _children: self.__widget.remove(_child) self.__widget.pack_start(_page.widget, True, True, 0) - _noteBook = self.__mainWindow.getNotebook() + _noteBook = self.__mainWindow.notebook _pageIndex = _noteBook.page_num(self.__widget) - self.__mainWindow.getPageList()[_pageIndex] = _page + self.__mainWindow.pageList[_pageIndex] = _page + def threadCanceled(self): - """def threadCanceled(self) + """threadCanceled() Sets the __children atribute to None This causes that the timeouts is ended. @@ -697,48 +721,52 @@ """ self.__children = None self.stopLoading() - _page_num = self.__mainWindow.getNotebook().page_num(self.widget) + _page_num = self.__mainWindow.notebook.page_num(self.widget) self.__mainWindow.removePage(_page_num) + def close(self): - """def close(self) - - Clos page canceling children + """close() + + Close page canceling children """ self.__children.cancel() + def clear(self): - """def clear(self) + """clear() clear vars """ pass - - def getWidget(self): - """def getWidget(self) + + def _getWidget(self): + """_getWidget() Return de main widget to show in the page """ return self.__widget - def getTitle(self): - """def getTitle(self) + def _getTitle(self): + """_getTitle() Return the title of the page, a gtk.Label objetc """ return self.__title - def getFiletype(self): - """def getFiletipe(self) + + def _getFiletype(self): + """_getFiletipe() Return the title of the page, a gtk.Label objetc """ return self.__filetype - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "Main widget showed in the pane") - title = property(getTitle, None, None, + title = property(_getTitle, None, None, "Page Title") - filetype = property(getFiletype, None, None, + filetype = property(_getFiletype, None, None, "Filetype: budget, basedata or durus") + class Page(object): """gui.Page: @@ -755,9 +783,9 @@ +-- object +-- Page Atributes: - "widget": Read. Notebook page Widget. (a gtk.VBox instance) - "budget": Read-Write. Budget to show in the page. (base.obra object) - "panes_list": Read. info list for create the panes + widget: Read. Notebook page Widget. (a gtk.VBox instance) + budget: Read-Write. Budget to show in the page. (base.obra object) + panes_list: Read. info list for create the panes ej: [ "v", pane1, pane2 ] , [ "h", pane1, pane2 ] [ "v", [ "h", pane1, pane2 ], [ "h", pane1, pane2 ] ] pane types: @@ -766,10 +794,10 @@ * "Measure": its creates a "Measure" objetc * "FileView": its creates a "FileView" objet * "CompanyView": its creates a "CompanyView" object - "title": Read. Notebook page title (gtk.Label object) - "activePathRecord": Read. The active path record - "previousPathRecord": Read. The previous path record - "posteriorPathRecord" Read. The posterior path record + title: Read. Notebook page title (gtk.Label object) + activePathRecord: Read. The active path record + previousPathRecord: Read. The previous path record + posteriorPathRecord Read. The posterior path record Methods: propagateMessageFrom sendMessageTo @@ -783,7 +811,7 @@ # TODO: * General budget properties (is better a dialog?) def __init__(self, mainWindow, budget, path_record=(0,)): - """def __init__(self, budget=None, active_code=None) + """__init__(mainWindow, budget, path_record=(0,)) mainWindow: MainWindow object budget: "base.Budget" object @@ -798,12 +826,12 @@ self.__active_path_record = () self.__history_back = [] self.__history_forward = [] - self.setBudget(budget) + self.budget = budget self._setActivePathRecord(path_record) self.__widget.show() def propagateMessageFrom(self, message, pane_path, arg=None): - """def propagateMessageFrom(self, message, pane_path, arg=None) + """propagateMessageFrom(message, pane_path, arg=None) message: string message * "change_active": change active code @@ -826,9 +854,9 @@ self._splitItem(pane_path, "h") elif message == "split v": self._splitItem(pane_path, "v") - + def sendMessageTo(self, pane, message, pane_path, arg=None): - """def sendMessageTo(self, pane, message, pane_path, arg=None) + """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 @@ -840,11 +868,11 @@ pane.runMessage(message, pane_path, arg) def close(self): - """def close(self) + """close() Close Page """ - _page_list = self.__mainWindow.getPageList() + _page_list = self.__mainWindow.pageList if self in _page_list: _page_num = _page_list.index(self) self.__mainWindow.removePage(_page_num) @@ -852,7 +880,7 @@ raise IndexError, _("The page is not in the page list") def clear(self): - """def clear(self) + """clear() Clear atributes """ @@ -865,8 +893,8 @@ del self.__active_path_record del self.__main_item - def getItem(self,pane_path): - """def getItem(self, pane_path) + def getItem(self, pane_path): + """getItem(pane_path) Return the item whith the path "pane_path", it can return a Paned instance or a View instance @@ -878,7 +906,7 @@ return _item.getItem(pane_path[1:]) def _setMainItem(self, item): - """_setMainItem(self,item) + """_setMainItem(item) Sets a new main item in the page """ @@ -891,13 +919,13 @@ self.__widget.pack_start(_main_widget, True, True, 0) def _splitItem(self, pane_path, orientation): - """_splitItem(self, pane_path, orientation) + """_splitItem(pane_path, orientation) Splits the item that is identifies by the pane_path and the orientation """ _item = self.getItem(pane_path) _parent = self.getItem(pane_path[:-1]) - _item.setPath(pane_path+ (0,)) + _item.path = pane_path + (0,) _item_clone0 = _item.getClone(pane_path + (0,)) _item_clone1 = _item.getClone(pane_path + (1,)) _paned = Paned(orientation, pane_path, _item_clone0, _item_clone1) @@ -905,9 +933,9 @@ _parent.setItem(pane_path[-1], [_paned]) else: self._setMainItem(_paned) - + def _closeItem(self, pane_path): - """_closeItem(self, pane_path) + """_closeItem(pane_path) Closes the item that is identifies by the pane_path """ @@ -938,7 +966,7 @@ pass def _itemsFactory(self, list_paned, pane_path=(0,)): - """def _itemsFactory(self, list_paned, pane_path(0,)) + """_itemsFactory(list_paned, pane_path(0,)) list_paned: list in "__panes_list" format [ "v" or "h", panel1_type, panel2_type] @@ -991,7 +1019,7 @@ return _item def _setActivePathRecord(self, path_record): - """def _setActivePathRecord(self, path_record) + """_setActivePathRecord(path_record) path_record: the active record path @@ -1004,8 +1032,9 @@ else: raise ValueError, utils.mapping(_("The budget does not have "\ "the path record: $1"), (str(path_record),)) + def _appendHistory(self, path): - """def _appendHistory(self, path)) + """_appendHistory(path)) path: the old active path record @@ -1028,15 +1057,15 @@ if len(self.__history_back) > 1000: self.__history_back.pop(0) - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """_getActivePathRecord() Return the Active Path Record """ return self.__active_path_record - def getPreviousPathRecord(self): - """def getPreviousPathRecord(self) + def _getPreviousPathRecord(self): + """_getPreviousPathRecord() Return the Previous Path Record """ @@ -1045,8 +1074,8 @@ else: return None - def getPosteriorPathRecord(self): - """def getPosteriorPathRecord(self) + def _getPosteriorPathRecord(self): + """_getPosteriorPathRecord() Return the Posterior Path Record """ @@ -1055,22 +1084,22 @@ else: return None - def getTitle(self): - """def getTitle(self) + def _getTitle(self): + """_getTitle() Return the page title, a gtk.Label objetc """ return self.__title - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() Return de main widget to show in the pane """ return self.__widget - def setBudget(self, budget): - """def setBudget(self, budget) + def _setBudget(self, budget): + """_setBudget(budget) budget: a base.Budget object @@ -1088,39 +1117,40 @@ self.__active_path_record)) _panes_list = self.__panes_list self.__main_item = self._itemsFactory(_panes_list) - _main_widget = self.__main_item.getWidget() + _main_widget = self.__main_item.widget _main_widget.show() self.__widget.pack_start(_main_widget, True, True, 0) - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """_getBudget() Return de budget, a "base.Budget" object. """ return self.__budget - def getPanesList(self): - """def getPanesList(self) + def _getPanesList(self): + """_getPanesList() Return the panes list, info list for create the panes. """ return self.__panes_list - - budget = property(getBudget, setBudget, None, + + budget = property(_getBudget, _setBudget, None, "Budget to show, base.Budget object") - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "Main widget showed in the pane") - title = property(getTitle, None, None, + title = property(_getTitle, None, None, "Page Title") - panes_list = property(getPanesList, None, None, + panes_list = property(_getPanesList, None, None, "Info list for create the panes") - activePathRecord = property(getActivePathRecord, None, None, + activePathRecord = property(_getActivePathRecord, None, None, "Active Path Record") - previousPathRecord = property(getPreviousPathRecord, None, None, + previousPathRecord = property(_getPreviousPathRecord, None, None, "Previous Active Path Record") - posteriorPathRecord = property(getPosteriorPathRecord, None, None, + posteriorPathRecord = property(_getPosteriorPathRecord, None, None, "Posterior Active Path Record") + class View(object): """gui.View: @@ -1128,49 +1158,35 @@ It creates a view to show the budget info Constructor: View(view_type, budget, wr_page, path, active_path_record) + view_type: the object type to show + * DecompositionList + * Description + * Measure + * Sheet + * FileView + * CompanyView + budget: the budget to show + wr_page: weak reference to the page where the view must be showed + path: the position or path of the view in the page notebook + active_path_record: the record path that must be showed Ancestry: +-- object - +-- Paned + +-- View Atributes: - "path": the tuple that identifies the view in the main notebook page - "widget": the main gtk widget to show in a view object, + path: Read-Write. The tuple that identifies the view in the main + notebook page + widget: Read. the main gtk widget to show in a view object, a gtk.VBox object - "__view_type": the object type to show - * DecompositionList - * Description - * Measure - * Sheet of conditions - * FileView - * CompanyView - "__wr_page": weak reference to the page where the view must be showed - "__budget": the budget to show - "__view ": the object to show: - * DecompositionList object - * Description object - * Measure object - * Sheet object - * FileView object - * Comapany View - "__connected": boolean value, True means that the View object sends and - receives signals from/to others views - "__connected_button": a button to switch __connected True or False Methods: - __init__(self) - getItem(self, path) - _closeItem(self, close_button) - _change_combo(self, combobox) - propagateMessgeFrom(self, message, path, arg=None) - runMessage(self, message, path, arg=None) - getWidget(self) - getPath(self) - setPath(self) - getClone(self, newpath) - clear(self) + getItem + propagateMessgeFrom + runMessage + getClone + clear """ + def __init__(self, view_type, budget, wr_page, path, active_path_record): - - """def __init__(self, view_type, budget, wr_page, path, - active_path_record) + """__init__(view_type, budget, wr_page, path, active_path_record) view_type: the object type to show * DecompositionList * Description @@ -1183,6 +1199,31 @@ path: the position or path of the view in the page notebook active_path_record: the record path that must be showed + self.__active_path_record: the record path that must be showed + self.__view_type: the object type to show + * DecompositionList + * Description + * Measure + * Sheet of conditions + * FileView + * CompanyView + self.__wr_page: weak reference to the page where the view must be + showed + self.__budget: the budget to show + self.__path: the position or path of the view in the page notebook + self.__connected: boolean value, True means that the View object sends + and receives signals from/to others views + self.__widget: main widget. a gtk.Toolbar? + self.__view: the object to show: + * DecompositionList object + * Description object + * Measure object + * Sheet object + * FileView object + * Comapany View + self.__connected_button: a button to switch self.__connected True or + False + Creates and shows a new view """ self.__active_path_record = active_path_record @@ -1217,13 +1258,15 @@ path, active_path_record) _combobox.set_active(0) _view_icon = gtk.Image() - _view_icon.set_from_file(globalVars.getAppPath("DECOMPOSITION-ICON")) + _view_icon.set_from_file(globalVars.getAppPath( + "DECOMPOSITION-ICON")) elif view_type == "RecordDescription": self.__view = Description(budget, weakref.ref(self), path, active_path_record) _combobox.set_active(1) _view_icon = gtk.Image() - _view_icon.set_from_file(globalVars.getAppPath("DESCRIPTION-ICON")) + _view_icon.set_from_file(globalVars.getAppPath( + "DESCRIPTION-ICON")) elif view_type == "Measure": self.__view = Measure(budget, weakref.ref(self), path, active_path_record) @@ -1248,7 +1291,6 @@ _combobox.set_active(5) _view_icon = gtk.Image() _view_icon.set_from_file(globalVars.getAppPath("SHEET-ICON")) - else: raise ValueError, _(utils.mapping("Invalid type of View: $1", view_type)) @@ -1290,22 +1332,22 @@ self.__widget.show() def getItem(self, path): - """def getItem(self, path) + """getItem(path) Return itself. """ return self def _closeItem(self, close_button): - """_closeItem(self, widget) + """_closeItem(close_button) Method connected to the "clicked" signal of the _close_button widget Send the "autoclose" message to the page to close this view """ - self.propagateMessageFrom( "autoclose", self.__path) + self.propagateMessageFrom("autoclose", self.__path) def _change_combo(self, combobox): - """_change_combo(self, combobox) + """_change_combo(combobox) Method connected to the "changed" signal of the _combobox widget It changes the view type to the type selected in the combobox @@ -1336,7 +1378,8 @@ self.__view = DecompositionList(_budget, _wr_page, _path, _path_record) - _view_icon.set_from_file(globalVars.getAppPath("DECOMPOSITION-ICON")) + _view_icon.set_from_file(globalVars.getAppPath( + "DECOMPOSITION-ICON")) self.__view_type = "DecompositionList" elif _index == 1: self.__view = Description(_budget, _wr_page, _path, @@ -1376,7 +1419,7 @@ _vbox.pack_start(self.__view.widget, True, True, 0) def _menu_view(self, widget): - """_menu_view(self, widget) + """_menu_view(widget) Method connected to the "clicked" signal of the __connected_button It shows a popup menu with some options @@ -1395,9 +1438,9 @@ _item_close.connect_object("activate", self._closeItem, None) _item_close.show() _menu_view.popup(None, None, None, 0, 0) - + def _split_view(self, orientation): - """_menu_view(self, orientation) + """_menu_view(orientation) orientation: orientation split, "h" or "v" @@ -1409,7 +1452,7 @@ self.propagateMessageFrom( "split " + orientation, self.__path) def _connected(self, widget): - """_connected(self, widget) + """_connected(widget) Method connected to the "clicked" signal of the _menu_button It changes the __connected atribute to True or False, if the @@ -1430,7 +1473,7 @@ self.__connected = True def propagateMessageFrom(self, message, path, arg=None): - """def propagateMessageFrom(self, message, path, arg=None) + """propagateMessageFrom(message, path, arg=None) message: string message path: tuple that represents the pane path which emits the message @@ -1442,7 +1485,7 @@ self.__wr_page().propagateMessageFrom(message, path, arg) def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -1460,22 +1503,22 @@ _path_record = arg self.__active_path_record = _path_record - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() Return de pane widget """ return self.__widget - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__view.path - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() set the tuple that identifies the pane in the notebook page """ @@ -1483,7 +1526,7 @@ self.__view.path = path def getClone(self, new_path): - """getClone(self, new_path) + """getClone(new_path) new_path: the path that identifies the clone view in the page @@ -1493,7 +1536,7 @@ new_path, self.__active_path_record) def clear(self): - """clear(self) + """clear() Clear the intance atributes """ @@ -1504,39 +1547,34 @@ del self.__view del self.__connected del self.__connected_button - - path = property(getPath, setPath, None, + + path = property(_getPath, _setPath, None, "path that identifies the item in the notebook page") - widget = property(getWidget, None, None, "View widget") + widget = property(_getWidget, None, None, "View widget") + class Paned(object): """gui.Paned: Description: - It creates and shows gtk.Hpaned or gtk.Vpaned to show in page budget + It creates and shows gtk.Hpaned or gtk.Vpaned to show in page budget Constructor: Paned(orientation, widget1, widget2) - orientation: The orientation of the pane separator, can be "v" or "h" - widget1: the top or left pane widget - widget2: the botton or right pane widget - Returns the newly created Paned instance + orientation: The orientation of the pane separator, can be "v" or + "h" + widget1: the top or left pane widget + widget2: the botton or right pane widget Ancestry: +-- object +-- Paned Atributes: - "widget": Pane widget("gtk.VPaned" or "gtk.HPaned" object) - "__orientation": The orientation of de gtk.Paned, can be "v" or "h" - "__items": list of items showed in the paned, its can be View or Paned - instances - "__path": the paned path in the page + widget: Read. Pane widget("gtk.VPaned" or "gtk.HPaned" object) + path: Read-Write. The paned path in the page Methods: - __init__(self) - __getitem__(self, item) - getClone(self, new_path) - getItem(self, path) - runMessage(self, messge, path, arg=None) - getWidget(self) - {get/set}Path + getClone + getItem + setItem + runMessage clear(self) """ # TODO: *control the position paned separator. Now is always 200 pixels @@ -1547,13 +1585,19 @@ # TODO: change with the same ascpect ratio def __init__(self, orientation, path, item1, item2): - """def __init__(self, oritentation, path, item1, item2) + """__init__(oritentation, path, item1, item2) orientation: The orientation of de gtk.Paned, can be "v" or "h" path: the paned path in the page item1: the top or left pane object item2: the bottom or right pane object + self.__orientation: The orientation of de gtk.Paned, can be "v" or "h" + self.__widget: Main widget, a gtk.VPaned o gtk.HPaned + self.__items: list of items showed in the paned, its can be View or + Paned instances + self.__path: the paned path in the page + Creates and shows a new gtk.Paned """ self.__orientation = orientation @@ -1574,7 +1618,7 @@ self.__path = path def __getitem__(self, item): - """__getitem__(self, item) + """__getitem__(item) Called to implement evaluation of self[key]. The accepted keys should be integers 0 or 1. @@ -1582,7 +1626,7 @@ return self.__items[item] def getClone(self, new_path): - """getClone(self, new_path) + """getClone(new_path) Return a clone Paned instance with the path new_path """ @@ -1591,7 +1635,7 @@ self.__items[1].getClone(new_path + (1,))) def getItem(self,path): - """def getItem(self, path) + """getItem(path) Return the item whith the specified path. """ @@ -1602,7 +1646,7 @@ return _item.getItem(path[1:]) def setItem(self, path, item_list): - """def setItem(self, path, item_list) + """setItem(path, item_list) Sets the first item in the item_list whith the especified path and remove the old item in this position. @@ -1620,7 +1664,7 @@ return False def runMessage(self, message, path, arg=None): - """def runMessage(self, message, page_path, arg=None) + """runMessage(message, page_path, arg=None) message: the message type "change_active": change the active record @@ -1634,37 +1678,42 @@ if not _item.path == path: _item.runMessage(message, path, arg) - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() Return de gtk.Paned widget """ return self.__widget - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() Return de Paned path in the notebook page """ return self.__path - - def setPath(self, path): - """def setPath(self) + + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path self.__items[0].path = path + (0,) self.__items[1].path = path + (1,) - + def clear(self): + """clear() + + Delete atributes + """ del self.__widget del self.__orientation del self.__items del self.__path - widget = property(getWidget, None, None, "gtk.Paned widget") - path = property(getPath, setPath, None, "Pane path in the notebook page") + widget = property(_getWidget, None, None, "gtk.Paned widget") + path = property(_getPath, _setPath, None, "Pane path in the notebook page") + class TreeView(object): """gui.Treeviev: @@ -1691,17 +1740,15 @@ +-- object +-- TreeView Atributes: - "columns": list of columns (gtk.TreeViewColumn isntances) + columns: list of columns (gtk.TreeViewColumn objects) Methods: - __init__(self) - __getitem__(self, item) - createColumn(self, args) - createTextBaseColumn(self,args) - createBaseColumn(self,args) + createColumn + createTextBaseColumn + createBaseColumn """ def __init__(self, args): - """__init__(self, args) + """__init__(args) args: list of tuples, the tuple items are: 0.type: @@ -1724,7 +1771,7 @@ self.columns.append(self.createColumn(("END",))) def createColumn(self, args): - """createColumn(self, args) + """createColumn(args) args: tuple with the args 0.type: @@ -1754,7 +1801,7 @@ _index_column.pack_start(_text_index_cell, True) _index_column.pack_start(_pixbuf_index_cell, True) _index_column.set_cell_data_func(_text_index_cell, - self.colorCell, + self._colorCell, [gtk.gdk.color_parse(globalVars.color["INDEX-UNEVEN"]), gtk.gdk.color_parse(globalVars.color["INDEX-EVEN"])]) return _index_column @@ -1783,16 +1830,16 @@ _column.pack_start(_type_cell2, True) _column.add_attribute(_type_cell2, 'text', args[5]) _column.set_cell_data_func(_type_cell1, - self.colorCell, args[4]) + self._colorCell, args[4]) _column.set_cell_data_func(_type_cell2, - self.colorCell, args[4]) + self._colorCell, args[4]) return _column elif args[0] == "PIXBUF": _column = self.createBaseColumn(args) _type_cell1 = gtk.CellRendererPixbuf() _column.pack_start(_type_cell1, True) _column.set_cell_data_func(_type_cell1, - self.colorCell, args[4]) + self._colorCell, args[4]) return _column elif args[0] == "END": _end_column = gtk.TreeViewColumn() @@ -1804,8 +1851,8 @@ return _end_column return None - def createTextBaseColumn(self,args): - """createTextBaseColumn(self,args) + def createTextBaseColumn(self, args): + """createTextBaseColumn(args) args: tuple with the args 0.type: @@ -1825,11 +1872,11 @@ _cell = gtk.CellRendererText() _cell.set_property('foreground-gdk', args[3]) _column.pack_start(_cell, True) - _column.set_cell_data_func(_cell, self.colorCell, args[4]) + _column.set_cell_data_func(_cell, self._colorCell, args[4]) return _column, _cell - def createBaseColumn(self,args): - """createBaseColumn(self,args) + def createBaseColumn(self, args): + """createBaseColumn(args) args: tuple with the args 0.type: @@ -1855,78 +1902,72 @@ _column.set_resizable(True) return _column + class DecompositionList(TreeView): """gui.DecompositionList: Description: Class to show a budget Decomposition List Constructor: - DecompositionList(budget, page, path) + DecompositionList(budget, page, path, path_record=(0,)) budget: budget showed ("base.Budget" object) page: weak reference from Page instance which creates this class path: tuple that represents the view path in the Page + path_record: the record path that must be showed Returns the newly created DecompositionList instance Ancestry: +-- object +-- TreeView +-- DecompositionList Atributes: - "budget": Budget to show, base.obra instance. - "widget or __scrolled_window": Window that contains the table, - (gtk.ScrolledWindow) - "path": Pane page identifier - "page": weak reference from Page instance which creates this class - "__active_color": background color of the active cell, a - gtk.gdk.Color object - "__chapter_background_colors": background colors of the Code - column cells when there is a chapter record, - list of gtk.gdk.Color objects [even cell, uneven cell] - "__methond_message": Method to send messages to the page - "__liststore": list model which store the list data - (gtk.ListStore object) - "__treeview": widget for displaying decomposition lists (gtk.TreeView) - "__index_column": Index column (gtk.TreeViewColumn object) - "__code_column": Record code column (gtk.TreeViewColumn) - "__unit_column": Unit of measure column (gtk.TreeViewColumn) - "__description_column": record's short description column - (gtk.TreeViewColumn) - "__measure_column": Measure column (gtk.TreeViewColumn) - "__price_column": Price column (gtk.TreeViewColumn) - "__amount_column": Amount column(gtk.TreeViewColumn) - "__end_column": End empty column (gtk.TreeViewColumn) - "__treeselection": active selection - "__selection_control": state of the selection control (True/False) - "__cursor": cursor position in the table + budget: Read. Budget to show, base.obra object. + widget: Read. Window that contains the table, gtk.ScrolledWindow + path: Read-Write. Pane page identifier + page: Read-Write. weak ref from Page object which creates this class + active_path_record: Read. Active path record Methods: - __init__(self, budget) - treeviewCursorChanged(self, treeview) - treeviewClickedEvent(self, widget, event) - treeviewKeyPressEvent(self, widget, event) - moveCursor(self, treeview, step, count) - controlSelection(self, selection) - selectAll(self, column) - setColumnsHeaders(self) - setListstoreValues(self, puntero, treeiter=None) - colorCell(self, column, cell_renderer, tree_model, iter, lcolor) - _claculateAmount(self, row_path, tree_model) - showParentRecord(self, column) - showMessageRecord(self, camino,_code): - showRowRecord(self, treeview, path, column) - runMessage(self, messagem path, arg=None) - _clear(self) - getWidget(self) - {get/set}Path - {get/seg}Page - getBudget(self) - getActivePathRecord(self) + runMessage """ def __init__(self, budget, page, path, path_record=(0,)): - """def __init__(self, budget, page, path) + """__init__(budget, page, path, path_record=(0,)) budget: budget showed ("base.Budget" object) page: weak reference from Page instance which creates this class path: tuple that represents the path of the List in the Page + path_record: the record path that must be showed + + self.__budget: budget showed ("base.Budget" object) + self.__page: weak reference from Page instance which creates this class + self.__path: tuple that represents the path of the List in the Page + self.__liststore: list model which store the list data + (gtk.ListStore object) + self.__active_path_record: the record path that must be showed + self.__treeview: widget for displaying decomposition lists + (gtk.TreeView) + self.__scrolled_window: widget to contain the treeview object + self.__chapter_background_colors: background colors of the Code + column cells when there is a chapter record, + list of gtk.gdk.Color objects [even cell, uneven cell] + self.__chapter_background_colors + self.__index_column: Index column (gtk.TreeViewColumn object) + self.__code_column: Record code column (gtk.TreeViewColumn) + self.__type_column: Record Type column (gtk.TreeViewColumn) + self.__unit_column: Unit of measure column (gtk.TreeViewColumn) + self.__description_column: record's short description column + (gtk.TreeViewColumn) + self.__measure_column: Measure column (gtk.TreeViewColumn) + self.__price_column: Price column (gtk.TreeViewColumn) + self.__amount_column: Amount column(gtk.TreeViewColumn) + self.__end_column: End empty column (gtk.TreeViewColumn) + self.__chapter_icon: a gtk.gdk.pixbuf + self.__unit_icon: a gtk.gdk.pixbuf + self.__material_icon: a gtk.gdk.pixbuf + self.__machinery_icon: a gtk.gdk.pixbuf + self.__labourforce_icon: a gtk.gdk.pixbuf + self.__treeselection: active selection + self.__selection_control: state of the selection control (True/False) + self.__cursor: cursor position in the table Sets the init atributes Creates the init list values in self.__liststore from the budget @@ -1949,10 +1990,10 @@ #, int, int, str, str, str, str, str,str ) if path_record is None: - print _("DecompositionList.__init__: Record path can not be None") + print _("Record path can not be None") path_record = (0,) self.__active_path_record = path_record - self.setListstoreValues(self.__active_path_record) + self._setListstoreValues(self.__active_path_record) # Treeview self.__treeview = gtk.TreeView(self.__liststore) self.__treeview.set_enable_search(False) @@ -1973,25 +2014,25 @@ gtk.gdk.color_parse(globalVars.color["CHAPTER-UNEVEN"]), gtk.gdk.color_parse(globalVars.color["CHAPTER-EVEN"])] super(DecompositionList,self).__init__( - [("INDEX",self.selectAll,42), - ("CALCULATEDTEXT", self.showParentRecord, + [("INDEX",self._selectAll,42), + ("CALCULATEDTEXT", self._showParentRecord, gtk.Label("A"*10).size_request()[0] +10, _text_color, _background_color), - ("PIXBUF", self.showParentRecord, 26, _text_color, + ("PIXBUF", self._showParentRecord, 26, _text_color, _background_color), - ("CALCULATEDTEXT", self.showParentRecord, + ("CALCULATEDTEXT", self._showParentRecord, gtk.Label(_("a"*4)).size_request()[0] +10, _text_color, _background_color), - ("CALCULATEDTEXT", self.showParentRecord, + ("CALCULATEDTEXT", self._showParentRecord, gtk.Label("a"*30).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.showParentRecord, + ("CALCULATED", self._showParentRecord, gtk.Label("a"*10).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.showParentRecord, + ("CALCULATED", self._showParentRecord, gtk.Label("a"*10).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.showParentRecord, + ("CALCULATED", self._showParentRecord, gtk.Label("a"*10).size_request()[0] +10, gtk.gdk.color_parse(globalVars.color["CALCULATED-TEXT"]), _background_color), @@ -2011,18 +2052,18 @@ self.__treeview.append_column(self.__code_column) # Type column self.__treeview.append_column(self.__type_column) - self.chapter_icon = gtk.gdk.pixbuf_new_from_file( + self.__chapter_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("CHAPTER-ICON")) - self.unit_icon = gtk.gdk.pixbuf_new_from_file( + self.__unit_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("UNIT-ICON") ) - self.material_icon = gtk.gdk.pixbuf_new_from_file( + self.__material_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("MATERIAL-ICON") ) - self.machinery_icon = gtk.gdk.pixbuf_new_from_file( + self.__machinery_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("MACHINERY-ICON")) - self.labourforce_icon = gtk.gdk.pixbuf_new_from_file( + self.__labourforce_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("LABOURFORCE-ICON")) self.__type_column.get_cell_renderers()[0].set_property("pixbuf", - self.labourforce_icon) + self.__labourforce_icon) # Unit column self.__treeview.append_column(self.__unit_column) @@ -2037,15 +2078,16 @@ # End Column self.__treeview.append_column(self.__end_column) # Connect - self.__treeview.connect("row-activated", self.showRowRecord) - self.__treeview.connect("move-cursor", self.moveCursor) - self.__treeview.connect("key-press-event", self.treeviewKeyPressEvent) - self.__treeview.connect("button-press-event", self.treeviewClickedEvent) - self.__treeview.connect("cursor-changed", self.treeviewCursorChanged) + self.__treeview.connect("row-activated", self._showRowRecord) + self.__treeview.connect("move-cursor", self._moveCursor) + self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent) + self.__treeview.connect("button-press-event", + self._treeviewClickedEvent) + self.__treeview.connect("cursor-changed", self._treeviewCursorChanged) # control selection self.__treeselection = self.__treeview.get_selection() self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE) - self.__treeselection.set_select_function(self.controlSelection) + self.__treeselection.set_select_function(self._controlSelection) self.__selection_control = True if len(self.__liststore) > 0: self.__treeview.set_cursor_on_cell((0,),self.__unit_column, @@ -2053,11 +2095,11 @@ self.__treeview.grab_focus() self.__cursor = self.__treeview.get_cursor() # Show - self.setColumnsHeaders() + self._setColumnsHeaders() self.__scrolled_window.show() - def treeviewCursorChanged(self, treeview): - """def treeviewCursorChanged(self, treeview) + def _treeviewCursorChanged(self, treeview): + """_treeviewCursorChanged(treeview) treeview: treewiew widget Method connected to "cursor-changed" signal @@ -2070,9 +2112,9 @@ if event is None or event.type != gtk.gdk.BUTTON_RELEASE: if not _column is self.__index_column: self.__cursor = treeview.get_cursor() - - def treeviewClickedEvent(self, widget, event): - """def treeviewClickedEvent(self, widget, event) + + def _treeviewClickedEvent(self, widget, event): + """_treeviewClickedEvent(widget, event) widget: treewiew widget event: clicked event @@ -2097,8 +2139,8 @@ self.__cursor[0] == _path_cursor return False - def treeviewKeyPressEvent(self, widget, event): - """def treeviewKeyPressEvent(self, widget, event) + def _treeviewKeyPressEvent(self, widget, event): + """_treeviewKeyPressEvent(widget, event) widget: treewiew widget event: Key Press event @@ -2120,8 +2162,8 @@ return True return False - def moveCursor(self, treeview, step, count): - """def treeviewKeyPressEvent(self, widget, event) + def _moveCursor(self, treeview, step, count): + """_moveCursor(treeview, step, count) treeview: the treeview that received the signal step: the movement step size @@ -2136,8 +2178,8 @@ """ return False - def controlSelection(self, selection): - """def controlSelection(self, selection) + def _controlSelection(self, selection): + """_controlSelection(selection) selection: treeselection @@ -2161,8 +2203,8 @@ self.__selection_control = True return False - def selectAll(self, column): - """def selectAll(self, column) + def _selectAll(self, column): + """_selectAll(column) column: index column Method connected to "clicked" event in the index column @@ -2181,8 +2223,8 @@ self.__treeselection.unselect_all() self.__selection_control = True - def setColumnsHeaders(self): - """def setColumnsHeaders(self) + def _setColumnsHeaders(self): + """_setColumnsHeaders() Sets the headers column values """ @@ -2218,9 +2260,8 @@ self.__amount_column.set_title( _("Amount") + chr(10) + "[" + str(_amount) + "]") - - def setListstoreValues(self, path_record): - """def setListstoreValues(self, path_record) + def _setListstoreValues(self, path_record): + """_setListstoreValues(path_record) path_record: Record path in the budget Sets the liststore record values from a path record @@ -2248,8 +2289,8 @@ ] _treeiter = self.__liststore.append(_values) - def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): - """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) + def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): + """_colorCell(column, cell_renderer, tree_model, iter, lcolor) column: the gtk.TreeViewColumn in the treeview cell_renderer: a gtk.CellRenderer @@ -2313,18 +2354,18 @@ _type = tree_model[_row_path][0].recordType.type _subtype = tree_model[_row_path][0].recordType.subtype if _hierarchy == 1: - cell_renderer.set_property("pixbuf",self.chapter_icon) + cell_renderer.set_property("pixbuf",self.__chapter_icon) else: if _type == 0: - cell_renderer.set_property("pixbuf",self.unit_icon) + cell_renderer.set_property("pixbuf",self.__unit_icon) elif _type == 1: cell_renderer.set_property("pixbuf", - self.labourforce_icon) + self.__labourforce_icon) elif _type == 2: cell_renderer.set_property("pixbuf", - self.machinery_icon) + self.__machinery_icon) else: - cell_renderer.set_property("pixbuf",self.material_icon) + cell_renderer.set_property("pixbuf",self.__material_icon) if self.__treeview.get_cursor() == (_row_path,column): cell_renderer.set_property('cell-background-gdk', gtk.gdk.color_parse(globalVars.color["ACTIVE"])) @@ -2332,8 +2373,8 @@ cell_renderer.set_property('cell-background-gdk', lcolor[_number % 2]) - def showParentRecord(self, column): - """def showParentRecord(self, column) + def _showParentRecord(self, column): + """_showParentRecord(column) column: the column that is clicked Method connected to "clicked" event of many columns @@ -2348,16 +2389,16 @@ _path_record = self.__active_path_record[:-1] _parent = self.__active_path_record[-1] self.__active_path_record = _path_record - self.setColumnsHeaders() - self.setListstoreValues(self.__active_path_record) + self._setColumnsHeaders() + self._setListstoreValues(self.__active_path_record) arg = ( _path_record ) _page = self.__page() _page.propagateMessageFrom("change_active", self.__path, arg) self.__treeview.set_cursor(_parent, self.__cursor[1]) self.__cursor = self.__treeview.get_cursor() - def showMessageRecord(self, record_path): - """def showMessageRecord(self, record_path) + def _showMessageRecord(self, record_path): + """_showMessageRecord(record_path) record_path: the path of the record to show Method connected to "change_active" message @@ -2365,12 +2406,12 @@ """ _budget = self.__budget self.__active_path_record = record_path - self.setColumnsHeaders() - self.setListstoreValues(self.__active_path_record) + self._setColumnsHeaders() + self._setListstoreValues(self.__active_path_record) self.__treeview.set_cursor((0,)) - def showRowRecord(self, treeview, treeview_path, column): - """def showRowRecord(self, treeview, treeview_path, column) + def _showRowRecord(self, treeview, treeview_path, column): + """_showRowRecord(treeview, treeview_path, column) treeview: treview to show treeview_path: the path of the record to show @@ -2394,8 +2435,8 @@ if self.__budget.hasPath(_path_record): # if this record path is valid self.__active_path_record = _path_record - self.setColumnsHeaders() - self.setListstoreValues(self.__active_path_record) + self._setColumnsHeaders() + self._setListstoreValues(self.__active_path_record) self.__treeview.set_cursor((0,)) _arg = ( _path_record ) _page = self.__page() @@ -2403,7 +2444,7 @@ _arg ) def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -2418,151 +2459,144 @@ if message == "change_active": if _budget.hasPath(arg): _path_record = arg - self.showMessageRecord( _path_record) + self._showMessageRecord( _path_record) elif message == "clear": self._clear() def _clear(self): - """def _clear(self) - - it deletes the __budget value - this would not be necessary if there were not circular references, - which are pending to fix + """_clear() + + it deletes the __budget reference """ del self.__budget - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__scrolled_window - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__path - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path - def getPage(self): - """def getPage(self) + def _getPage(self): + """_getPage() return the Page """ return self.__page - def setPage(self,page): - """def setPage(self) + def _setPage(self,page): + """_setPage() set the Page """ self.__page = page - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """_getBudget() return the Budget objet """ return self.__budget - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """_getActivePathRecord() return the Active Path Record """ return self.__active_path_record - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "Pane configuration list") - path = property(getPath, setPath, None, + path = property(_getPath, _setPath, None, "path that identifie the item in the page notebook") - page = property(getPage, setPage, None, + page = property(_getPage, _setPage, None, "weak reference from Page instance which creates this class") - budget = property(getBudget, None, None, + budget = property(_getBudget, None, None, "Budget object") - active_path_record = property(getActivePathRecord, None, None, + active_path_record = property(_getActivePathRecord, None, None, "Active path record") + class Measure(TreeView): """gui.Measure: Description: Class to show a Measure List Constructor: - Measure(budget, page, path) + Measure(budget, page, path, path_record=(0,) budget: budget showed ("base.Budget" object) page: weak reference from Page instance which creates this class path: tuple that represents the path of the List in the Page - Returns the newly created DecompositionList instance + path_record: path of the active record in the budget Ancestry: +-- object +-- TreeView +-- DecompositionList Atributes: - "budget": Budget to show, base.obra instance. - "__active_path_record": path of the active record in the budget - "widget or __scrolled_window": Window that contains the table, - (gtk.ScrolledWindow) - "path": Pane page identifier - "page": weak reference from Page instance which creates this class - "__active_color": The background color of the active cell as a - gtk.gdk.Color object - "__chapter_background_colors": The background colors of the Code - column cells when there is a chapter record - as a list of gtk.gdk.Color objects [even cell, uneven cell] - "__methond_message": Method to send messages to the page - "__liststore": list model which store the list data - (gtk.ListStore object) - "__treeview": widget for displaying decomposition lists (gtk.TreeView) - "__index_column": Index column (gtk.TreeViewColumn object) - "__code_column": Record code column (gtk.TreeViewColumn) - "__unit_column": Unit of measure column (gtk.TreeViewColumn) - "__description_column": record's short description column - (gtk.TreeViewColumn) - "__measure_column": Measure column (gtk.TreeViewColumn) - "__price_column": Price column (gtk.TreeViewColumn) - "__amount_column": Amount column(gtk.TreeViewColumn) - "__end_column": End empty column (gtk.TreeViewColumn) - "__treeselection": active selection - "__selection_control": state of the selection control (True/False) - "__cursor": Situation of the cursor in the table + budget: Read. Budget to show, base.obra instance. + widget: Read. Window that contains the table, gtk.ScrolledWindow + path: Read-Write. Pane page identifier + page: Read-Write. weak reference from Page instance which creates + this class + active_path_record: Read. Path of the active record in the budget Methods: - __init__(self, budget, page, path, path_record=(0,)) - setListstoreValues(self, path_record) - setColumnsHeaders(self) - controlSelection(self, selection) - showMessageRecord(self, record_path) - treeviewCursorChanged(self, treeview) - moveCursor(self, treeview, step, count) - treeviewClickedEvent(self, widget, event) - treeviewKeyPressEvent(self, widget, event) - runMessage(self, message, path, arg=None) - selectAll(self, column) - colorCell(self, column, cell_renderer, tree_model, iter, lcolor) - _clear(self) - getWidget(self) - {get/set}Path - {get/set}Page - getBudget(self) - getActivePathRecord(self) + runMessage """ def __init__(self, budget, page, path, path_record=(0,)): - """def __init__(self, budget, page, path, path_record=(0,)) + """__init__(budget, page, path, path_record=(0,)) budget: budget: budget showed ("base.Budget" object) page: weak reference from Page instance which creates this class path: tuple that represents the path of the List in the Page path_record: path of the active record in the budget + self.__budget: budget showed ("base.Budget" object) + self.__page: weak reference from Page instance which creates this class + self.__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.__liststore: list model which store the list data + (gtk.ListStore object) + self.__treeview: widget to display decomposition lists + (gtk.TreeView) + self.__scrolled_window: widget to scroll the treeview + gtk.ScrolledWindow() + self.__chapter_background_colors: The background colors of the Code + column cells when there is a chapter record + as a list of gtk.gdk.Color objects [even cell, uneven cell] + self.__index_column: Index column (gtk.TreeViewColumn object) + self.__linetype_column: Linetype column (gtk.TreeViewColumn object) + self.__comment_column: Comment column (gtk.TreeViewColumn) + self.__unit_column: Unit column (gtk.TreeViewColumn) + self.__length_column: Legth column (gtk.TreeViewColumn) + self.__width_column: With column (gtk.TreeViewColumn) + self.__height_column: Height column (gtk.TreeViewColumn) + self.__formula_column: Formula column (gtk.TreeViewColumn) + self.__parcial_column: Parcial column (gtk.TreeViewColumn) + self.__subtotal_column: Subtotal column (gtk.TreeViewColumn) + self.__end_column: End empty column (gtk.TreeViewColumn + self.__calculatedline_icon: gtk.gdk.pixbuf + self.__normalline_icon: gtk.gdk.pixbuf + self.__parcialline_icon: gtk.gdk.pixbuf + self.__acumulatedline_icon: gtk.gdk.pixbuf + self.__treeselection: active selection + self.__selection_control: state of the selection control (True/False) + self.__cursor: Situation of the cursor in the table + Sets the init atributes Creates the init list values in self.__liststore from the budget showing the top record from the record with path path_record @@ -2584,7 +2618,7 @@ self.__active_path_record = path_record # ListStore self.__liststore = gtk.ListStore(object) - self.setListstoreValues(self.__active_path_record) + self._setListstoreValues(self.__active_path_record) # Treeview self.__treeview = gtk.TreeView(self.__liststore) self.__treeview.set_enable_search(False) @@ -2606,35 +2640,36 @@ gtk.gdk.color_parse(globalVars.color["CHAPTER-UNEVEN"]), gtk.gdk.color_parse(globalVars.color["CHAPTER-EVEN"])] super(Measure,self).__init__( - [("INDEX",self.selectAll,42), - ("PIXBUF", self.passMethod, + [("INDEX",self._selectAll,42), + ("PIXBUF", self._passMethod, gtk.Label("A"*4).size_request()[0] +10, _text_color, _background_color), - ("CALCULATEDTEXT", self.passMethod, + ("CALCULATEDTEXT", self._passMethod, gtk.Label("A"*12).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.passMethod, + ("CALCULATED", self._passMethod, gtk.Label("A"*5).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.passMethod, + ("CALCULATED", self._passMethod, gtk.Label("A"*7).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.passMethod, + ("CALCULATED", self._passMethod, gtk.Label("A"*7).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.passMethod, + ("CALCULATED", self._passMethod, gtk.Label("A"*7).size_request()[0] +10, _text_color, _background_color), - ("CALCULATEDTEXT", self.passMethod, + ("CALCULATEDTEXT", self._passMethod, gtk.Label("A"*12).size_request()[0] +10, _text_color, _background_color), - ("CALCULATED", self.passMethod, + ("CALCULATED", self._passMethod, gtk.Label("A"*7).size_request()[0] +10, _calculated_text, _background_color), - ("CALCULATED", self.passMethod, + ("CALCULATED", self._passMethod, gtk.Label("A"*7).size_request()[0] +10, _calculated_text, _background_color), ]) + # Colums self.__index_column = self.columns[0] self.__linetype_column = self.columns[1] self.__comment_column = self.columns[2] @@ -2650,13 +2685,13 @@ self.__treeview.append_column(self.__index_column) # Linetype column self.__treeview.append_column(self.__linetype_column) - self.calculatedline_icon = gtk.gdk.pixbuf_new_from_file( + self.__calculatedline_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("CALCULATEDLINE-ICON")) - self.normalline_icon = gtk.gdk.pixbuf_new_from_file( + self.__normalline_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("NORMALLINE-ICON") ) - self.parcialline_icon = gtk.gdk.pixbuf_new_from_file( + self.__parcialline_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("PARCIALLINE-ICON") ) - self.acumulatedline_icon = gtk.gdk.pixbuf_new_from_file( + self.__acumulatedline_icon = gtk.gdk.pixbuf_new_from_file( globalVars.getAppPath("ACUMULATEDLINE-ICON")) # Comment column self.__treeview.append_column(self.__comment_column) @@ -2677,28 +2712,35 @@ # End Column self.__treeview.append_column(self.__end_column) # Connect - self.__treeview.connect("move-cursor", self.moveCursor) - self.__treeview.connect("key-press-event", self.treeviewKeyPressEvent) - self.__treeview.connect("button-press-event", self.treeviewClickedEvent) - self.__treeview.connect("cursor-changed", self.treeviewCursorChanged) + self.__treeview.connect("move-cursor", self._moveCursor) + self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent) + self.__treeview.connect("button-press-event", + self._treeviewClickedEvent) + self.__treeview.connect("cursor-changed", self._treeviewCursorChanged) # control selection self.__treeselection = self.__treeview.get_selection() self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE) - self.__treeselection.set_select_function(self.controlSelection) + self.__treeselection.set_select_function(self._controlSelection) self.__selection_control = True self.__treeview.set_cursor_on_cell((1,), self.columns[1], self.columns[1].get_cell_renderers()[0],True) self.__treeview.grab_focus() self.__cursor = self.__treeview.get_cursor() # Show - self.setColumnsHeaders() + self._setColumnsHeaders() self.__scrolled_window.show() - - def passMethod(self, args): + + def _passMethod(self, column): + """_passMethod(column) + + column: the column that is clicked + Method connected to "clicked" event of many columns + Do nothing + """ pass - def setListstoreValues(self, path_record): - """def setListstoreValues(self, path_record) + def _setListstoreValues(self, path_record): + """_setListstoreValues(path_record) path_record: Record path in the budget Sets the liststore record values from a path record @@ -2712,21 +2754,14 @@ if isinstance(_measure, base.Measure): _lines = _measure.lines for _line in _lines: - _values = [ - _line, -## _line.type, -## _line.comment, -## _line.units, -## _line.length, -## _line.width, -## _line.height - ] + _values = [ _line ] _treeiter = self.__liststore.append(_values) else: raise ValueError, utils.mapping(_("measure must be a Measure "\ "object. Type: $1"), (type(_measure),)) - def setColumnsHeaders(self): - """def setColumnsHeaders(self) + + def _setColumnsHeaders(self): + """_setColumnsHeaders() Sets the headers column values """ @@ -2743,8 +2778,9 @@ self.columns[7].set_title(_("Formula")) self.columns[8].set_title(_("Parcial\n[%s]" % _total_str)) self.columns[9].set_title(_("Subtotal")) - def controlSelection(self, selection): - """def controlSelection(self, selection) + + def _controlSelection(self, selection): + """_controlSelection(selection) selection: treeselection @@ -2768,8 +2804,8 @@ self.__selection_control = True return False - def showMessageRecord(self, record_path): - """def showMessageRecord(self, record_path) + def _showMessageRecord(self, record_path): + """_showMessageRecord(record_path) record_path: the path of the record to show Method connected to "change_active" message @@ -2777,12 +2813,12 @@ """ _budget = self.__budget self.__active_path_record = record_path - self.setColumnsHeaders() - self.setListstoreValues(self.__active_path_record) + self._setColumnsHeaders() + self._setListstoreValues(self.__active_path_record) self.__treeview.set_cursor((0,)) - def treeviewCursorChanged(self, treeview): - """def treeviewCursorChanged(self, treeview) + def _treeviewCursorChanged(self, treeview): + """_treeviewCursorChanged(treeview) treeview: treewiew widget Method connected to "cursor-changed" signal @@ -2796,8 +2832,8 @@ if not _column is self.__index_column: self.__cursor = treeview.get_cursor() - def moveCursor(self, treeview, step, count): - """def treeviewKeyPressEvent(self, widget, event) + def _moveCursor(self, treeview, step, count): + """moveCursor(treeview, step, count) treeview: the treeview that received the signal step: the movement step size @@ -2812,8 +2848,8 @@ """ return False - def treeviewClickedEvent(self, widget, event): - """def treeviewClickedEvent(self, widget, event) + def _treeviewClickedEvent(self, widget, event): + """_treeviewClickedEvent(widget, event) widget: treewiew widget event: clicked event @@ -2838,8 +2874,8 @@ self.__cursor[0] == _path_cursor return False - def treeviewKeyPressEvent(self, widget, event): - """def treeviewKeyPressEvent(self, widget, event) + def _treeviewKeyPressEvent(self, widget, event): + """_treeviewKeyPressEvent(widget, event) widget: treewiew widget event: Key Press event @@ -2862,7 +2898,7 @@ return False def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -2877,12 +2913,12 @@ if message == "change_active": if _budget.hasPath(arg): _path_record = arg - self.showMessageRecord( _path_record) + self._showMessageRecord( _path_record) elif message == "clear": self._clear() - def selectAll(self, column): - """def selectAll(self, column) + def _selectAll(self, column): + """_selectAll(column) column: index column Method connected to "clicked" event in the index column @@ -2901,8 +2937,8 @@ self.__treeselection.unselect_all() self.__selection_control = True - def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): - """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) + def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): + """_colorCell(column, cell_renderer, tree_model, iter, lcolor) column: the gtk.TreeViewColumn in the treeview cell_renderer: a gtk.CellRenderer @@ -2936,15 +2972,15 @@ _measure = tree_model[_row_path][0] _type = _measure.lineType if _type == 0: - cell_renderer.set_property("pixbuf",self.normalline_icon) + cell_renderer.set_property("pixbuf",self.__normalline_icon) elif _type == 1: - cell_renderer.set_property("pixbuf",self.parcialline_icon) + cell_renderer.set_property("pixbuf",self.__parcialline_icon) elif _type == 2: cell_renderer.set_property("pixbuf", - self.acumulatedline_icon) + self.__acumulatedline_icon) else: #elif _type == 3: cell_renderer.set_property("pixbuf", - self.calculatedline_icon) + self.__calculatedline_icon) elif column is self.__comment_column: _measure = tree_model[_row_path][0] @@ -3020,73 +3056,73 @@ lcolor[_number % 2]) def _clear(self): - """def _clear(self) + """_clear() it deletes the __budget value - this would not be necessary if there were not circular references, - which are pending to fix """ del self.__budget - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__scrolled_window - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__path - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path - def getPage(self): - """def getPage(self) + + def _getPage(self): + """_getPage() return the Page """ return self.__page - def setPage(self,page): - """def setPage(self) + def _setPage(self,page): + """_setPage() set the Page """ self.__page = page - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """_getBudget() return the Budget objet """ return self.__budget - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """getActivePathRecord() return the Active Path Record """ return self.__active_path_record - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "Pane configuration list") - path = property(getPath, setPath, None, + path = property(_getPath, _setPath, None, "Path that identifies the item in the page notebook") - page = property(getPage, setPage, None, + page = property(_getPage, _setPage, None, "Weak reference from Page instance which creates this class") - budget = property(getBudget, None, None, + budget = property(_getBudget, None, None, "Budget object") - active_path_record = property(getActivePathRecord, None, None, + active_path_record = property(_getActivePathRecord, None, None, "Active Code") + class Description(object): """gui.Description @@ -3094,40 +3130,39 @@ Class to show a description text of a record in a pane Constructor: Description(budget, code) - budget: budget - code: code record + budget: base.Budget object + code: record code Ancestry: +-- object +-- Description Atributes: - "widget": the main widget (gtk.ScrolledWindow object) - "path": the tuple that identifies the pane in the notebook page - TODO - "budget": The budget (base.obra objetc) - "active_code": The active code of the record - "__textbuffer": The textbuffer of the textview that contain - the record text. - "__label": The gtk.label with the title of the pane + widget: the main widget (gtk.ScrolledWindow object) + path: the tuple that identifies the pane in the notebook page + budget: The budget (base.obra objetc) + active_path_record: The active path record Methods: - __init__(self, budget, code) - setActiveCode(self, code) - runMessage(self, message, nt, arg=None) - _clear(self) - getWidget(self) - {get/set}Path - {get/seg}Page - getBudget(self) - getActviCode(self) + runMessage """ # TODO: make standar: "DecompositonList and Description" + def __init__(self, budget, page, path, path_record=(0,)): - """def __init__(self, budget, page, path, path_record=(0,)) + """__init__(budget, page, path, path_record=(0,)) budget: the budget (base.obra object) page: weak reference from Page instance which creates this class path: the path position of the description in the page path_record: the path of the active record + self.__budget: the budget (base.obra object) + self.__page: weak reference from Page instance which creates this class + self.__path: the path position of the description in the page + self.__active_path_recordthe path of the active record + + self.__textbuffer: The textbuffer of the textview that contain + the record text. + self.__label: The gtk.label with the title of the pane + self.__widget: the main pane widget, a gtk.ScrolledWindow() + Creates an shows the scroledwindow that contain the description text of the record to be showed in a pane. """ @@ -3163,8 +3198,8 @@ self.__widget = _scrollwindow - def setActivePathRecord(self, path_record): - """def setActivePathRecord(self, path_record)) + def _setActivePathRecord(self, path_record): + """_setActivePathRecord(path_record)) path_record: active path record Set the new path code to show its description text. @@ -3178,7 +3213,7 @@ self.__textbuffer.set_text(_text) def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -3192,12 +3227,12 @@ _budget = self.__budget if message == "change_active": if _budget.hasPath(arg): - self.setActivePathRecord(arg) + self._setActivePathRecord(arg) elif message == "clear": self._clear() def _clear(self): - """def _clear(self) + """_clear() Delete all instance atributes """ @@ -3208,66 +3243,67 @@ del self.__textbuffer del self.__label - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__widget - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__path - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path - def getPage(self): - """def getPage(self) + def _getPage(self): + """_getPage() return the weak reference from Page instance """ return self.__page - def setPage(self, page): - """def setPage(self) + def _setPage(self, page): + """_setPage() set the weak reference from Page instance """ self.__page = page - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """_getBudget() return the budget object """ return self.__budget - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """_getActivePathRecord() return the Active Path Record """ return self.__active_path_record - path = property(getPath, setPath, None, + path = property(_getPath, _setPath, None, "Path that identifie the item in the page notebook") - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "The main widget (gtk.ScrolledWindow)") - page = property(getPage, setPage, None, + page = property(_getPage, _setPage, None, "Weak reference from Page instance which creates this class") - budget = property(getBudget, None, None, + budget = property(_getBudget, None, None, "Budget object") - active_path_record = property(getActivePathRecord, None, None, + active_path_record = property(_getActivePathRecord, None, None, "Active Path Record") + class Sheet(object): """gui.Sheet @@ -3281,43 +3317,38 @@ +-- object +-- Sheet Atributes: - "widget": the main widget (gtk.ScrolledWindow object) - "path": the tuple that identifies the pane in the notebook page - "budget": The budget (base.obra objetc) - "active_path_record": The active path record - "page": weak reference from Page instance which creates this class - - "__textbuffer": The textbuffer of the textview that contain - the record text. - "__label": The gtk.label with the title of the pane - "__field_liststore": the field liststore - "__field_treeview": the field treeview - "__field_selection": the field selected in field treview - "__section_liststore": the section liststore - "__section_treeview": the section treeview - "__section_selection": the section selected in the section treeview + widget: the main widget (gtk.VBox() object) + path: the tuple that identifies the pane in the notebook page + page: weak reference from Page instance which creates this class + budget: The budget (base.obra objetc) + active_path_record: The active path record Methods: - __init__(self, budget, code) - setFields(self) - setSection(self) - setText(self) - field_controlSelection(self, selection) - section_controlSelection(self, selection) - runMessage(self, message, nt, arg=None) - _clear(self) - getWidget(self) - {get/set}Path - {get/set}Page - getBudget(self) - getActviPathRecord(self) + runMessage """ + def __init__(self, budget, page, path, path_record=(0,)): - """def __init__(self, budget, page, path, path_record=(0,)) + """__init__(budget, page, path, path_record=(0,)) budget: the budget (base.obra object) page: weak reference from Page instance which creates this class path: the path position of the description in the page path_record: the path of the active record + + self.__budget: the budget (base.obra object) + self.__page: weak reference from Page instance which creates this class + self.__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 + self.__field_liststore: the field liststore + self.__field_treeview: the field treeview + self.__field_selection: the field selected in field treview + self.__section_liststore: the section liststore + self.__section_treeview: the section treeview + self.__section_selection: the section selected in the section treeview + self.__textbuffer: The textbuffer of the textview that contain + the record text. + self.__widget: main widget, a gtk.VBox() + Creates an shows the scroledwindow that contain the description text of the record to be showed in a pane. """ @@ -3326,27 +3357,23 @@ self.__path = path self.__active_path_record = path_record _budget = budget - _main_box = gtk.VBox() - self.__label = gtk.Label(utils.mapping(_("Sheet of Conditions of the "\ "record $1"), (self.__budget.getCode( self.__active_path_record),))) self.__label.set_alignment(0, 0) self.__label.show() - _frame = gtk.Frame() _frame.set_shadow_type(gtk.SHADOW_IN) _frame_box = gtk.VBox() _list_box = gtk.HBox() - self.__field_liststore = gtk.ListStore(str, str) self.__field_treeview = gtk.TreeView(self.__field_liststore) _field_treeselection = self.__field_treeview.get_selection() _field_treeselection.set_mode(gtk.SELECTION_SINGLE) self.__field_selection = None _field_treeselection.set_select_function( - self.field_controlSelection) + self._field_controlSelection) self.__field_treeview.show() _fieldcode_cell = gtk.CellRendererText() _field_column = gtk.TreeViewColumn(_("Field")) @@ -3361,14 +3388,13 @@ gtk.POLICY_AUTOMATIC) _field_scrollwindow.add(self.__field_treeview) _field_scrollwindow.show() - self.__section_liststore = gtk.ListStore(str, str) self.__section_treeview = gtk.TreeView(self.__section_liststore) _section_treeselection = self.__section_treeview.get_selection() _section_treeselection.set_mode(gtk.SELECTION_SINGLE) self.__section_selection = None _section_treeselection.set_select_function( - self.section_controlSelection) + self._section_controlSelection) self.__section_treeview.show() _sectioncode_cell = gtk.CellRendererText() _section_column = gtk.TreeViewColumn(_("Section")) @@ -3398,29 +3424,24 @@ _hbox = gtk.HBox() _hbox.pack_start(_textview, True, True, 5) _hbox.show() - _frame_box.pack_start(self.__label, False, False, 5) _frame_box.pack_start(_list_box, False, False, 5) _frame_box.show() _frame.add(_frame_box) _frame.show() _main_box.pack_start(_frame, False) - - _vbox = gtk.VBox() _vbox.pack_start(_hbox, True, True, 5) _vbox.show() _main_box.pack_start(_scrollwindow, True, True, 5) _main_box.show() - _scrollwindow.add_with_viewport(_vbox) _scrollwindow.show() self.__widget = _main_box - - self.setFields() - - def setFields(self): - """setFields(self) + self._setFields() + + def _setFields(self): + """_setFields() Set the fields items in the field treeview """ @@ -3435,8 +3456,8 @@ _treeselection = self.__field_treeview.get_selection() _treeselection.select_path(0) - def setSection(self): - """setSection(self) + def _setSection(self): + """_setSection() Set the section items in the section treeview """ @@ -3452,8 +3473,8 @@ _treeselection = self.__section_treeview.get_selection() _treeselection.select_path(0) - def setText(self): - """setText(self) + def _setText(self): + """_setText() Set the text in the textview """ @@ -3469,8 +3490,8 @@ else: self.__textbuffer.set_text("") - def field_controlSelection(self, selection): - """def controlSelection(self, selection) + def _field_controlSelection(self, selection): + """_controlSelection(selection) selection: treeselection @@ -3486,11 +3507,11 @@ """ _treeiter = self.__field_liststore.get_iter(selection) self.__field_selection = self.__field_liststore.get_value(_treeiter, 0) - self.setSection() + self._setSection() return True - def section_controlSelection(self, selection): - """def controlSelection(self, selection) + def _section_controlSelection(self, selection): + """_section_controlSelection(selection) selection: treeselection @@ -3506,11 +3527,11 @@ """ _treeiter = self.__section_liststore.get_iter(selection) self.__section_selection = self.__section_liststore.get_value(_treeiter, 0) - self.setText() + self._setText() return True - def setActivePathRecord(self, path_record): - """def setActivePathRecord(self, path_record)) + def _setActivePathRecord(self, path_record): + """_setActivePathRecord(path_record)) path_record: active path record @@ -3526,10 +3547,10 @@ _code = _budget.getCode(self.__active_path_record) self.__label.set_text(utils.mapping(_("Sheet2 of Conditions of the "\ "record $1"), (_code,))) - self.setFields() + self._setFields() def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -3543,12 +3564,12 @@ _budget = self.__budget if message == "change_active": if _budget.hasPath(arg): - self.setActivePathRecord(arg) + self._setActivePathRecord(arg) elif message == "clear": self._clear() def _clear(self): - """def _clear(self) + """_clear() Deletes all the instance atributes """ @@ -3568,104 +3589,106 @@ del self.__section_treeview del self.__section_selection - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__widget - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__page - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path - def getPage(self): - """def getPage(self) + def _getPage(self): + """_getPage() return the weak reference from Page instance """ return self.__page - def setPage(self, page): - """def setPage(self) + def _setPage(self, page): + """_setPage() set the weak reference from Page instance """ self.__page = page - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """_getBudget() return the budget object """ return self.__budget - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """_getActivePathRecord() return the Active Path Record """ return self.__active_path_record - path = property(getPath, setPath, None, + path = property(_getPath, _setPath, None, "Path that identifie the item in the page notebook") - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "Lista de configuracion de vistas") - page = property(getPage, setPage, None, + page = property(_getPage, _setPage, None, "Weak reference from Page instance which creates this class") - budget = property(getBudget, None, None, + budget = property(_getBudget, None, None, "Budget object") - active_path_record = property(getActivePathRecord, None, None, + active_path_record = property(_getActivePathRecord, None, None, "Active Path Record") + class FileView(object): """gui.FileView Description: Class to show the file icons of a record in a pane Constructor: - Description(budget, code) - budget: budget - code: code record + Description(budget, page, path, path_record=(0,)) + budget: the budget (base.obra object) + page: weak reference from Page instance which creates this class + path: the path position of the description in the page + path_record: the path of the active record Ancestry: +-- object - +-- Description + +-- FileView Atributes: - "widget": the main widget (gtk.ScrolledWindow object) - "__icon_box": the box that contains the icon + widget: the main widget (gtk.ScrolledWindow object) "path": the tuple that identifies the pane in the notebook page "budget": The budget (base.obra objetc) "active_code": The active code of the record Methods: - __init__(self, budget, code) - setActiveCode(self, code) - runMessage(self, message, nt, arg=None) - _clear(self) - getWidget(self) - {get/set}Path - {get/seg}Page - getBudget(self) - getActviCode(self) + runMessage """ def __init__(self, budget, page, path, path_record=(0,)): - """def __init__(self, budget, page, path, path_record=(0,)) + """__init__(budget, page, path, path_record=(0,)) budget: the budget (base.obra object) page: weak reference from Page instance which creates this class path: the path position of the description in the page path_record: the path of the active record + self.__budget: the budget (base.obra object) + self.__page: weak reference from Page instance which creates this class + self.__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 + self.__icon_box: the box that contains the icon + self.__widget: main widget, a gtk.ScrolledWindow + Creates an shows the scroledwindow that contain icon files of the record to be showed in a pane. """ @@ -3678,18 +3701,17 @@ _record = self.__budget.getRecord(self.__budget.getCode( self.__active_path_record)) - self.__icon_box = self.getIconBox(_record) + self.__icon_box = self._getIconBox(_record) _scrollwindow = gtk.ScrolledWindow() _scrollwindow.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER) - self.__icon_box.show() _scrollwindow.add_with_viewport(self.__icon_box) _scrollwindow.show() self.__widget = _scrollwindow - def getIconBox(self, record): - """getIconBox(self, record) + def _getIconBox(self, record): + """_getIconBox(record) record: the active record object @@ -3721,7 +3743,7 @@ _image_icon.show() _event_box.add(_image_icon) _box.pack_start(_event_box, False, False, 5) - _event_box.connect("button-press-event", self.launchFile, + _event_box.connect("button-press-event", self._launchFile, "image", _file_path) _event_box.show() @@ -3736,7 +3758,7 @@ _dxf_icon.show() _event_box.add(_dxf_icon) _box.pack_start(_event_box, False, False, 5) - _event_box.connect("button-press-event", self.launchFile, + _event_box.connect("button-press-event", self._launchFile, "dxf", _file_path) _event_box.show() _label_event_box = gtk.EventBox() @@ -3751,8 +3773,8 @@ _frame.add(_hbox) return _frame - def launchFile(self, widget, event, kind, file_path): - """launchFile(self, widget, event, kind, file_path) + def _launchFile(self, widget, event, kind, file_path): + """_launchFile(widget, event, kind, file_path) widget: the widget that emit the signal event: the event that emit the signal @@ -3765,8 +3787,8 @@ if event.type is gtk.gdk._2BUTTON_PRESS: openwith.launch_file(kind, file_path) - def setActivePathRecord(self, path_record): - """def setActivePathRecord(self, path_record)) + def _setActivePathRecord(self, path_record): + """_setActivePathRecord(path_record)) path_record: active path record Set the new path code to show its description text. @@ -3776,12 +3798,12 @@ _code = _budget.getCode(self.__active_path_record) _record = self.__budget.getRecord(_code) self.__icon_box.destroy() - self.__icon_box = self.getIconBox(_record) + self.__icon_box = self._getIconBox(_record) self.__icon_box.show() self.__widget.add_with_viewport(self.__icon_box) def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -3795,191 +3817,123 @@ _budget = self.__budget if message == "change_active": if _budget.hasPath(arg): - self.setActivePathRecord(arg) + self._setActivePathRecord(arg) elif message == "clear": self._clear() def _clear(self): - """def _clear(self) + """_clear() Delete all instance atributes """ - del self.__hbox del self.__widget del self.__path del self.__budget del self.__active_code - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__widget - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__path - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path - def getPage(self): - """def getPage(self) + def _getPage(self): + """_getPage() return the weak reference from Page instance """ return self.__page - def setPage(self, page): - """def setPage(self) + def _setPage(self, page): + """setPage() set the weak reference from Page instance """ self.__page = page - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """getBudget() return the budget object """ return self.__budget - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """_getActivePathRecord() return the Active Path Record """ return self.__active_path_record - path = property(getPath, setPath, None, + path = property(_getPath, _setPath, None, "Path that identifie the item in the page notebook") - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "The main widget (gtk.ScrolledWindow)") - page = property(getPage, setPage, None, + page = property(_getPage, _setPage, None, "Weak reference from Page instance which creates this class") - budget = property(getBudget, None, None, + budget = property(_getBudget, None, None, "Budget object") - active_path_record = property(getActivePathRecord, None, None, + active_path_record = property(_getActivePathRecord, None, None, "Active Path Record") -class TextWindow(object): - """gui.TextWindow - - Description: - Class to show a description text of a record in a new gtk window - Constructor: - TextWindow(code, text) - code: code of the record - text: description text of the record - Ancestry: - +-- object - +-- TextWindow - Atributes: - Methods: - __init__(self, code, text) - main(self) - destroy(self, widget) - """ - - def __init__(self, code, text): - """def __init__(self, code, text) - - code: code of the record - text: description text of the record - Creates an shows the window. - """ - _window = gtk.Window(gtk.WINDOW_TOPLEVEL) - _window.set_resizable(True) - _window.set_default_size(700, 300) - _window.set_title(utils.mapping(_("$1 text"), (code,))) - _window.set_border_width(0) - _box1 = gtk.VBox(False, 0) - _window.add(_box1) - _box1.show() - _sw = gtk.ScrolledWindow() - _sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - _textview = gtk.TextView() - _textview.set_wrap_mode(gtk.WRAP_WORD) - _textbuffer = _textview.get_buffer() - _sw.add(_textview) - _sw.show() - _textview.show() - _box1.pack_start(_sw) - _textbuffer.set_text(text) - _window.connect("destroy", self.destroy) - _window.show() - - def main(self): - """def main(self) - - Starts the GTK+ event processing loop. - """ - gtk.main() - - def destroy(self, widget): - """destroy(self, widget) - widget: the widget where the event is emitted from - Method connected to "destroy" signal of window widget - This signal is emited when the method connected to "delete_event" - signal returns True or when the program call the destroy() method of - the gtk.Window widget. - The window is closed and the GTK+ event processing loop is ended. - """ - gtk.main_quit() - class CompanyView(object): """gui.CompanyView: Description: Class to show the company records of a budget Constructor: - CompanyView(budget, page, path) + CompanyView(budget, page, path, path_record=(0,)) budget: budget showed ("base.Budget" object) page: weak reference from Page instance which creates this class path: tuple that represents the path of the List in the Page - Returns the newly created CompanyView instance + path_record: path of the active record in the budget Ancestry: +-- object +-- CompanyView Atributes: - "budget": Budget to show, base.obra instance. - "active_path_record" - "widget": Window that contains the main widget, - (gtk.ScrolledWindow) - "path": Pane page identifier - "page": weak reference from Page instance which creates this class - "__methond_message": Method to send messages to the page + active_path_record: Read. Path of the active record in the budget + widget: Read. Window that contains the main widget, a gtk.HPaned + path: Read-Write. Pane page identifier + page: Read-Write. weak reference from Page instance which creates this class + budget: Read. Budget to show, base.budget instance. Methods: - __init__(self, budget, page, path, path_record=(0,)) - runMessage(self, message, path, arg=None) - _clear(self) - getWidget(self) - {get/set}Path - {get/set}Page - getBudget(self) - getActivePathRecord(self) + runMessage """ def __init__(self, budget, page, path, path_record=(0,)): - """def __init__(self, budget, page, path, path_record=(0,)) + """__init__(budget, page, path, path_record=(0,)) budget: budget: budget showed ("base.Budget" object) page: weak reference from Page instance which creates this class path: tuple that represents the path of the List in the Page path_record: path of the active record in the budget - Sets the init atributes - Creates the - + self.__selection: + self.__budget: budget: budget showed ("base.Budget" object) + self.__page: weak reference from Page instance which creates this class + self.__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.HPaned + self.__treestore: to store companys data + self.__option_View: OptionView object + + Creates an shows the scroledwindow that contain the company data. """ self.__selection = None # Seting init args @@ -3989,60 +3943,63 @@ self.__page = page self.__path = path self.__active_path_record = path_record - # HVox - self.__hbox = gtk.HPaned() - self.__hbox.set_position(230) + # main widget + self.__widget = gtk.HPaned() + self.__widget.set_position(230) # TreeStore self.__treestore = gtk.TreeStore(str, str) - self.setTreeStoreValues() + self._setTreeStoreValues() # Select Treeview - self.__select_treeview = gtk.TreeView(self.__treestore) - self.__select_treeview.set_enable_search(False) - self.__select_treeview.set_reorderable(False) - self.__select_treeview.set_headers_visible(False) - self.__select_treeview.show() + _select_treeview = gtk.TreeView(self.__treestore) + _select_treeview.set_enable_search(False) + _select_treeview.set_reorderable(False) + _select_treeview.set_headers_visible(False) + _select_treeview.show() # Scrolled_window - self.__scrolled_window = gtk.ScrolledWindow() - self.__scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, + _scrolled_window = gtk.ScrolledWindow() + _scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self.__scrolled_window.add(self.__select_treeview) + _scrolled_window.add(_select_treeview) # colors _text_color = gtk.gdk.color_parse(globalVars.color["TEXT"]) _background_color = [ gtk.gdk.color_parse(globalVars.color["UNEVEN"]), gtk.gdk.color_parse(globalVars.color["EVEN"])] - self.__code_column = gtk.TreeViewColumn() - self.__code_column.set_clickable(True) - self.__code_column.set_fixed_width(200) + _code_column = gtk.TreeViewColumn() + _code_column.set_clickable(True) + _code_column.set_fixed_width(200) _code_cell = gtk.CellRendererText() _code_cell.set_property('foreground-gdk', _text_color) - self.__code_column.pack_start(_code_cell, True) - self.__code_column.add_attribute(_code_cell, 'text', 0) + _code_column.pack_start(_code_cell, True) + _code_column.add_attribute(_code_cell, 'text', 0) _summary_cell = gtk.CellRendererText() _summary_cell.set_property('foreground-gdk', _text_color) - self.__code_column.pack_start(_summary_cell, True) - self.__code_column.add_attribute(_summary_cell, 'text', 1) + _code_column.pack_start(_summary_cell, True) + _code_column.add_attribute(_summary_cell, 'text', 1) # Index column - self.__select_treeview.append_column(self.__code_column) + _select_treeview.append_column(_code_column) # control selection - self.__treeselection = self.__select_treeview.get_selection() - self.__treeselection.set_mode(gtk.SELECTION_SINGLE) - self.__treeselection.set_select_function(self.controlSelection) + _treeselection = _select_treeview.get_selection() + _treeselection.set_mode(gtk.SELECTION_SINGLE) + _treeselection.set_select_function(self._controlSelection) # Show - self.setColumnsHeaders() - self.__scrolled_window.show() + _scrolled_window.show() # Option View self.__option_View = OptionView("") # Selection - self.__select_treeview.set_cursor((0,), None, False) - self.__select_treeview.grab_focus() + _select_treeview.set_cursor((0,), None, False) + _select_treeview.grab_focus() # - self.__hbox.add1(self.__scrolled_window) - self.__hbox.add2(self.__option_View.widget) - self.__hbox.show() - self.__widget = self.__hbox - - def setOptions(self, type): + self.__widget.add1(_scrolled_window) + self.__widget.add2(self.__option_View.widget) + self.__widget.show() + + def _setOptions(self, type): + """_setOptions(type) + + type: "company" or "office" + Sets the Options in the OptionView + """ if type == "company": _options = [("code", _("Code"), "string", _("""Code that define the company""")), @@ -4057,7 +4014,7 @@ ("email", _("Email"), "string", _("""Company email""")), ] - self.__option_View.setOptions(_options) + self.__option_View.options = _options elif type == "office": _options = [("type", _("Type"), "string", _("""Type of Office: @@ -4078,16 +4035,14 @@ ("contact person", _("Contact person"), "string", _("Contact persons in the office")), ] - self.__option_View.setOptions(_options) + self.__option_View.options = _options else: print _("Unknow Option Type") - def setOptionValues(self, company_key): - self.__option_View.setValues(_values) - - def setTreeStoreValues(self): - """def setListstoreValues(self) - - Sets the treestore values from the budget + + def _setTreeStoreValues(self): + """_setTreeStoreValues() + + Sets the treestore values from the budget """ _budget = self.__budget _company_keys = _budget.getCompanyKeys() @@ -4101,21 +4056,9 @@ _values = [_office.officeType, _office.subname] self.__treestore.append(_treeiter, _values) - def setColumnsHeaders(self): - """def setColumnsHeaders(self) - - Sets the headers column values - """ - #self.columns[1].set_title(_("Type")) # Σ parcial Σ total - #self.columns[2].set_title(_("Comment")) - #self.columns[3].set_title(_("N")) - #self.columns[4].set_title(_("Length")) - #self.columns[5].set_title(_("Width")) - #self.columns[6].set_title(_("Height")) - pass - - def controlSelection(self, selection): - """def controlSelection(self, selection) + + def _controlSelection(self, selection): + """_controlSelection(selection) selection: selection @@ -4143,13 +4086,13 @@ _values = _office.values if not self.__selection == _selection: self.__selection = _selection - self.setOptions(_selection) - self.__option_View.setValues(_values) + self.options = _selection + self.__option_View.values = _values return True - def showMessageRecord(self, record_path): - """def showMessageRecord(self, record_path) + def _showMessageRecord(self, record_path): + """_showMessageRecord(record_path) record_path: the path of the record to show Method connected to "change_active" message @@ -4158,7 +4101,7 @@ self.__active_path_record = record_path def runMessage(self, message, path, arg=None): - """def runMessage(self, message, path, arg=None) + """runMessage(message, path, arg=None) message: the message type "change_active": change the active record @@ -4173,13 +4116,13 @@ if message == "change_active": if _budget.hasPath(arg): _path_record = arg - self.showMessageRecord( _path_record) + self._showMessageRecord( _path_record) pass elif message == "clear": self._clear() - def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): - """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) + def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): + """_colorCell(column, cell_renderer, tree_model, iter, lcolor) column: the gtk.TreeViewColumn in the treeview cell_renderer: a gtk.CellRenderer @@ -4217,71 +4160,70 @@ lcolor[_number % 2]) def _clear(self): - """def _clear(self) - - it deletes the __budget value - this would not be necessary if there were not circular references, - which are pending to fix + """_clear() + + it deletes the self.__budget value """ del self.__budget - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__widget - def getPath(self): - """def getPath(self) + def _getPath(self): + """_getPath() return the tuple that identifies the pane in the notebook page """ return self.__path - def setPath(self, path): - """def setPath(self) + def _setPath(self, path): + """_setPath() sets the tuple that identifies the pane in the notebook page """ self.__path = path - def getPage(self): - """def getPage(self) + + def _getPage(self): + """_getPage() return the Page """ return self.__page - def setPage(self,page): - """def setPage(self) + def _setPage(self,page): + """_setPage() set the Page """ self.__page = page - def getBudget(self): - """def getBudget(self) + def _getBudget(self): + """_getBudget() return the Budget objet """ return self.__budget - def getActivePathRecord(self): - """def getActivePathRecord(self) + def _getActivePathRecord(self): + """_getActivePathRecord() return the Active Path Record """ return self.__active_path_record - active_path_record = property(getActivePathRecord, None, None, + active_path_record = property(_getActivePathRecord, None, None, "Active path record") - widget = property(getWidget, None, None, + widget = property(_getWidget, None, None, "main widget") - path = property(getPath, setPath, None, + path = property(_getPath, _setPath, None, "Path that identifies the item in the page notebook") - page = property(getPage, setPage, None, + page = property(_getPage, _setPage, None, "Weak reference from Page instance which creates this class") - budget = property(getBudget, None, None, + budget = property(_getBudget, None, None, "Budget object") @@ -4299,32 +4241,33 @@ +-- object +-- OptionView Atributes: - "__liststore" - "__treeview" - "__option_column" - "__value_column" - "__type_column" - "__treeselection" - "__widget": Main windget - "__option_list" - "__option_dict" - "__description_label" - "option_types" - "widget": __widget + widget: Read. Main widget + options: Write + values: Write Methods: - __init__(self, option_list) - createColumn(self, args) - createTextBaseColumn(self,args) - createBaseColumn(self,args) """ def __init__(self, option_list): - """__init__(self, option_list) - + """__init__(option_list) + + self.__option_dict: + {"option key" : ["option name", "value", "option type", + "option_description"]} + self.__option_list: option keys list + self.__option_types: valid option types list + self.__liststore: gtk.ListStore + self.__treeview: gtk.TreeView + self.__option_column: option column + self.__value_column: value column + self.__type_column: type column + self.__description_label: gtk.Label + self.__widget: Main widget + + Creates an shows the widget that contain the option data. """ self.__option_dict = {} self.__option_list = [] - self.option_types = {"boolean" : _("Boolean"), + self.__option_types = {"boolean" : _("Boolean"), "integer": _("Integer"), "string": _("Text"), "color" : _("Color"), @@ -4358,7 +4301,7 @@ _option_cell = gtk.CellRendererText() _option_cell.set_property('foreground-gdk', _text_color) self.__option_column.pack_start(_option_cell, True) - self.__option_column.set_cell_data_func(_option_cell, self.colorCell, + self.__option_column.set_cell_data_func(_option_cell, self._colorCell, _background_color) self.__option_column.set_title(_("Option name")) self.__option_column.add_attribute(_option_cell, 'text', 1) @@ -4371,7 +4314,7 @@ _value_cell = gtk.CellRendererText() _value_cell.set_property('foreground-gdk', _text_color) self.__value_column.pack_start(_value_cell, True) - self.__value_column.set_cell_data_func(_value_cell, self.colorCell, + self.__value_column.set_cell_data_func(_value_cell, self._colorCell, _background_color) self.__value_column.set_title(_("Value")) self.__value_column.add_attribute(_value_cell, 'text', 2) @@ -4384,7 +4327,7 @@ _type_cell = gtk.CellRendererText() _type_cell.set_property('foreground-gdk', _text_color) self.__type_column.pack_start(_type_cell, True) - self.__type_column.set_cell_data_func(_type_cell, self.colorCell, + self.__type_column.set_cell_data_func(_type_cell, self._colorCell, _background_color) self.__type_column.set_title(_("Type")) self.__treeview.append_column(self.__type_column) @@ -4397,12 +4340,13 @@ _end_column.pack_start(_end_cell, True) self.__treeview.append_column(_end_column) # Connect - self.__treeview.connect("key-press-event", self.treeviewKeyPressEvent) - self.__treeview.connect("button-press-event", self.treeviewClickedEvent) + self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent) + self.__treeview.connect("button-press-event", + self._treeviewClickedEvent) # control selection - self.__treeselection = self.__treeview.get_selection() - self.__treeselection.set_mode(gtk.SELECTION_MULTIPLE) - self.__treeselection.set_select_function(self.controlSelection) + _treeselection = self.__treeview.get_selection() + _treeselection.set_mode(gtk.SELECTION_MULTIPLE) + _treeselection.set_select_function(self._controlSelection) # labels _frame = gtk.Frame() _frame.set_shadow_type(gtk.SHADOW_OUT) @@ -4431,8 +4375,8 @@ _vbox.show() self.__widget = _vbox - def treeviewKeyPressEvent(self, widget, event): - """def treeviewKeyPressEvent(self, widget, event) + def _treeviewKeyPressEvent(self, widget, event): + """_treeviewKeyPressEvent(widget, event) widget: treewiew widget event: Key Press event @@ -4457,8 +4401,8 @@ self.__description_label.set_text(_description) return False - def treeviewClickedEvent(self, widget, event): - """def treeviewClickedEvent(self, widget, event) + def _treeviewClickedEvent(self, widget, event): + """_treeviewClickedEvent(widget, event) widget: treewiew widget event: clicked event @@ -4484,9 +4428,9 @@ self.__treeview.grab_focus() return True return True - - def controlSelection(self, selection): - """def controlSelection(self, selection) + + def _controlSelection(self, selection): + """_controlSelection(selection) selection: treeselection @@ -4501,9 +4445,8 @@ """ return False - - def colorCell(self, column, cell_renderer, tree_model, iter, lcolor): - """def colorCell(self, column, cell_renderer, tree_model, iter, lcolor) + def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor): + """_colorCell(column, cell_renderer, tree_model, iter, lcolor) column: the gtk.TreeViewColumn in the treeview cell_renderer: a gtk.CellRenderer @@ -4536,11 +4479,11 @@ cell_renderer.set_property('cell-background-gdk', lcolor[_number % 2]) if column is self.__type_column: - _type = self.option_types[tree_model[_row_path][3]] + _type = self.__option_types[tree_model[_row_path][3]] cell_renderer.set_property('text', _type) - def setOptions(self, option_list): - """setOptions(self, option_list) + def _setOptions(self, option_list): + """_setOptions(option_list) option_list: list of tuples (option, option name, type) @@ -4566,7 +4509,7 @@ if isinstance(_option_key, str) and \ (isinstance(_option_name, str) or\ isinstance(_option_name, unicode))and \ - _option_type in self.option_types.keys(): + _option_type in self.__option_types.keys(): self.__liststore.append([_option_key, _option_name, "", _option_type, _option_description]) self.__option_dict[_option_key] = [_option_name, "", @@ -4578,9 +4521,9 @@ print _("Option must be a tuple with 4 items") else: print _("Option list must be a list") - return - def setValues(self, values): - """setValues(self, values) + + def _setValues(self, values): + """_setValues(values) values: dictionary {option : value} @@ -4654,11 +4597,16 @@ _description = self.__liststore[_cursor_path][4] self.__description_label.set_text(_description) - def getWidget(self): - """def getWidget(self) + def _getWidget(self): + """_getWidget() return the main widget (gtk.ScrolledWindow) """ return self.__widget - widget = property(getWidget, None, None, - "main widget") \ No newline at end of file + + widget = property(_getWidget, None, None, + "main widget") + values = property(None, _setValues, None, + "values") + options = property(None, _setOptions, None, + "options") \ No newline at end of file diff -r 0359329a1c26 -r 55df0b15706b Gtk/importFiebdc.py --- a/Gtk/importFiebdc.py Thu Nov 11 23:22:35 2010 +0100 +++ b/Gtk/importFiebdc.py Wed Nov 17 21:05:56 2010 +0100 @@ -111,9 +111,9 @@ _emptyPage = gui.EmptyPage(self.__mainWindow, self.__readFileMethod, self.__budget, self.__filename, self.__cancelMethod, self.__filetype) - self.__mainWindow.getNotebook().append_page(_emptyPage.widget, + self.__mainWindow.notebook.append_page(_emptyPage.widget, _emptyPage.title) - self.__mainWindow.getPageList().append(_emptyPage) + self.__mainWindow.pageList.append(_emptyPage) _emptyPage.run() def _openFile(self, filename):