Reputation: 114
How would I make it it so a pop up box (If you have better name for it comment below) appear asking you a question. It would have one button saying I agree and another saying I disagree.
Upvotes: 1
Views: 2229
Reputation: 5660
Here’s a simple one I suppose:
import tkinter as tk
root = tk.Tk()
questionsAsked = []
def yes():
#do stuff if the user says yes
pass
def no():
#do stuff if the user says no
pass
def modal(question):
if question in questionsAsked:
return False
questionsAsked.append(question)
label = tk.Label(root, text=question)
bYes = tk.Button(root, text="Yes", command=yes)
bNo = tk.Button(root, text="No", command=no)
for el in [label, bYes, bNo]:
el.pack()
modal("Do you want to continue?")
root.mainloop()
Upvotes: 3