-
大小: 4KB文件類型: .py金幣: 2下載: 1 次發(fā)布日期: 2024-03-19
- 語言: Python
- 標簽: python??python實戰(zhàn)??
資源簡介
利用python對抽獎大轉盤進行簡易實現。
采用圖形界面的效果,利用兩個按鈕實現對于轉盤的控制。
(此為某網絡課程中的詳細實現)
代碼片段和文件信息
#嗶哩嗶哩視頻改編
‘‘‘
原理分析??寫文檔的能力
1>用python開發(fā)一個圖形界面的效果
2>有12個備選選項和2個功能按鈕
3>確定備選選項的和功能按鈕的位置
每一個備選選項的xy(橫豎)都有相同的間隔
功能按鈕的字圖形界面的中間
4>點擊開始會不斷旋轉,點擊停止按鈕的時候,選中選項的背景顏色?為紅色,沒被選中的選項的背景顏色為白色
‘‘‘
#-*-?coding:UTF-8?-*-
import?tkinter
import?threading
import?time
#1.生成主窗口,設置窗口的標題,大小
root?=?tkinter.Tk()
root.title(“抽獎小程序“)
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元話費‘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=‘現金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=‘藍牙耳機‘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>將所有選項添加到列表中?python基礎看列表掌握情況
herolists?=?[btn1btn2btn3btn4btn5btn6btn7btn8btn9btn
- 上一篇:雙邊濾波器實驗報告及代碼python
- 下一篇:python簡明教程.chm
評論
共有 條評論