def rem_source(self, srcs=None): """Delete a source from the list.""" if srcs is None: srcs=self.source_list.get_selected_rows() elif type(srcs) != list: srcs=[srcs] if not self.plt_combo.read() is ValueUnset: plts=self.plt_combo.get_model_items().values() else: plts=[] src_str="" for s in srcs: src_str+="<i>\'"+s.name+"\'</i> " reply=dialogs.yesno("You are about to remove "+str(len(srcs))+" Sources:\n"+\ src_str+".\n"\ "Is this what you want?") if reply == RESPONSE_YES: for src in srcs: plots=self.get_plots_with_source(src) for plot in plots: plot.rem_line(plot.get_line(src)) self.lines_list.add_list(plot.lines) self.update_plt_title(plot) self.source_list.remove(src)
def quit(self): if not self.mo.config['miniorganizer.auto_save'] and self.mo.cal_model.modified_inmem(): response = dialogs.yesno('You have unsaved changes in this calendar. Are you sure you want to quit?') if response == gtk.RESPONSE_NO: return True self.view.hide() gtk.main_quit()
def on_button_del__clicked(self, *args): result = yesno(_('Really delete the selected asset?\n') + _('This action can\'t be undone!')) if result == gtk.RESPONSE_YES: selected = self.list.get_selected() selected.delete() session.commit() self.populate_list() else: pass
def default_remove(self, item): """Asks the user confirmation for removal of an item. @param item: a description of the item that will be removed @returns: True if the user confirm the removal, False otherwise """ response = yesno(_('Do you want to remove %s ?') % (quote(str(item)),), parent=None, default=gtk.RESPONSE_OK, buttons=((gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), (gtk.STOCK_REMOVE, gtk.RESPONSE_OK))) return response == gtk.RESPONSE_OK
def on_button_del__clicked(self, *args): result = yesno( _('Really delete the selected asset?\n') + _('This action can\'t be undone!')) if result == gtk.RESPONSE_YES: selected = self.list.get_selected() selected.delete() session.commit() self.populate_list() else: pass
def yesno(self, text, default=gtk.RESPONSE_YES, *verbs): if len(verbs) != 2: raise ValueError( "Button descriptions must be a tuple with 2 items") if verbs == (_("Yes"), _("No")): buttons = gtk.BUTTONS_YES_NO else: buttons = ((verbs[0], gtk.RESPONSE_YES), (verbs[1], gtk.RESPONSE_NO)) return (yesno(text, get_current_toplevel(), default, buttons) == gtk.RESPONSE_YES)
def default_remove(self, item): """Asks the user confirmation for removal of an item. :param item: a description of the item that will be removed :returns: True if the user confirm the removal, False otherwise """ response = yesno(_('Do you want to remove %s ?') % (GLib.markup_escape_text(str(item)),), parent=None, default=Gtk.ResponseType.OK, buttons=((Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL), (Gtk.STOCK_REMOVE, Gtk.ResponseType.OK))) return response == Gtk.ResponseType.OK
def default_remove(self, item): """Asks the user confirmation for removal of an item. :param item: a description of the item that will be removed :returns: True if the user confirm the removal, False otherwise """ response = yesno(_('Do you want to remove %s ?') % (GLib.markup_escape_text(str(item)), ), parent=None, default=Gtk.ResponseType.OK, buttons=((Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL), (Gtk.STOCK_REMOVE, Gtk.ResponseType.OK))) return response == Gtk.ResponseType.OK
def default_remove(self, item): """Asks the user confirmation for removal of an item. @param item: a description of the item that will be removed @returns: True if the user confirm the removal, False otherwise """ response = yesno(_('Do you want to remove %s ?') % (quote(str(item)), ), parent=None, default=gtk.RESPONSE_OK, buttons=((gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), (gtk.STOCK_REMOVE, gtk.RESPONSE_OK))) return response == gtk.RESPONSE_OK
def yesno(self, text, default=None, *verbs): if default is None: default = Gtk.ResponseType.YES if len(verbs) != 2: raise ValueError( "Button descriptions must be a tuple with 2 items") if verbs == (_("Yes"), _("No")): buttons = Gtk.ButtonsType.YES_NO else: buttons = ((verbs[0], Gtk.ResponseType.YES), (verbs[1], Gtk.ResponseType.NO)) return (yesno(text, get_current_toplevel(), default, buttons) == Gtk.ResponseType.YES)
def on_toolbutton_remove__clicked(self, *args): sel_event = self.treeview_event.get_selected() sel_real_event = getattr(sel_event, 'real_event', sel_event) # Delete real event instead of recurring event if sel_event != sel_real_event: response = dialogs.yesno('This is a recurring event. Deleting it will delete all recurrences. Are you sure you want to delete it?') if response == gtk.RESPONSE_NO: return else: sel_event = sel_real_event if sel_event: self.mo.cal_model.delete(sel_event) self.treeview_event.remove(sel_event) self.on_calendar__month_changed(self.calendar) self.on_calendar__day_selected(self.calendar) self.parent.menuitem_save.set_sensitive(True)
def open_or_new(self): """ Shows a dialog with options for opening a file or creating a new one. Used on the startup to provide a ``db_file`` """ result = yesno(_('Do you want to open a previous file?\n\n') + _('Choose \'Yes\' to open a previous work, or\n') + _('choose \'No\' if you want to create a new DB')) if result == gtk.RESPONSE_YES: res = self.on_open__activate() if res is None: sys.exit() elif result == gtk.RESPONSE_NO: res = self.on_new__activate() if res is None: sys.exit() else: sys.exit()
def ask_to_save(self, field): """Pergunta ao usuario sobre a edicao de campos""" #Criando um novo if self.editing_new : question =str('Deseja salvar %s ?') for field in self.fields: if field.searchable: registro = quote(str(field.entry.get_text())) #Editando else: question =str('Deseja salvar alterações em %s ?') registro = quote(str(getattr(self.item, field.field_name))) response = yesno((question) % (registro,), parent=None, default=gtk.RESPONSE_OK, buttons=((gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), (gtk.STOCK_SAVE, gtk.RESPONSE_OK))) return response == gtk.RESPONSE_OK
def open_or_new(self): """ Shows a dialog with options for opening a file or creating a new one. Used on the startup to provide a ``db_file`` """ result = yesno( _('Do you want to open a previous file?\n\n') + _('Choose \'Yes\' to open a previous work, or\n') + _('choose \'No\' if you want to create a new DB')) if result == gtk.RESPONSE_YES: res = self.on_open__activate() if res is None: sys.exit() elif result == gtk.RESPONSE_NO: res = self.on_new__activate() if res is None: sys.exit() else: sys.exit()
def on_remove_log_button__clicked(self, button): parent = self.get_toplevel().get_toplevel() response = yesno('Deseja remover?', parent=parent, default=False, buttons=((gtk.STOCK_YES, True), (gtk.STOCK_NO, False))) if not response: return log = self.log.get_selected() racer = log.racer self.log.remove(log) self.store.remove(log) self.store.commit() # We need to recalculate the number of laps racer.category.update() racer.update() self.categories.refresh(racer.category) self.lap_number.grab_focus()