def delete_files(main_window, forever):
    iconview = main_window.iconview
    selected = iconview.get_selected_items()
    if selected and len(selected)>1:
        if forever:
            message = _('Would you like to permanently delete the '
                        'selected images?')
        else:
            message = _('Would you like to delete the selected images?')

        dlg = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION,
            buttons=gtk.BUTTONS_YES_NO,
            message_format=message)
        response = dlg.run()
        dlg.destroy()
        if response != gtk.RESPONSE_YES:
            return

    banned = open(os.path.expanduser('~/.webilder/banned_photos'), 'a')
    model = iconview.get_model()

    monitor = main_window.collection_monitor
    if monitor['monitor'] is not None:
        gnomevfs.monitor_cancel(monitor['monitor'])
        monitor['monitor'] = None

    for path in selected:
        iterator = model.get_iter(path)
        data = model.get_value(iterator,
            IV_DATA_COLUMN)
        for fname in (data['filename'], data['info_file'], data['thumb']):
            try:
                os.remove(fname)
            except (IOError, OSError):
                pass
        if forever:
            banned.write(os.path.basename(data['filename'])+'\n')
        model.remove(iterator)

    if monitor['dir']:
        monitor['monitor'] = gnomevfs.monitor_add(
            monitor['dir'],
            gnomevfs.MONITOR_DIRECTORY,
            main_window.collection_directory_changed)

    banned.close()
Delete the selected files.
dataset/ETHPy150Open thesamet/webilder/src/webilder/WebilderDesktop.py/delete_files