#1. GUI from tkinter
#2. 逻辑层
Code:
from tkinter import *
import tkinter.simpledialog as dl
import tkinter.messagebox as mb
#设置GUI
root = Tk()
w = Label(root, text = "Guess Number Game")
w.pack()
#欢迎消息
mb.showinfo("Welcome", "Welcome to Guess Number Game")
#处理信息
number = 59
while True:
#让用户输入信息
guess = dl.askinteger("Number", "What's your guess?")
if guess == number:
# New block starts here
output = 'Bingo! you guessed it right, but you do not win any prizes!'
mb.showinfo("Hint: ", output)
break
# New block ends here
elif guess < number:
output = 'No, the number is a higer than that'
mb.showinfo("Hint: ", output)
else:
output = 'No, the number is a lower than that'
mb.showinfo("Hint: ", output)
print('Done')