您的位置:首页 > 编程语言 > Python开发

python基础课题开发小游戏

2018-01-24 11:01 393 查看
'''
Created on 2018年1月24日

@author: Vision_TXG
'''

#导入tkinter库
from tkinter import *
import tkinter.simpledialog as dl
import tkinter.messagebox as mb  #信息框

#Tk()是tkinter自带的构造函数,主函数的显示框
root  = Tk()

#标签  标签的显示框和标题
w = Label(root,text = "Lable Title")

#自带调节标签大小
w.pack()

#进入画面
mb.showinfo("Welcome", "Welcome to Guess Number Game")

number = 66

while True:
#提供一个给用户输入的对话框
guess = dl.askinteger("Number", "What's you guess?")
if guess == number:
output = "Bingo! you guessed it right"
mb.showinfo("Hint:",output)
break
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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: