Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter.simpledialog
- import tkinter.messagebox
- root = Tk()
- w = Label(root, text="Menu")
- w.pack()
- choice = 0
- while choice != 5:
- choice = tkinter.simpledialog.askinteger("Order", "Enter the number of what you want to order:\n" +
- "1: pizza\n"+
- "2: hamburger\n"+
- "3: taco\n"+
- "4: donut\n"+
- "5: quit")
- if choice == 1:
- tkinter.messagebox.showinfo("Pizza", "One slice of pizza with extra ANCHOVIES")
- elif choice == 2:
- tkinter.messagebox.showinfo("Hamburger", "Sorry, I ran out of beef. This hamburger is made from donkey meat.")
- elif choice == 3:
- tkinter.messagebox.showinfo("Taco", "One taco de lengua (tongue) coming up.")
- elif choice == 4:
- tkinter.messagebox.showinfo("Donut", "mmm... donuts")
- tkinter.messagebox.showinfo("Thanks", "Thank you, come again!")
- # One good use of a while loop is a menu. Try out the following menu and complete the following:
- #
- # 1. Add your own three creative choices (make them 5, 6, and 7).
- # 2. Move quit to be choice number 8.
- # 3. Adjust the loop so that it will quit when 8 is chosen instead of 5.
- #
- # Extra Credit:
- # Sum up peoples choices and give a summary when they quit.
- # For instance, if 5 people choose pizza, and 1 chooses donut, then they quit,
- # you should output:
- # 5 pizzas, 0 hamburgers, 0 tacos, 1 donuts.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement