-
大小: 4KB文件類型: .py金幣: 2下載: 1 次發(fā)布日期: 2024-03-19
- 語言: Python
- 標(biāo)簽: python??python實(shí)戰(zhàn)??
資源簡介
利用python對(duì)抽獎(jiǎng)大轉(zhuǎn)盤進(jìn)行簡易實(shí)現(xiàn)。
采用圖形界面的效果,利用兩個(gè)按鈕實(shí)現(xiàn)對(duì)于轉(zhuǎn)盤的控制。
(此為某網(wǎng)絡(luò)課程中的詳細(xì)實(shí)現(xiàn))
代碼片段和文件信息
#嗶哩嗶哩視頻改編
‘‘‘
原理分析??寫文檔的能力
1>用python開發(fā)一個(gè)圖形界面的效果
2>有12個(gè)備選選項(xiàng)和2個(gè)功能按鈕
3>確定備選選項(xiàng)的和功能按鈕的位置
每一個(gè)備選選項(xiàng)的xy(橫豎)都有相同的間隔
功能按鈕的字圖形界面的中間
4>點(diǎn)擊開始會(huì)不斷旋轉(zhuǎn),點(diǎn)擊停止按鈕的時(shí)候,選中選項(xiàng)的背景顏色?為紅色,沒被選中的選項(xiàng)的背景顏色為白色
‘‘‘
#-*-?coding:UTF-8?-*-
import?tkinter
import?threading
import?time
#1.生成主窗口,設(shè)置窗口的標(biāo)題,大小
root?=?tkinter.Tk()
root.title(“抽獎(jiǎng)小程序“)
root.minsize(300300)
#2.擺放按鈕,按鈕的位置,大小
btn1?=?tkinter.Button(roottext=‘iPhone‘bg=‘red‘)
btn1.place(x=20y=20width=50height=50)
btn2?=?tkinter.Button(roottext=‘10元優(yōu)惠‘bg=‘white‘)
btn2.place(x=90y=20width=50height=50)
btn3?=?tkinter.Button(roottext=‘小豬公仔‘bg=‘white‘)
btn3.place(x=160y=20width=50height=50)
btn4?=?tkinter.Button(roottext=‘謝謝參與‘bg=‘white‘)
btn4.place(x=230y=20width=50height=50)
btn5?=?tkinter.Button(roottext=‘50元話費(fèi)‘bg=‘white‘)
btn5.place(x=20y=90width=50height=50)
btn6?=?tkinter.Button(roottext=‘掛鏈‘bg=‘white‘)
btn6.place(x=20y=160width=50height=50)
btn7?=?tkinter.Button(roottext=‘明星簽名‘bg=‘white‘)
btn7.place(x=230y=230width=50height=50)
btn8?=?tkinter.Button(roottext=‘現(xiàn)金10元‘bg=‘white‘)
btn8.place(x=160y=230width=50height=50)
btn9?=?tkinter.Button(roottext=‘謝謝參與‘bg=‘white‘)
btn9.place(x=90y=230width=50height=50)
btn10?=?tkinter.Button(roottext=‘藍(lán)牙耳機(jī)‘bg=‘white‘)
btn10.place(x=20y=230width=50height=50)
btn11?=?tkinter.Button(roottext=‘手表‘bg=‘white‘)
btn11.place(x=230y=160width=50height=50)
btn12?=?tkinter.Button(roottext=‘墨鏡‘bg=‘white‘)
btn12.place(x=230y=90width=50height=50)
#2.1>將所有選項(xiàng)添加到列表中?python基礎(chǔ)看列表掌握情況
herolists?=?[btn1btn2btn3btn4btn5btn6btn7btn8btn9btn
評(píng)論
共有 條評(píng)論