0

Is it possible to make a Tkinter yes/no messagebox with a checkbox, for something like 'Never ask me again'?

Or would I have to create another window, create my own Labels and CheckButtons, and basically create my own dialog?

LuisAFK
  • 846
  • 4
  • 22
  • You would probably have to create your own dialog. Just remember to use `tkinter.Toplevel` for your custom dialog, not `tkinter.Tk`. – Sylvester Kruin Oct 13 '21 at 18:15
  • you could use the [`Dialog`](https://docs.python.org/3/library/dialog.html#module-tkinter.simpledialog) as a base class to create your own dialog but yes otherwise you will yourself need to create the structure – Matiiss Oct 13 '21 at 18:58
  • Does this answer your question? [Correct way to implement a custom popup tkinter dialog box](https://stackoverflow.com/questions/10057672/correct-way-to-implement-a-custom-popup-tkinter-dialog-box) – Thingamabobs Oct 13 '21 at 20:03

1 Answers1

0

You should create your own dialog box then.

Here’s what you can do:

from tkinter import *

def popup():
    popupWin = Toplevel()
    popupWin.title(“Continue?”)

    checkVariable = IntVar()
   
    lbl = Label(popupWin, text=“Continue?)
    lbl.pack()
   
    btn2 = Button(popupWin, text=“Yes”)
    btn2.pack()
   
    btn3 = Button(popupWin, text=“No”)
    btn3.pack()

    checkBox = Checkbutton(popupWin, text=“Don’t ask again”, variable=checkVariable)

root = Tk()

btn = Button(root, text=Message Box, command=popup)

root.mainloop()
InfoDaneMent
  • 326
  • 3
  • 18