def delete_format(self, widget, data=None):
# ???? ???????? gtk.RadioButton
for format_id in self.format_radio:
if format_id.get_active():
# ?????????? ??????, ? ??????? ???????? ???????????? ?????????? ???? ?????
dialog = gtk.Dialog('???????? ??????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"', self.window, gtk.DIALOG_NO_SEPARATOR | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_NO, gtk.RESPONSE_CANCEL, gtk.STOCK_YES, gtk.RESPONSE_OK))
dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
dialog.set_resizable(False)
dialog.set_border_width(10)
self.confirmation_label = gtk.Label('?? ????????????? ?????? ??????? ?????? "' + self.data['formats'][self.format_radio.index(format_id)]['name'] + '"?')
dialog.vbox.pack_start(self.confirmation_label, True, True, 5)
dialog.show_all()
response = dialog.run()
if response == gtk.RESPONSE_CANCEL:
dialog.hide()
dialog.destroy()
if response == gtk.RESPONSE_OK:
# ??????? ??????
name = self.data['formats'][self.format_radio.index(format_id)]['name']
del self.data['formats'][self.format_radio.index(format_id)]
config = open(self.path, 'wb')
json.dump(self.data, config)
config.close()
self.format_radio[self.format_radio.index(format_id)].hide()
if len(self.format_radio) == 1:
pass
elif self.format_radio.index(format_id) + 1 <= len(self.format_radio) - 1:
self.format_radio[self.format_radio.index(format_id) + 1].set_active(True)
elif self.format_radio.index(format_id) + 1 > len(self.format_radio) - 1:
self.format_radio[self.format_radio.index(format_id) - 1].set_active(True)
del self.format_radio[self.format_radio.index(format_id)]
if len(self.format_radio) < 1:
self.delete_button.set_sensitive(False)
self.edit_button.set_sensitive(False)
self.add_success_label.set_markup('<span foreground="#008600">"' + str(name) + '" ??????? ??????\n</span>')
dialog.hide()
dialog.destroy()
break
# ??? ??????? ???????????? ?????????? ?????? ???????
评论列表
文章目录