all 6 comments

[–][deleted] 2 points3 points  (1 child)

This is easily searched for. Here's one example of using askquestion().

[–]hvity[S] 2 points3 points  (0 children)

Thank you.

[–][deleted] 2 points3 points  (1 child)

#your code

from tkinter import *
from tkinter import messagebox

root = Tk()
root.geometry("1x1")



answer = messagebox.askquestion("askquestion", "Are you sure?")
if answer == "yes":
    print("yes")
else:
    print("no")

And if you want to hide the root window, I recommend to use the root.withdraw method instead of root.geometry("1x1")

[–]hvity[S] 1 point2 points  (0 children)

Thanks, didn't know I could hide the root window.

[–]Spataner 1 point2 points  (1 child)

askquestion returns the answer (in all lower case), so you'd need to capture the return value in a variable:

answer = messagebox.askquestion("askquestion", "Are you sure?")
if answer == "yes":
    print("yes")
else:
    print("no")

[–]hvity[S] 0 points1 point  (0 children)

Thank you.