def get_value(self, title=None): """Popup a FrameSelector dialog to select a precise frame. """ if title is None: title = _("Select the appropriate snapshot") d = Gtk.Dialog(title=title, parent=self.controller.gui.gui.win, flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK, )) def callback(v): d.response(Gtk.ResponseType.OK) return True self.callback = callback d.vbox.add(self.widget) buttons = Gtk.HBox() b=Gtk.Button(_("Refresh snapshots")) b.set_tooltip_text(_("Refresh missing snapshots")) b.connect("clicked", lambda b: self.refresh_snapshots()) buttons.pack_start(b, False, True, 0) d.vbox.pack_start(buttons, False, True, 0) d.show_all() dialog.center_on_mouse(d) res = d.run() timestamp = self.timestamp if res == Gtk.ResponseType.OK: timestamp = self.selected_value d.destroy() return timestamp
def get_value(self, title=None): if title is None: title = _("Select the appropriate snapshot") d = gtk.Dialog(title=title, parent=None, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) def callback(v): d.response(gtk.RESPONSE_OK) return True self.callback = callback d.vbox.add(self.widget) buttons = gtk.HBox() b=gtk.Button(_("Refresh snapshots")) b.set_tooltip_text(_("Refresh missing snapshots")) b.connect("clicked", lambda b: self.refresh_snapshots()) buttons.pack_start(b, expand=False) d.vbox.pack_start(buttons, expand=False) d.show_all() dialog.center_on_mouse(d) res = d.run() timestamp = self.timestamp if res == gtk.RESPONSE_OK: timestamp = self.selected_value d.destroy() return timestamp
def select_active_checkers(self): active = self.options.get('active_checkers') if active: active = [ name.strip() for name in active.split(',') ] else: active = list(CHECKERS.keys()) d = Gtk.Dialog(title=_("Active checkers"), parent=self.widget.get_toplevel(), flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_OK, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL )) d.vbox.pack_start(Gtk.Label(_("Please specify the active checkers.")), False, False, 0) for name in CHECKERS: b = Gtk.CheckButton(name, use_underline=False) b._element = name b.set_active(name in active) d.vbox.pack_start(b, False, True, 0) d.vbox.show_all() d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show() dialog.center_on_mouse(d) res=d.run() if res == Gtk.ResponseType.OK: elements=[ but._element for but in d.vbox.get_children() if hasattr(but, 'get_active') and but.get_active() ] self.options['active_checkers'] = ",".join(elements) self.build_checkers() self.update_model() d.close() return True
def get_value(self, title=None): if title is None: title = _("Select the appropriate snapshot") d = gtk.Dialog(title=title, parent=None, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) def callback(v): d.response(gtk.RESPONSE_OK) return True self.callback = callback d.vbox.add(self.widget) d.show_all() dialog.center_on_mouse(d) res = d.run() timestamp = self.timestamp if res == gtk.RESPONSE_OK: timestamp = self.selected_value d.destroy() return timestamp
def new_tag(self, *p): """Enter a new tag. """ d = gtk.Dialog(title=_("New tag name"), parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) l = gtk.Label(_("Enter a new tag name and select its color.")) d.vbox.pack_start(l, expand=False) hb = gtk.HBox() hb.pack_start(gtk.Label(_("Name")), expand=False) tagname = gtk.Entry() hb.pack_start(tagname, expand=False) d.vbox.pack_start(hb, expand=False) hb = gtk.HBox() hb.pack_start(gtk.Label(_("Color")), expand=False) colorbutton = gtk.ColorButton() colorbutton.set_color(gtk.gdk.color_parse('red')) hb.pack_start(colorbutton, expand=False) d.vbox.pack_start(hb, expand=False) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res = d.run() ret = None if res == gtk.RESPONSE_OK: try: tag = unicode(tagname.get_text()) except ValueError: tag = None color = colorbutton.get_color() else: tag = None d.destroy() if tag and not tag in self.tags: if not re.match('^[\w\d_]+$', tag): dialog.message_dialog(_("The tag contains invalid characters"), icon=gtk.MESSAGE_ERROR) return True self.tags.append(tag) self.controller.package._tag_colors[tag] = "#%04x%04x%04x" % ( color.red, color.green, color.blue) self.controller.notify('TagUpdate', tag=tag) self.refresh() return True
def new_tag(self, *p): """Enter a new tag. """ d = Gtk.Dialog(title=_("New tag name"), parent=self.controller.gui.gui.win, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK, )) l = Gtk.Label(label=_("Enter a new tag name and select its color.")) d.vbox.pack_start(l, False, True, 0) hb = Gtk.HBox() hb.pack_start(Gtk.Label(_("Name")), False, False, 0) tagname = Gtk.Entry() hb.pack_start(tagname, False, True, 0) d.vbox.pack_start(hb, False, True, 0) hb = Gtk.HBox() hb.pack_start(Gtk.Label(_("Color")), False, False, 0) colorbutton = Gtk.ColorButton() colorbutton.set_color(Gdk.color_parse('red')) hb.pack_start(colorbutton, False, True, 0) d.vbox.pack_start(hb, False, True, 0) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res = d.run() if res == Gtk.ResponseType.OK: try: tag = tagname.get_text() except ValueError: tag = None color = colorbutton.get_color() else: tag = None d.destroy() if tag and not tag in self.tags: if not re.match(r'^[\w\d_]+$', tag): dialog.message_dialog(_("The tag contains invalid characters"), icon=Gtk.MessageType.ERROR) return True self.tags.append(tag) self.controller.package._tag_colors[tag] = "#%04x%04x%04x" % ( color.red, color.green, color.blue) self.controller.notify('TagUpdate', tag=tag) self.refresh() return True
def new_tag(self, *p): """Enter a new tag. """ d = gtk.Dialog(title=_("New tag name"), parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) l=gtk.Label(_("Enter a new tag name and select its color.")) d.vbox.pack_start(l, expand=False) hb=gtk.HBox() hb.pack_start(gtk.Label(_("Name")), expand=False) tagname=gtk.Entry() hb.pack_start(tagname, expand=False) d.vbox.pack_start(hb, expand=False) hb=gtk.HBox() hb.pack_start(gtk.Label(_("Color")), expand=False) colorbutton=gtk.ColorButton() colorbutton.set_color(gtk.gdk.color_parse('red')) hb.pack_start(colorbutton, expand=False) d.vbox.pack_start(hb, expand=False) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res=d.run() ret=None if res == gtk.RESPONSE_OK: try: tag=unicode(tagname.get_text()) except ValueError: tag=None color=colorbutton.get_color() else: tag=None d.destroy() if tag and not tag in self.tags: if not re.match('^[\w\d_]+$', tag): dialog.message_dialog(_("The tag contains invalid characters"), icon=gtk.MESSAGE_ERROR) return True self.tags.append(tag) self.controller.package._tag_colors[tag]="#%04x%04x%04x" % (color.red, color.green, color.blue) self.controller.notify('TagUpdate', tag=tag) self.refresh() return True
def new_tag(self, *p): """Enter a new tag. """ d = Gtk.Dialog(title=_("New tag name"), parent=self.controller.gui.gui.win, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK, )) l=Gtk.Label(label=_("Enter a new tag name and select its color.")) d.vbox.pack_start(l, False, True, 0) hb=Gtk.HBox() hb.pack_start(Gtk.Label(_("Name")), False, False, 0) tagname=Gtk.Entry() hb.pack_start(tagname, False, True, 0) d.vbox.pack_start(hb, False, True, 0) hb=Gtk.HBox() hb.pack_start(Gtk.Label(_("Color")), False, False, 0) colorbutton=Gtk.ColorButton() colorbutton.set_color(Gdk.color_parse('red')) hb.pack_start(colorbutton, False, True, 0) d.vbox.pack_start(hb, False, True, 0) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res=d.run() if res == Gtk.ResponseType.OK: try: tag=tagname.get_text() except ValueError: tag=None color=colorbutton.get_color() else: tag=None d.destroy() if tag and not tag in self.tags: if not re.match('^[\w\d_]+$', tag): dialog.message_dialog(_("The tag contains invalid characters"), icon=Gtk.MessageType.ERROR) return True self.tags.append(tag) self.controller.package._tag_colors[tag]="#%04x%04x%04x" % (color.red, color.green, color.blue) self.controller.notify('TagUpdate', tag=tag) self.refresh() return True
def popup_edit(i, button): d = gtk.Dialog(title=_("Enter the new time value"), parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL )) ta=TimeAdjustment(value=button.value, controller=self.controller) d.vbox.pack_start(ta.widget, expand=False) d.show_all() dialog.center_on_mouse(d) res=d.run() retval=None if res == gtk.RESPONSE_OK: button.value = ta.get_value() d.destroy() return True
def popup_at_pointer(menu, event): if event is None: event = Gtk.get_current_event() if event is None or event.type != Gdk.EventType.DROP_START: # We should be able to use the real popup_at_pointer (button press...) menu._real_popup_at_pointer(event) return # else: # Problematic case on win32. Workaround by using a modal. popup = Gtk.Window(Gtk.WindowType.POPUP) # For some reason, enter_notify is triggered upon creation # (even if the pointer is not in it). So guard using multiple # enter events before enabling deletion. popup.can_delete = -2 def enable_deletion(w, e=None): popup.can_delete += 1 def conditional_deletion(w, e=None): if popup.can_delete > 0: popup.destroy() return False def forced_deletion(w, e=None): popup.destroy() return False newmenu = Gtk.MenuBar() newmenu.set_pack_direction(Gtk.PackDirection.TTB) popup.add(newmenu) # Set our popup as modal wrt. normal menu toplevel p = menu.get_parent() if p is not None: popup.set_transient_for(p.get_toplevel()) popup.set_modal(True) # Take menuitems from menu and reattach them to our new menu for menuitem in menu.get_children(): menu.remove(menuitem) newmenu.append(menuitem) popup.connect("enter-notify-event", enable_deletion) popup.connect("leave-notify-event", conditional_deletion) popup.connect("button-press-event", enable_deletion) popup.connect("button-release-event", conditional_deletion) newmenu.connect("selection-done", forced_deletion) newmenu.connect("cancel", forced_deletion) center_on_mouse(popup) popup.show_all() newmenu.set_take_focus(True)
def get_value(self, title=None): """Popup a FrameSelector dialog to select a precise frame. """ if title is None: title = _("Select the appropriate snapshot") d = Gtk.Dialog(title=title, parent=self.controller.gui.gui.win, flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK, )) def callback(v): d.response(Gtk.ResponseType.OK) return True self.callback = callback d.vbox.add(self.widget) buttons = Gtk.HBox() b = Gtk.Button(_("Refresh snapshots")) b.set_tooltip_text(_("Refresh missing snapshots")) b.connect("clicked", lambda b: self.refresh_snapshots()) buttons.pack_start(b, False, True, 0) d.vbox.pack_start(buttons, False, True, 0) d.show_all() dialog.center_on_mouse(d) res = d.run() timestamp = self.timestamp if res == Gtk.ResponseType.OK: timestamp = self.selected_value d.destroy() return timestamp
def popup(self, modal=False): d=self.build_widget(modal) d.connect('key-press-event', dialog.dialog_keypressed_cb) self.dialog=d while True: d.show() dialog.center_on_mouse(d) res=d.run() retval=None if res == gtk.RESPONSE_OK: retval=self.do_create_element() if retval is not None: break else: break d.destroy() if retval is not None and not modal and not isinstance(retval, Resources): if self.controller.gui: self.controller.gui.edit_element(retval) return retval
def popup(self, modal=False): d = self.build_widget(modal) d.connect('key-press-event', dialog.dialog_keypressed_cb) self.dialog = d while True: d.show() dialog.center_on_mouse(d) res = d.run() retval = None if res == gtk.RESPONSE_OK: retval = self.do_create_element() if retval is not None: break else: break d.destroy() if retval is not None and not modal and not isinstance( retval, Resources): if self.controller.gui: self.controller.gui.edit_element(retval) return retval
def renumber_annotations(self, m, at): """Renumber all annotations of a given type. """ d = gtk.Dialog(title=_("Renumbering annotations of type %s") % self.get_title(at), parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) l = gtk.Label() l.set_markup( _("<b>Renumber all annotations according to their order.</b>\n\n<i>Note that this action cannot be undone.</i>\nReplace the first numeric value of the annotation content with the new annotation number.\nIf no numeric value is found and the annotation is structured, it will insert the number.\nIf no numeric value is found and the annotation is of type text/plain, it will overwrite the annotation content.\nThe offset parameter allows you to renumber from a given annotation." )) l.set_line_wrap(True) l.show() d.vbox.add(l) hb = gtk.HBox() l = gtk.Label(_("Offset")) hb.pack_start(l, expand=False) s = gtk.SpinButton() s.set_range(1, len(at.annotations)) s.set_value(1) s.set_increments(1, 5) hb.add(s) d.vbox.pack_start(hb, expand=False) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res = d.run() if res == gtk.RESPONSE_OK: re_number = re.compile('(\d+)') re_struct = re.compile('^num=(\d+)$', re.MULTILINE) offset = s.get_value_as_int() - 1 l = at.annotations l.sort(key=lambda a: a.fragment.begin) l = l[offset:] size = float(len(l)) dial = gtk.Dialog( _("Renumbering %d annotations") % size, None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) prg = gtk.ProgressBar() dial.vbox.pack_start(prg, expand=False) dial.show_all() for i, a in enumerate(l[offset:]): prg.set_text(_("Annotation #%d") % i) prg.set_fraction(i / size) while gtk.events_pending(): gtk.main_iteration() if a.type.mimetype == 'application/x-advene-structured': if re_struct.search(a.content.data): # A 'num' field is present. Update it. data = re_struct.sub("num=%d" % (i + 1), a.content.data) else: # Insert the num field data = ("num=%d\n" % (i + 1)) + a.content.data elif re_number.search(a.content.data): # There is a number. Simply substitute the new one. data = re_number.sub(str(i + 1), a.content.data) elif a.type.mimetype == 'text/plain': # Overwrite the contents data = str(i + 1) else: data = None if data is not None and a.content.data != data: a.content.data = data self.controller.notify('PackageActivate', package=self.controller.package) dial.destroy() d.destroy() return True
def convert_transcription_cb(self, button=None): if not self.controller.gui: self.message(_("Cannot convert the data: no associated package")) return True d = Gtk.Dialog(title=_("Converting transcription"), parent=self.controller.gui.gui.win, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK, )) l=Gtk.Label(label=_("Choose the annotation-type where to create annotations.\n")) l.set_line_wrap(True) l.show() d.vbox.pack_start(l, False, True, 0) # Anticipated declaration of some widgets, which need to be # updated in the handle_new_type_selection callback. new_type_dialog=Gtk.VBox() delete_existing_toggle=Gtk.CheckButton(_("Delete existing annotations in this type")) delete_existing_toggle.set_active(False) ats=list(self.controller.package.annotationTypes) newat=helper.TitledElement(value=None, title=_("Create a new annotation type")) ats.append(newat) def handle_new_type_selection(combo): el=combo.get_current_element() if el == newat: new_type_dialog.show() delete_existing_toggle.set_sensitive(False) else: new_type_dialog.hide() delete_existing_toggle.set_sensitive(True) return True type_selection=dialog.list_selector_widget(members=[ (a, self.controller.get_title(a), self.controller.get_element_color(a)) for a in ats], callback=handle_new_type_selection, preselect=self.controller.package.get_element_by_id(self.options['annotation-type-id'])) hb=Gtk.HBox() hb.pack_start(Gtk.Label(_("Select type") + " "), False, False, 0) hb.pack_start(type_selection, False, True, 0) d.vbox.pack_start(hb, False, True, 0) l=Gtk.Label(label=_("You want to create a new type. Please specify its schema and title.")) l.set_line_wrap(True) l.show() new_type_dialog.pack_start(l, False, True, 0) hb=Gtk.HBox() hb.pack_start(Gtk.Label(_("Title") + " "), False, False, 0) new_title=Gtk.Entry() hb.pack_start(new_title, True, True, 0) new_type_dialog.pack_start(hb, False, True, 0) hb=Gtk.HBox() hb.pack_start(Gtk.Label(_("Containing schema") + " "), False, False, 0) schemas=list(self.controller.package.schemas) schema_selection=dialog.list_selector_widget(members=[ (s, self.controller.get_title(s)) for s in schemas]) hb.pack_start(schema_selection, False, True, 0) new_type_dialog.pack_start(hb, False, True, 0) new_type_dialog.show_all() new_type_dialog.set_no_show_all(True) new_type_dialog.hide() d.vbox.pack_start(new_type_dialog, True, True, 0) l=Gtk.Label() l.set_markup("<b>" + _("Export options") + "</b>") d.vbox.pack_start(l, False, True, 0) d.vbox.pack_start(delete_existing_toggle, False, True, 0) empty_contents_toggle=Gtk.CheckButton(_("Generate annotations for empty contents")) empty_contents_toggle.set_active(self.options['empty-annotations']) d.vbox.pack_start(empty_contents_toggle, False, True, 0) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) finished=None while not finished: res=d.run() if res == Gtk.ResponseType.OK: at=type_selection.get_current_element() if at == newat: new_type_title=new_title.get_text() if new_type_title == '': # Empty title. Generate one. id_=self.controller.package._idgenerator.get_id(AnnotationType) new_type_title=id_ else: id_=helper.title2id(new_type_title) # Check that the id is available if self.controller.package._idgenerator.exists(id_): dialog.message_dialog( _("The %s identifier already exists. Choose another one.") % id_, icon=Gtk.MessageType.WARNING) at=None continue # Creating a new type s=schema_selection.get_current_element() at=s.createAnnotationType(ident=id_) at.author=config.data.userid at.date=helper.get_timestamp() at.title=new_type_title at.mimetype='text/plain' at.setMetaData(config.data.namespace, 'color', next(s.rootPackage._color_palette)) at.setMetaData(config.data.namespace, 'item_color', 'here/tag_color') s.annotationTypes.append(at) self.controller.notify('AnnotationTypeCreate', annotationtype=at) if delete_existing_toggle.get_active(): # Remove all annotations of at type batch_id=object() for a in at.annotations: self.controller.delete_element(a, batch=batch_id) self.options['empty-annotations']=empty_contents_toggle.get_active() finished=True else: at=None finished=True d.destroy() if at is not None: self.options['annotation-type-id'] = at.id ti=TranscriptionImporter(package=self.controller.package, controller=self.controller, defaulttype=at, transcription_edit=self) ti.process_file('transcription') self.controller.package._modified=True self.controller.notify("PackageActivate", package=ti.package) self.message(_('Notes converted')) self.log(ti.statistics_formatted()) # Feedback dialog.message_dialog( _("Conversion completed.\n%s annotations generated.") % ti.statistics['annotation']) return True
def renumber_annotations(self, m, at): """Renumber all annotations of a given type. """ d = gtk.Dialog(title=_("Renumbering annotations of type %s") % self.get_title(at), parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK, )) l=gtk.Label() l.set_markup(_("<b>Renumber all annotations according to their order.</b>\n\n<i>Note that this action cannot be undone.</i>\nReplace the first numeric value of the annotation content with the new annotation number.\nIf no numeric value is found and the annotation is structured, it will insert the number.\nIf no numeric value is found and the annotation is of type text/plain, it will overwrite the annotation content.\nThe offset parameter allows you to renumber from a given annotation.")) l.set_line_wrap(True) l.show() d.vbox.add(l) hb=gtk.HBox() l=gtk.Label(_("Offset")) hb.pack_start(l, expand=False) s=gtk.SpinButton() s.set_range(-5, len(at.annotations)) s.set_value(1) s.set_increments(1, 5) hb.add(s) d.vbox.pack_start(hb, expand=False) d.connect('key-press-event', dialog.dialog_keypressed_cb) d.show_all() dialog.center_on_mouse(d) res=d.run() if res == gtk.RESPONSE_OK: re_number=re.compile('(\d+)') re_struct=re.compile('^num=(\d+)$', re.MULTILINE) offset=s.get_value_as_int() - 1 l=at.annotations l.sort(key=lambda a: a.fragment.begin) l=l[offset:] size=float(len(l)) dial=gtk.Dialog(_("Renumbering %d annotations") % size, None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) prg=gtk.ProgressBar() dial.vbox.pack_start(prg, expand=False) dial.show_all() for i, a in enumerate(l[offset:]): prg.set_text(_("Annotation #%d") % i) prg.set_fraction( i / size ) while gtk.events_pending(): gtk.main_iteration() if a.type.mimetype == 'application/x-advene-structured': if re_struct.search(a.content.data): # A 'num' field is present. Update it. data=re_struct.sub("num=%d" % (i+1), a.content.data) else: # Insert the num field data=("num=%d\n" % (i+1)) + a.content.data elif re_number.search(a.content.data): # There is a number. Simply substitute the new one. data=re_number.sub(str(i+1), a.content.data) elif a.type.mimetype == 'text/plain': # Overwrite the contents data=str(i+1) else: data=None if data is not None and a.content.data != data: a.content.data=data self.controller.notify('PackageActivate', package=self.controller.package) dial.destroy() d.destroy() return True