Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python3..../tkinter
File: messagebox.py
# tk common message boxes
[0] Fix | Delete
#
[1] Fix | Delete
# this module provides an interface to the native message boxes
[2] Fix | Delete
# available in Tk 4.2 and newer.
[3] Fix | Delete
#
[4] Fix | Delete
# written by Fredrik Lundh, May 1997
[5] Fix | Delete
#
[6] Fix | Delete
[7] Fix | Delete
#
[8] Fix | Delete
# options (all have default values):
[9] Fix | Delete
#
[10] Fix | Delete
# - default: which button to make default (one of the reply codes)
[11] Fix | Delete
#
[12] Fix | Delete
# - icon: which icon to display (see below)
[13] Fix | Delete
#
[14] Fix | Delete
# - message: the message to display
[15] Fix | Delete
#
[16] Fix | Delete
# - parent: which window to place the dialog on top of
[17] Fix | Delete
#
[18] Fix | Delete
# - title: dialog title
[19] Fix | Delete
#
[20] Fix | Delete
# - type: dialog type; that is, which buttons to display (see below)
[21] Fix | Delete
#
[22] Fix | Delete
[23] Fix | Delete
from tkinter.commondialog import Dialog
[24] Fix | Delete
[25] Fix | Delete
#
[26] Fix | Delete
# constants
[27] Fix | Delete
[28] Fix | Delete
# icons
[29] Fix | Delete
ERROR = "error"
[30] Fix | Delete
INFO = "info"
[31] Fix | Delete
QUESTION = "question"
[32] Fix | Delete
WARNING = "warning"
[33] Fix | Delete
[34] Fix | Delete
# types
[35] Fix | Delete
ABORTRETRYIGNORE = "abortretryignore"
[36] Fix | Delete
OK = "ok"
[37] Fix | Delete
OKCANCEL = "okcancel"
[38] Fix | Delete
RETRYCANCEL = "retrycancel"
[39] Fix | Delete
YESNO = "yesno"
[40] Fix | Delete
YESNOCANCEL = "yesnocancel"
[41] Fix | Delete
[42] Fix | Delete
# replies
[43] Fix | Delete
ABORT = "abort"
[44] Fix | Delete
RETRY = "retry"
[45] Fix | Delete
IGNORE = "ignore"
[46] Fix | Delete
OK = "ok"
[47] Fix | Delete
CANCEL = "cancel"
[48] Fix | Delete
YES = "yes"
[49] Fix | Delete
NO = "no"
[50] Fix | Delete
[51] Fix | Delete
[52] Fix | Delete
#
[53] Fix | Delete
# message dialog class
[54] Fix | Delete
[55] Fix | Delete
class Message(Dialog):
[56] Fix | Delete
"A message box"
[57] Fix | Delete
[58] Fix | Delete
command = "tk_messageBox"
[59] Fix | Delete
[60] Fix | Delete
[61] Fix | Delete
#
[62] Fix | Delete
# convenience stuff
[63] Fix | Delete
[64] Fix | Delete
# Rename _icon and _type options to allow overriding them in options
[65] Fix | Delete
def _show(title=None, message=None, _icon=None, _type=None, **options):
[66] Fix | Delete
if _icon and "icon" not in options: options["icon"] = _icon
[67] Fix | Delete
if _type and "type" not in options: options["type"] = _type
[68] Fix | Delete
if title: options["title"] = title
[69] Fix | Delete
if message: options["message"] = message
[70] Fix | Delete
res = Message(**options).show()
[71] Fix | Delete
# In some Tcl installations, yes/no is converted into a boolean.
[72] Fix | Delete
if isinstance(res, bool):
[73] Fix | Delete
if res:
[74] Fix | Delete
return YES
[75] Fix | Delete
return NO
[76] Fix | Delete
# In others we get a Tcl_Obj.
[77] Fix | Delete
return str(res)
[78] Fix | Delete
[79] Fix | Delete
[80] Fix | Delete
def showinfo(title=None, message=None, **options):
[81] Fix | Delete
"Show an info message"
[82] Fix | Delete
return _show(title, message, INFO, OK, **options)
[83] Fix | Delete
[84] Fix | Delete
[85] Fix | Delete
def showwarning(title=None, message=None, **options):
[86] Fix | Delete
"Show a warning message"
[87] Fix | Delete
return _show(title, message, WARNING, OK, **options)
[88] Fix | Delete
[89] Fix | Delete
[90] Fix | Delete
def showerror(title=None, message=None, **options):
[91] Fix | Delete
"Show an error message"
[92] Fix | Delete
return _show(title, message, ERROR, OK, **options)
[93] Fix | Delete
[94] Fix | Delete
[95] Fix | Delete
def askquestion(title=None, message=None, **options):
[96] Fix | Delete
"Ask a question"
[97] Fix | Delete
return _show(title, message, QUESTION, YESNO, **options)
[98] Fix | Delete
[99] Fix | Delete
[100] Fix | Delete
def askokcancel(title=None, message=None, **options):
[101] Fix | Delete
"Ask if operation should proceed; return true if the answer is ok"
[102] Fix | Delete
s = _show(title, message, QUESTION, OKCANCEL, **options)
[103] Fix | Delete
return s == OK
[104] Fix | Delete
[105] Fix | Delete
[106] Fix | Delete
def askyesno(title=None, message=None, **options):
[107] Fix | Delete
"Ask a question; return true if the answer is yes"
[108] Fix | Delete
s = _show(title, message, QUESTION, YESNO, **options)
[109] Fix | Delete
return s == YES
[110] Fix | Delete
[111] Fix | Delete
[112] Fix | Delete
def askyesnocancel(title=None, message=None, **options):
[113] Fix | Delete
"Ask a question; return true if the answer is yes, None if cancelled."
[114] Fix | Delete
s = _show(title, message, QUESTION, YESNOCANCEL, **options)
[115] Fix | Delete
# s might be a Tcl index object, so convert it to a string
[116] Fix | Delete
s = str(s)
[117] Fix | Delete
if s == CANCEL:
[118] Fix | Delete
return None
[119] Fix | Delete
return s == YES
[120] Fix | Delete
[121] Fix | Delete
[122] Fix | Delete
def askretrycancel(title=None, message=None, **options):
[123] Fix | Delete
"Ask if operation should be retried; return true if the answer is yes"
[124] Fix | Delete
s = _show(title, message, WARNING, RETRYCANCEL, **options)
[125] Fix | Delete
return s == RETRY
[126] Fix | Delete
[127] Fix | Delete
[128] Fix | Delete
# --------------------------------------------------------------------
[129] Fix | Delete
# test stuff
[130] Fix | Delete
[131] Fix | Delete
if __name__ == "__main__":
[132] Fix | Delete
[133] Fix | Delete
print("info", showinfo("Spam", "Egg Information"))
[134] Fix | Delete
print("warning", showwarning("Spam", "Egg Warning"))
[135] Fix | Delete
print("error", showerror("Spam", "Egg Alert"))
[136] Fix | Delete
print("question", askquestion("Spam", "Question?"))
[137] Fix | Delete
print("proceed", askokcancel("Spam", "Proceed?"))
[138] Fix | Delete
print("yes/no", askyesno("Spam", "Got it?"))
[139] Fix | Delete
print("yes/no/cancel", askyesnocancel("Spam", "Want it?"))
[140] Fix | Delete
print("try again", askretrycancel("Spam", "Try again?"))
[141] Fix | Delete
[142] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function