1

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.

2
  • 1
    Have you tried anything? Have you looked up the tkinter module? Commented Mar 18, 2017 at 18:57
  • I did google it for a while, but i didn't really understand, i am newish to python Commented Mar 18, 2017 at 18:59

1 Answer 1

3

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()
Sign up to request clarification or add additional context in comments.

3 Comments

How would you make it so it only asks it once (thanks for the help!)
What do you mean by “only asks once”? Do you mean the same question can’t be asked multiple times? Or do you mean that the window closes after the user selects an option?
Hmmm...I would probably need to see more of your code to make it work, but I’ll put an example up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.