日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

抽奖滚动效果 python_python实现转盘效果 python实现轮盘抽奖游戏

發布時間:2024/3/24 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 抽奖滚动效果 python_python实现转盘效果 python实现轮盘抽奖游戏 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python實現轉盤效果 python實現輪盤抽獎游戲

來源:中文源碼網????瀏覽: 次????日期:2019年11月5日

【下載文檔:??python實現轉盤效果 python實現輪盤抽獎游戲.txt?】

(友情提示:右鍵點上行txt文檔名->目標另存為)

python實現轉盤效果 python實現輪盤抽獎游戲本文實例為大家分享了python實現轉盤效果的具體代碼,供大家參考,具體內容如下#抽獎 面向對象版本

import tkinter

import time

import threading

class choujiang:

#初始化魔術方法

def __init__(self):

#準備好界面

self.root = tkinter.Tk()

self.root.title('lowB版轉盤')

self.root.minsize(300, 300)

# 聲明一個是否按下開始的變量

self.isloop = False

self.newloop = False

#調用設置界面的方法

self.setwindow()

self.root.mainloop()

#界面布局方法

def setwindow(self):

#開始停止按鈕

self.btn_start = tkinter.Button(self.root, text = 'start/stop',command = self.newtask)

self.btn_start.place(x=90, y=125, width=50, height=50)

self.btn1 = tkinter.Button(self.root, text='趙', bg='red')

self.btn1.place(x=20, y=20, width=50, height=50)

self.btn2 = tkinter.Button(self.root, text='錢', bg='white')

self.btn2.place(x=90, y=20, width=50, height=50)

self.btn3 = tkinter.Button(self.root, text='孫', bg='white')

self.btn3.place(x=160, y=20, width=50, height=50)

self.btn4 = tkinter.Button(self.root, text='李', bg='white')

self.btn4.place(x=230, y=20, width=50, height=50)

self.btn5 = tkinter.Button(self.root, text='周', bg='white')

self.btn5.place(x=230, y=90, width=50, height=50)

self.btn6 = tkinter.Button(self.root, text='吳', bg='white')

self.btn6.place(x=230, y=160, width=50, height=50)

self.btn7 = tkinter.Button(self.root, text='鄭', bg='white')

self.btn7.place(x=230, y=230, width=50, height=50)

self.btn8 = tkinter.Button(self.root, text='王', bg='white')

self.btn8.place(x=160, y=230, width=50, height=50)

self.btn9 = tkinter.Button(self.root, text='馮', bg='white')

self.btn9.place(x=90, y=230, width=50, height=50)

self.btn10 = tkinter.Button(self.root, text='陳', bg='white')

self.btn10.place(x=20, y=230, width=50, height=50)

self.btn11 = tkinter.Button(self.root, text='褚', bg='white')

self.btn11.place(x=20, y=160, width=50, height=50)

self.btn12 = tkinter.Button(self.root, text='衛', bg='white')

self.btn12.place(x=20, y=90, width=50, height=50)

# 將所有選項組成列表

self.girlfrends = [self.btn1,self.btn2,self.btn3,self.btn4,self.btn5,self.btn6,self.btn7,self.btn8,self.btn9,self.btn10,self.btn11,self.btn12]

def rounds(self):

# 判斷是否開始循環

if self.isloop == True:

return

# 初始化計數 變量

i = 0

# 死循環

while True:

if self.newloop == True:

self.newloop = False

return

# 延時操作

time.sleep(0.1)

# 將所有的組件背景變為白色

for x in self.girlfrends:

x['bg'] = 'white'

# 將當前數值對應的組件變色

self.girlfrends[i]['bg'] = 'red'

# 變量+1

i += 1

# 如果i大于最大索引直接歸零

if i >= len(self.girlfrends):

i = 0

# 建立一個新線程的函數

def newtask(self):

if self.isloop == False:

# 建立線程

t = threading.Thread(target = self.rounds)

# 開啟線程運行

t.start()

# 設置循環開始標志

self.isloop = True

elif self.isloop == True:

self.isloop = False

self.newloop = True

c = choujiang()小編再為大家分享一款python模擬輪盤抽獎的游戲

python3.x的版本測試中文的變量名

from random import random

#輪盤賭lpd,獎項分布jxfb,本次轉盤讀數bclpds,中獎情況zjqk,本次戰況bczk,

def lpd(jxfb):

bclpds = random()

for k, v in jxfb.items():

if v[0]<=bclpdsreturn kjxfb = {'一等獎':(0, 0.08),

'二等獎':(0.08, 0.3),

'三等獎':(0.3, 1.0)}zjqk = dict()

#模擬玩10000次,統計中獎情況

for i in range(10000):

bczk = lpd(jxfb)

zjqk[bczk] = zjqk.get(bczk, 0) + 1for item in zjqk.items():

print(item)

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持中文源碼網。

親,試試微信掃碼分享本頁!?*^_^*

總結

以上是生活随笔為你收集整理的抽奖滚动效果 python_python实现转盘效果 python实现轮盘抽奖游戏的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。