Making a custom message box using tinter

Go To


I'm looking to make a three way message box in tkinter. Something like, "do you want chocolate milk, lemonade, or sprite" and then buttons for each of the 3 at the bottom. As an aside, is it possible to make python "knock out" numbers when counting. So say I'm adding counting from 10 to 60, could I make python skip over every 7 and 8?

2012-04-03 22:29
by Mission Impossible


(1) By message box do you mean something like this?


 for i in range(6):
    for j in range(10):
        if j in [7,8]: continue
        print i*10+j

prints all numbers 0-59 skipping if it ends in 7 or 8.

2012-04-03 22:56
by apple16
1) Kind of, I was wanting three buttons on the bottom (chocolate milk, lemonade, sprite), and for sprite to return sprite to the program. 2) That's great, TH - Mission Impossible 2012-04-04 13:36


You can use PyMsgBox to do this. Install it with pip install pymsgbox. The documentation is at

The code to do your example is:

>>> import pymsgbox
>>> drink_choice = pymsgbox.confirm('What drink do you want?', 'Title', ['Chocolate milk', 'Lemonade', 'Sprite'])
2017-03-20 01:33
by Al Sweigart