Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界daiding
【摘要】 Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界
目录
输出结果
设计思路
输出结果
设计思路
from tkinter import * import tkinter.simpledialog as dl import tkinter.messagebox as mb ...
Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界
目录
输出结果
设计思路
-
from tkinter import *
-
import tkinter.simpledialog as dl
-
import tkinter.messagebox as mb
-
-
root = Tk()
-
w = Label(root, text = "Guess Number Game")
-
w.pack()
-
-
mb.showinfo("yunyaniu", "Welcome to Guess Number Game")
-
-
number = 2018
-
while True:
-
guess = dl.askinteger("yunyaniu", "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)
-
mb.showinfo("yunyaniu","Thank you for your participation!")
-
-
print('Game over!')
文章来源: yunyaniu.blog.csdn.net,作者:一个处女座的程序猿,版权归原作者所有,如需转载,请联系作者。
原文链接:yunyaniu.blog.csdn.net/article/details/114909474
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)