from tkinter import *
import tkinter.messagebox as mb
import tkinter.simpledialog as dl
root = Tk()
w = Label(root, text = 'Guess Number Game')
w.pack()
mb.showinfo('Wellcome', 'Wellcome to guess number game')
number = 10
while True:
guess = dl.askinteger('Number', 'Enter an integer:')
if int(guess) == number:
mb.showinfo('Hint','Bingo! you guessed it right!')
break
elif int(guess) > number:
mb.showinfo('Hint', 'you guessed it higher than that!')
else:
mb.showinfo('Hint', 'you guessed it lower than that!')
来源:oschina
链接:https://my.oschina.net/jugier/blog/4269390