def _check_outstanding_changes(self): """This function checks if any UI Element has changed """ has_outstanding_changes = False return has_outstanding_changes # FIXME the rest of this function has to be activated when it # is possible to set the selected menu item in the left-sided # main menu # otehrwise this popup will show, but the next menu item is selected # and we can not reset it to the entry which raised this popup if self.current_plugin() and self.current_plugin().pending_changes(): pending_changes = self.current_plugin().pending_changes() elements = self.current_plugin().widgets self.logger.debug("Pending changes: %s" % pending_changes) self.logger.debug("Available elements: %s" % elements) msg = "" for path in [p for p in pending_changes if p in elements]: self.logger.debug("Element '%s' changed" % path) # assumption that element is a container element = elements[path] field = element.label() self.logger.debug("Changed widget: " + "%s %s" % (path, element)) msg += "- %s\n" % (field.strip(":")) if msg: txt = "The following fields have changed:\n%s" % msg txt += "\n\nPlease save or reset the page." dialog = ui.Dialog("dialog.changes", "Pending Changes", [ui.Label("dialog.changes.txt", txt)]) dialog.buttons = [ui.CloseButton("dialog.changes.close", "Back")] self.show(dialog) has_outstanding_changes = True
def _check_outstanding_changes(self): has_outstanding_changes = False if self.current_plugin(): pending_changes = self.current_plugin().pending_changes() if pending_changes: self.logger.warning("Pending changes: %s" % pending_changes) msg = "" elements = self.current_plugin().ui_content().elements() self.logger.debug("Available elements: %s" % elements) for path, value in pending_changes.items(): if path in elements: # assumption that element is a container element = elements[path] field = element.path self.logger.debug("Changed widget: " + "%s %s" % (path, element)) msg += "- %s\n" % (field.strip(":")) if msg: txt = "The following fields have changed:\n%s" % msg txt += "\n\nPlease save or reset the page." self.ui.display_as_dialog(ui.Dialog("pendin", "Pending Changes", [ui.Label(txt)])) has_outstanding_changes = True return has_outstanding_changes
def display_exception_as_notice(e): self.logger.debug(traceback.format_exc()) children = [ui.Label("dialog.notice.exception", "%s" % e)] notice = ui.Dialog("dialog.notice", "An exception occurred", children) notice.buttons = [ ui.CloseButton("dialog.notice.action.close", "Close") ] self.show(notice)
def notice(self, msg): """Displays a notice on the screen """ if True: children = [ui.Label("app.notice.text", msg)] dialog = ui.Dialog("app.notice", "Notice", children) dialog.buttons = [ui.CloseButton("app.notice.close")] self.show(dialog) else: self.ui._show_on_notice(msg)
def _build_lock_dialog(self): widgets = [ ui.Header("lock.label[0]", "Enter the admin password to unlock"), ui.KeywordLabel("username", "Username: "******"password", "Password:"******"lock.dialog", "This screen is locked.", widgets) page.buttons = [ui.Button("action.unlock", "Unlock")] page.escape_key = None return page
def _check_min_size_cb(self): size = self.size() msize = self._min_size() width, height = size min_width, min_height = msize if width < min_width or height < min_height: msg = ("The current window size %s is smaller " + "than the minimum size %s") % (size, msize) self.logger.warning(msg) if not hasattr(self, "_error_dialog") or not self._error_dialog: d = ui.Dialog("error", "Error", [ui.Label("label", msg)]) d.buttons = [] self._error_dialog = self._show_on_dialog(d) else: if hasattr(self, "_error_dialog") and self._error_dialog: self._error_dialog.close() self._error_dialog = None self.close_topmost_dialog()
def notice(self, msg): children = [ui.Label("app.notice.text", msg)] dialog = ui.Dialog("app.notice", "Notice", children) dialog.buttons = [ui.CloseButton("app.notice.close")]
def _build_dialog(self, path, txt, widgets): self.widgets.add(widgets) self.widgets.add(ui.Dialog(path, txt, widgets)) return self.widgets[path]