if ans:
    print('Yes Pressed')
else:
    print('No Pressed')
root = tk.Tk()
tk.Button(root, text='Click me', command=onClick).pack()
root.mainloop()
Tkinter messagebox not behaving like a modal dialog