A sample of all dialog boxes.
26"""The items of this dictionary are tuples with
27 - the name of the function to call
28 - its named parameters
30DIALOGS = { "Ok - Cancel": (Ntk.askokcancel, {"message":" Do you want to proceed? "}),
31 "Yes - No": (Ntk.askquestion, {
"message":
" Exit from the application? "}),
32 "Retry - Cancel": (Ntk.askretrycancel, {
"message":
" Do you want to retry? "}),
33 "Yes - No - Cancel": (Ntk.askyesnocancel, {
"message":
" Exit from the application? "}),
34 "Error": (Ntk.showerror, {
"message":
" File not found "}),
35 "Info": (Ntk.showinfo, {
"message":
" File saved "}),
36 "Warning": (Ntk.showwarning, {
"message":
" Data could be corrupted "}),
37 "Open File": (Ntk.askopenfilename, {}),
38 "Save as File": (Ntk.asksaveasfilename, {
"initialfile":
"untitled.py"}),
39 "Open Files": (Ntk.askopenfilenames, {}),
40 "Choose Directory": (Ntk.askdirectory, {}),
41 "Choose color": (Ntk.askcolor, {
"color":
"#FF0000"})
45def open_dialog(event):
46 key = cmbType.get_content()
47 func, arg = DIALOGS[key][0], DIALOGS[key][1]
48 result = func(title=key +
" dialog", **arg)
49 diagResult.set(
"The dialog box returned:\n" + result.__repr__())
53winMain = Ntk.Main(200, 150, 500, 400,
"Dialog sample")
54winMain.config_children(ALL, font=(
"Arial", 16))
58butOpen= Ntk.Button(winMain, CENTER, 20, 320, 60, pad=10,
59 content=
"Open a dialog box", command=open_dialog)
60butOpen.config(bcolor=
"#C0F0C0", fcolor=
"#2020C0")
63cmbType = Ntk.Combobox(winMain, CENTER, PACK, 320, 80, pad=10,
64 items=tuple(DIALOGS.keys()))
66diagResult = Ntk.StringVar(value=
"")
68labResult = Ntk.Label(winMain, CENTER, PACK, 400, 160, pad=10, content=diagResult)
69labResult.config(bcolor=
"#FFFFC0", fcolor=
"#202060", relief=RIDGE, anchor=CENTER)
Definition: constants.py:1