I am trying to write a custom Yes/No confirmation message. I need to use specific font, button size etc. I would like it to be a function like zzz=myYesNoFunction('Please confirm your choice'). The problem is that my expresion z=questionYesNo() returns no value. Why?
import tkinter as tk
root = tk.Tk()
root.title("Main Window")
#custom messagebox code#########################################
m=""
def check(choice):
global m
if choice=="yes":
message_window.destroy()
m="YES"
else:
message_window.destroy()
m="NO"
def questionYesNo():
global message_window
global m
message_window = tk.Toplevel()
message_window.title("This is Custom messagebox")
label = tk.Label(message_window, text="Please confirm your choice.",
font=("ariel 22 bold"), justify=tk.LEFT)
label.pack(padx=20, pady=15)
no = tk.Button(message_window, text="No", font=("ariel 15 bold"), width=8,
relief=tk.GROOVE, bd=3, command=lambda: check("no"))
no.pack(padx=5, pady=10, side=tk.RIGHT)
yes = tk.Button(message_window, text="Yes", font=("ariel 15 bold"), width=8,
relief=tk.GROOVE,
bd=3, command=lambda: check("yes"))
yes.pack(pady=10, side=tk.RIGHT)
return m
#end of custom messagebox code#########################################
text = tk.Label(root, text="Click on Open button to \nopen questionYesNo window", font=("ariel 20 bold"))
text.pack(padx=30, pady=5,side=tk.TOP)
choicetobeconfirmed = tk.Button(root, text="Open", font=("ariel 20 bold"), width=10,
relief=tk.GROOVE, bd=2, bg='black',fg="gold2", command=questionYesNo)
choicetobeconfirmed.pack(padx=30, pady=15)
z=questionYesNo()
print(z)
root.mainloop()