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

Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界——daidingdaiding

2020-01-11 07:57 841 查看

Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界——daidingdaiding

 

 

 

目录

输出结果

设计思路

 

 

 

 

 

 

输出结果

 

设计思路

[code]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!')  

 

 

 

 

 

 

 

 

 

 

 

  • 点赞 1
  • 收藏
  • 分享
  • 文章举报
一个处女座的程序猿 博客专家 发布了1560 篇原创文章 · 获赞 6062 · 访问量 1158万+ 他的留言板 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐