Python gtk 模块,BUTTONS_YES_NO 实例源码
我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用gtk.BUTTONS_YES_NO。
def _confirm_experimental(self, rclass):
sql_key = "warn_experimental_%s" % directory.radio_class_id(rclass)
if CONF.is_defined(sql_key, "state") and \
not CONF.get_bool(sql_key, "state"):
return True
title = _("Proceed with experimental driver?")
text = rclass.get_prompts().experimental
msg = _("This radio's driver is experimental. "
"Do you want to proceed?")
resp, squelch = common.show_warning(msg, text,
title=title,
buttons=gtk.BUTTONS_YES_NO,
can_squelch=True)
if resp == gtk.RESPONSE_YES:
CONF.set_bool(sql_key, not squelch, "state")
return resp == gtk.RESPONSE_YES
def do_toggle_report(self, action):
if not action.get_active():
d = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO, parent=self)
markup = "<b><big>" + _("Reporting is disabled") + "</big></b>"
d.set_markup(markup)
msg = _("The reporting feature of CHIRP is designed to help "
"<u>improve quality</u> by allowing the authors to focus "
"on the radio drivers used most often and errors "
"experienced by the users. The reports contain no "
"identifying information and are used only for "
"statistical purposes by the authors. Your privacy is "
"extremely important, but <u>please consider leaving "
"this feature enabled to help make CHIRP better!</u>\n\n"
"<b>Are you sure you want to disable this feature?</b>")
d.format_secondary_markup(msg.replace("\n", "\r\n"))
r = d.run()
d.destroy()
if r == gtk.RESPONSE_NO:
action.set_active(not action.get_active())
conf = config.get()
conf.set_bool("no_report", not action.get_active())
def show_confirmation_dialog(self, msg):
dialog = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
gtk.BUTTONS_YES_NO, msg)
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
return True
return False
def ask(query, parent=None):
dia = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, query)
dia.show()
rtn=dia.run()
dia.destroy()
return rtn == gtk.RESPONSE_YES
def ask(self, query):
dia = gtk.MessageDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, query)
dia.show()
rtn=dia.run()
dia.destroy()
return rtn == gtk.RESPONSE_YES
def confirmDialog(parent=None, message="Confirm?"):
"""Creates a confirmation dialog and returns the response."""
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, message)
dialog.show()
response = dialog.run()
dialog.destroy()
return response
def ask_yesno_question(msg, parent=None):
d = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO, parent=parent,
type=gtk.MESSAGE_QUESTION)
d.set_property("text", msg)
if not parent:
d.set_position(gtk.WIN_POS_CENTER_ALWAYS)
r = d.run()
d.destroy()
return r == gtk.RESPONSE_YES