Mercurial > pyarq-presupuestos
diff Gtk/gui.py @ 25:189f8274aecd
gui. switch navigation menu on switch page
author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
---|---|
date | Mon, 20 May 2019 13:18:33 +0200 |
parents | 65e7ae0d0e63 |
children | 16f91684686b |
line wrap: on
line diff
--- a/Gtk/gui.py Fri May 03 11:11:00 2019 +0200 +++ b/Gtk/gui.py Mon May 20 13:18:33 2019 +0200 @@ -77,7 +77,8 @@ _pixbufIcons = [] for _icon in _icons: if os.path.exists(globalVars.getAppPath(_icon)): - _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(globalVars.getAppPath(_icon)) + _icon_file = globalVars.getAppPath(_icon) + _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(_icon_file) _pixbufIcons.append(_pixbufIcon) else: print(utils.mapping(_("The icon file does not exist. '$1'"), @@ -104,7 +105,8 @@ Constructor: App() Ancestry: - +-- Gtk.Application https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html + +-- Gtk.Application + https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html +-- App Atributes: Methods: @@ -141,7 +143,7 @@ Shows new appplication windows. """ _mainWindow = MainWindow(self, self.filesToOpen ) - _mainWindow.window.present_with_time(GLib.get_monotonic_time() / 1000) + _mainWindow.window.present_with_time(Gtk.get_current_event_time()) def do_startup(self): """do_startup() @@ -192,7 +194,8 @@ if win_menu: _win_menu = Gio.Menu() _win_submenu_file = Gio.Menu.new() - _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"), "win.ImportFiebdc") + _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"), + "win.ImportFiebdc") _import_fiebdc.set_icon(Gio.Icon.new_for_string("document-open")) _win_submenu_file.append_item(_import_fiebdc) @@ -223,7 +226,7 @@ Shows new appplication windows. """ _mainWindow = MainWindow(self, []) - _mainWindow.window.present_with_time(GLib.get_monotonic_time() / 1000) + _mainWindow.window.present_with_time(Gtk.get_current_event_time()) def _on_about(self, action, param): """_on_about(action, param) @@ -240,7 +243,7 @@ _aboutDialog.set_license_type(Gtk.License(3)) _aboutDialog.set_comments(base.comments) _aboutDialog.connect("response", self._on_close_aboutdialog) - _aboutDialog.present_with_time(GLib.get_monotonic_time() / 1000) + _aboutDialog.present_with_time(Gtk.get_current_event_time()) def _on_close_aboutdialog(self, action, parameter): """on_close_aboutdialog(action, param) @@ -388,7 +391,8 @@ # Import Fiebdc _gtk_image = Gtk.Image.new_from_icon_name("document-open",1) _gtk_image.show() - _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image , _("Import Fiebdc")) + _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image, + _("Import Fiebdc")) _ImportFiebdc_button.set_tooltip_text(_("Import Fiebdc")) _ImportFiebdc_button.set_is_important(False) # label not shown _toolbar.insert(_ImportFiebdc_button, -1) @@ -419,7 +423,8 @@ # Go Forward _gtk_image = Gtk.Image.new_from_icon_name("go-next",1) _gtk_image.show() - self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image ,_("Forward")) + self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image, + _("Forward")) self.__goForward_button.set_tooltip_text(_("Forward")) self.__goForward_button.set_is_important(False) # label not shown _toolbar.insert(self.__goForward_button, -1) @@ -538,7 +543,7 @@ self.__GoToRoot_action.set_enabled(False) self.__navigation_is_enabled = False - def _switch_page(self, notebook, page, page_num,): + def _switch_page(self, notebook, page, page_num): """_switch_page(notebook, page, page_num) Method connected to the "switch-page" signal of the notebook widget @@ -559,7 +564,9 @@ elif isinstance(_page, Page): if not self.__navigation_is_enabled: self.__navigation_is_enabled = True - self._checkButtonsSensitive(page_num) + self.__goBack_button.set_menu(_page.back_menu) + self.__goForward_button.set_menu(_page.forward_menu) + self._checkButtonsSensitive(page_num) def _main(self): """main() @@ -957,7 +964,8 @@ self.closeTabButton.set_is_important(False) # label not shown self.__title.add(self.closeTabButton) self.closeTabButton.hide() - self.__closeTabId = self.closeTabButton.connect("clicked", self.on_close_button) + self.__closeTabId = self.closeTabButton.connect("clicked", + self.on_close_button) # Statusbar self.__statusbar = Gtk.Statusbar() self.__statuscontext = self.__statusbar.get_context_id("Statusbar") @@ -1272,8 +1280,8 @@ self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical self.__widget.props.margin = 5 #TODO: __panes_list should come from gui config file... - # "DecompositionList" "RecordDescription" "Measure" "Sheet of Conditions" - # "FileView" "CompanyView" + # "DecompositionList" "RecordDescription" "Measure" + # "Sheet of Conditions" "FileView" "CompanyView" self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure", "RecordDescription" ]] self.__main_item = None @@ -1330,7 +1338,8 @@ """sendMessageTo(pane, message, pane_path, arg=None) pane: the receiver pane message: string message - pane_path: tuple that represents the pane pane_path which emits the message + pane_path: tuple that represents the pane pane_path which emits + the message arg: arguments for the message Sends a message to a pane @@ -1470,17 +1479,18 @@ _item = View( "RecordDescription", self.__budget,weakref.ref(self), pane_path, self.__active_path_record, True) elif list_paned[0] == "Measure": - _item = View( "Measure", self.__budget, weakref.ref(self), pane_path, - self.__active_path_record, True) + _item = View("Measure", self.__budget, weakref.ref(self), + pane_path, self.__active_path_record, True) elif list_paned[0] == "Sheet of Conditions": - _item = View("Sheet of Conditions", self.__budget, weakref.ref(self), pane_path, + _item = View("Sheet of Conditions", + self.__budget, weakref.ref(self), pane_path, self.__active_path_record) elif list_paned[0] == "FileView": - _item = View("FileView", self.__budget, weakref.ref(self), pane_path, - self.__active_path_record) + _item = View("FileView", self.__budget, weakref.ref(self), + pane_path, self.__active_path_record) elif list_paned[0] == "CompanyView": - _item = View("CompanyView", self.__budget, weakref.ref(self), pane_path, - self.__active_path_record) + _item = View("CompanyView", self.__budget, weakref.ref(self), + pane_path, self.__active_path_record) else: _item = None raise ValueError( utils.mapping(_("Incorrect item $1"), @@ -1926,7 +1936,7 @@ _hbox.add(_combobox) _invisible = Gtk.Grid() _invisible.set_orientation(Gtk.Orientation(0)) # 0 Horizontal - _invisible.set_property("hexpand", True) # widget expand horizontal space + _invisible.set_property("hexpand", True) # expand horizontal space _invisible.show() _hbox.add(_invisible) # TODO : Set thist with config @@ -1964,10 +1974,12 @@ self.__connected_button = Gtk.ToolButton() _icon_connected = Gtk.Image() if self.__connected: - _icon_connected.set_from_file(globalVars.getAppPath("CONNECTED-ICON")) + _icon_path = globalVars.getAppPath("CONNECTED-ICON") + _icon_connected.set_from_file(_icon_path) self.__connected_button.set_tooltip_text(_("Disconnect view")) else: - _icon_connected.set_from_file(globalVars.getAppPath("DISCONNECTED-ICON")) + _icon_path = globalVars.getAppPath("DISCONNECTED-ICON") + _icon_connected.set_from_file(_icon_path) self.__connected_button.set_tooltip_text(_("Connect view")) _icon_connected.show() self.__connected_button.set_icon_widget(_icon_connected) @@ -2082,7 +2094,8 @@ _menu_view.append(_item_close) _item_close.connect("activate",self._closeItem_from_menu) _item_close.show() - _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1), Gtk.get_current_event()) + _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1), + Gtk.get_current_event()) def _split_view(self, widget, orientation): """_menu_view(orientation) @@ -2582,7 +2595,7 @@ path_record: the record path that must be showed self.__budget: budget showed ("base.Budget" object) - self.__wr_page: weak reference from Page instance which creates this class + self.__wr_page: weak reference from Page instance which creates self self.__pane_path: tuple that represents the path of the List in the Page self.__liststore: list model which store the list data (Gtk.ListStore object) @@ -2645,7 +2658,8 @@ self.__treeview.show() # Scrolled_window self.__scrolled_window = Gtk.ScrolledWindow() - self.__scrolled_window.set_property("expand", True) # widget expand all space + # widget expand all space + self.__scrolled_window.set_property("expand", True) self.__scrolled_window.set_policy(Gtk.PolicyType(1), Gtk.PolicyType(1)) # 1 Automatic self.__scrolled_window.add(self.__treeview) @@ -2818,8 +2832,10 @@ """ return False - def _controlSelection(self, selection, model, path, path_currently_selected, *data): - """_controlSelection(selection) + def _controlSelection(self, selection, model, path, + path_currently_selected, *data): + """_controlSelection(selection, model, path, + path_currently_selected, *data) selection: treeselection @@ -2889,10 +2905,13 @@ _parent_code = self.budget.getCode(self.__active_path_record[:-1]) _parent_record = self.__budget.getRecord(_parent_code) _amount = _budget.getStrAmount(self.__active_path_record) - self.__code_column.set_title(_("Code") + chr(10) + "[" + _code.decode("utf8") + "]") - self.__unit_column.set_title(_("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]") - self.__description_column.set_title( - _("Description") + chr(10) + "[" + _description.decode("utf8") + "]") + _str = _("Code") + chr(10) + "[" + _code.decode("utf8") + "]" + self.__code_column.set_title(_str) + _str = _("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]" + self.__unit_column.set_title(_str) + _str = _("Description") + chr(10) + "[" + \ + _description.decode("utf8") + "]" + self.__description_column.set_title(_str) self.__measure_column.set_title( _("Measure") + chr(10) + "[" + _stryield + "]") self.__price_column.set_title( @@ -3272,7 +3291,8 @@ self.__treeview.show() # Scrolled_window self.__scrolled_window = Gtk.ScrolledWindow() - self.__scrolled_window.set_property("expand", True) # widget expand all space + # widget expand all space + self.__scrolled_window.set_property("expand", True) self.__scrolled_window.set_policy(Gtk.PolicyType(1), Gtk.PolicyType(1)) # 1 Automatic self.__scrolled_window.add(self.__treeview) @@ -3451,8 +3471,10 @@ """ return False - def _controlSelection(self, selection, model, path, path_currently_selected, *data): - """_controlSelection(selection) + def _controlSelection(self, selection, model, path, + path_currently_selected, *data): + """_controlSelection(selection, model, path, + path_currently_selected, *data) selection: treeselection @@ -3797,7 +3819,7 @@ path_record: the path of the active record self.__budget: the budget (base.obra object) - self.__wr_page: weak reference from Page instance which creates this class + self.__wr_page: weak reference from Page instance which creates self self.__pane_path: the path position of the description in the page self.__active_path_recordthe path of the active record @@ -3822,7 +3844,7 @@ _scrollwindow.set_property("expand", True) # widget expand all space _scrollwindow.set_policy(Gtk.PolicyType(1), Gtk.PolicyType(1)) # 1 Automatic - _scrollwindow.set_shadow_type(1) # NONE 0, IN 1, OUT 2, ETCHED_IN 3,ETCHED_OUT 4 + _scrollwindow.set_shadow_type(1) # IN 1 _textview = Gtk.TextView() _textview.set_wrap_mode(2) # 2 Word _textview.set_hexpand(True) @@ -3981,7 +4003,7 @@ path_record: the path of the active record self.__budget: the budget (base.obra object) - self.__wr_page: weak reference from Page instance which creates this class + self.__wr_page: weak reference from Page instance which creates self self.__pane_path: the path position of the description in the page self.__active_path_record: the path of the active record self.__label: The Gtk.label with the title of the pane @@ -4038,7 +4060,8 @@ _field_scrollwindow = Gtk.ScrolledWindow() _field_scrollwindow.set_policy(Gtk.PolicyType(1), Gtk.PolicyType(1)) # 1 Automatic - _field_scrollwindow.set_property("hexpand", True) # widget expand all space + # widget expand all space + _field_scrollwindow.set_property("hexpand", True) _field_scrollwindow.add(self.__field_treeview) _field_scrollwindow.set_size_request(-1, 80) _field_scrollwindow.show() @@ -4061,7 +4084,8 @@ _section_scrollwindow = Gtk.ScrolledWindow() _section_scrollwindow.set_policy(Gtk.PolicyType(1), Gtk.PolicyType(1)) # 1 Automatic - _section_scrollwindow.set_property("hexpand", True) # widget expand all space + # widget expand all space + _section_scrollwindow.set_property("hexpand", True) _section_scrollwindow.set_size_request(-1, 90) _section_scrollwindow.add(self.__section_treeview) _section_scrollwindow.show() @@ -4129,7 +4153,8 @@ _section_list = _sheet.getSections(self.__field_selection) for _section in _section_list: _section_text = self.__budget.getSheetSection(_section) - _iter = self.__section_liststore.append([_section, _section_text]) + _iter = self.__section_liststore.append([_section, + _section_text]) _treeselection = self.__section_treeview.get_selection() _treeselection.select_path(0) @@ -4192,7 +4217,8 @@ section in showed """ _treeiter = self.__section_liststore.get_iter(path) - self.__section_selection = self.__section_liststore.get_value(_treeiter, 0) + self.__section_selection = self.__section_liststore.get_value(_treeiter, + 0) self._setText() return True @@ -4335,7 +4361,7 @@ pane_path: the tuple that identifies the pane in the notebook page budget: The budget (base.obra object) active_path_record: Read. - wr_page: Read-Write. weak reference from Page instance which creates this class + wr_page: Read-Write. weak reference from Page instance Methods: runMessage """ @@ -4349,7 +4375,7 @@ path_record: the path of the active record self.__budget: the budget (base.obra object) - self.__wr_page: weak reference from Page instance which creates this class + self.__wr_page: weak reference from Page instance which creates self self.__pane_path: the path position of the description in the page self.__active_path_record: the path of the active record self.__active_code: the code of the active record @@ -4401,8 +4427,8 @@ _event_box = Gtk.LinkButton() _file_icon = Gtk.Image() # "image", "wmf", "dxf", "pdf" , "video", - # "office-document", "office-presentation", "office-spreadsheet", - # "html", "rtf", "txt", "" + # "office-document", "office-presentation", + # "office-spreadsheet", "html", "rtf", "txt", "" # icon if _filetype in ["image", "wmf"]: try: @@ -4641,7 +4667,7 @@ active_path_record: Read. Path of the active record in the budget widget: Read. Window that contains the main widget, a Gtk.Paned pane_path: Read-Write. Pane page identifier - wr_page: Read-Write. weak reference from Page instance which creates this class + wr_page: Read-Write. weak reference from Page instance budget: Read. Budget to show, base.budget instance. Methods: runMessage @@ -4657,7 +4683,7 @@ self.__selection: "company" or "office" selected treeview self.__budget: budget: budget showed ("base.Budget" object) - self.__wr_page: weak reference from Page instance which creates this class + self.__wr_page: weak reference from Page instance self.__pane_path: tuple that represents the path of the List in the Page self.__active_path_record: path of the active record in the budget self.__widget: main widget, a Gtk.Paned @@ -4791,8 +4817,10 @@ _values = [_office.officeType, _office.subname] self.__treestore.append(_treeiter, _values) - def _controlSelection(self, selection, model, path, path_currently_selected, *data): - """_controlSelection(selection, model, path, path_currently_selected, *data) + def _controlSelection(self, selection, model, path, + path_currently_selected, *data): + """_controlSelection(selection, model, path, + path_currently_selected, *data) selection: selection @@ -5083,7 +5111,7 @@ _treeselection.set_select_function(self._controlSelection) # labels _frame = Gtk.Frame() - _frame.set_shadow_type(2) # NONE 0, IN 1, OUT 2, ETCHED_IN 3,ETCHED_OUT 4 + _frame.set_shadow_type(2) # OUT 2 _vbox2 = Gtk.Grid() _vbox2.set_orientation(Gtk.Orientation(1)) # 1 Vertical _frame.add(_vbox2)