Making a custom message box using tinter

Go To StackoverFlow.com

1

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


3

(1) By message box do you mean something like this? http://www.java2s.com/Code/Python/GUI-Tk/Creatingasimpledialog.htm

(2)

 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


0

You can use PyMsgBox to do this. Install it with pip install pymsgbox. The documentation is at https://pymsgbox.readthedocs.io/en/latest/

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