Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界
生活随笔
收集整理的這篇文章主要介紹了
Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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 hereoutput = 'Bingo! you guessed it right, but you do not win any prizes!'mb.showinfo("Hint: ", output)break# New block ends hereelif 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!') ??
?
?
?
總結
以上是生活随笔為你收集整理的Py之tkinter:python最简单的猜字小游戏带你进入python的GUI世界的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MAT之PLS:利用PLS(两个主成分的
- 下一篇: 3dmax2014:打开3dmax201