def _on_page_change(self, event=None): if self._leave_form_requested or self._hide_form_requested or not self.IsShown( ): # Prevent (possibly expensive) database queries on NotebookEvent # called when the form is being closed asynchronously from _on_idle # method. return if self._block_on_page_change: return if event: selection = event.GetSelection() old_selection = event.GetOldSelection() else: selection = self._notebook.GetSelection() old_selection = self._old_notebook_selection if selection != -1: form = self._forms[selection] if form: # The SetSelection call below is necessary here to make # WebForm work in sideforms, as they need the panel to be shown # before the webkit widget can be embedded into it. And the # embedding is done within _init_subform(), so we must ensure # the page is changed before. self._block_on_page_change = True try: self._notebook.SetSelection(selection) finally: self._block_on_page_change = False self._init_subform(form) row = self._last_selection if row is not None: form.on_selection(row) form.focus() if old_selection != -1: old_form = self._forms[old_selection] if old_form and old_form is not form and old_form.initialized( ): old_form._release_data() elif event: message(_("Form disabled"), beep_=True) event.Veto() old_selection = event.GetOldSelection() if old_selection != -1: form = self._forms[old_selection] if form: form._init_subform(form) form.focus() form.SetFocus()
def _on_page_change(self, event=None): if self._leave_form_requested or self._hide_form_requested or not self.IsShown(): # Prevent (possibly expensive) database queries on NotebookEvent # called when the form is being closed asynchronously from _on_idle # method. return if self._block_on_page_change: return if event: selection = event.GetSelection() old_selection = event.GetOldSelection() else: selection = self._notebook.GetSelection() old_selection = self._old_notebook_selection if selection != -1: form = self._forms[selection] if form: # The SetSelection call below is necessary here to make # WebForm work in sideforms, as they need the panel to be shown # before the webkit widget can be embedded into it. And the # embedding is done within _init_subform(), so we must ensure # the page is changed before. self._block_on_page_change = True try: self._notebook.SetSelection(selection) finally: self._block_on_page_change = False self._init_subform(form) row = self._last_selection if row is not None: form.on_selection(row) form.focus() if old_selection != -1: old_form = self._forms[old_selection] if old_form and old_form is not form and old_form.initialized(): old_form._release_data() elif event: message(_("Form disabled"), beep_=True) event.Veto() old_selection = event.GetOldSelection() if old_selection != -1: form = self._forms[old_selection] if form: form._init_subform(form) form.focus() form.SetFocus()
def select_binding(self, id): """Raise the side form tab corresponfing to the binding of given identifier. The argument 'id' is a string identifier of a 'Binding' instance which must appear in the main form 'bindings' specification. If there is no binding of given id, an 'AssertError' is raised. If the corresponding form is not active (e.g. the user has no access rights for the form), False is returned and an error message is displayed. Otherwise the form is raised and 'True' is returned. """ for i, form in enumerate(self._forms): if form and form.binding().id() == id: self._init_subform(form) self._set_notebook_selection(i) return True message(_("The requested side form is not available."), beep_=True) return False