python實(shí)現(xiàn)的簡單抽獎(jiǎng)系統(tǒng)實(shí)例
本文實(shí)例講述了python實(shí)現(xiàn)的簡單抽獎(jiǎng)系統(tǒng)。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
#!/usr/bin/env python
#coding=utf-8
from Tkinter import *
import time
import random
class App:
def __init__(self,master):
frame = Frame(master)
frame.pack()
v = StringVar()
self.e = Entry(frame,textvariable=v,bd='5')
v.set('')
self.v = v
self.e.pack(padx=5)
self.button1 = Button(frame,text = 'start',fg='red',command=self.start_hi)
self.button1.pack(side=LEFT)
self.button2 = Button(frame,text='stop',fg = 'blue',command=self.say_stop)
self.button2.pack(side=LEFT)
self.root=master
self.stop = 0
#scrollbar = Scrollbar(frame, orient=VERTICAL)
#self.b1 = Listbox(frame, yscrollcommand=scrollbar.set)
#scrollbar.pack(side=RIGHT, fill=Y)
#self.b1.pack(side=LEFT, fill=BOTH, expand=1)
def list_star(self):
star = []
file = open('yaojiang.txt','r+')
data = file.readlines()
file.close()
for n in data:
l1 = n.split(':')
a = l1[0] + ':'+ l1[1][:4] + 'xxxx' + l1[1][8:12]
a = a.strip()
star.append(a)
return star
def start_hi(self):
self.stop = 0
#star = []
#file = open('yaojiang.txt','r+')
#data = file.readlines()
#file.close()
#for n in data:
#l1 = n.split(':')
#a = l1[0] + ':'+ l1[1][:4] + 'xxxx' + l1[1][8:12]
#a = a.strip()
#star.append(a)
star = self.list_star()
self.update_clock(star)
def say_stop(self):
self.stop = 1
#b = self.start()
def update_clock(self,star):
b = random.choice(star)
self.v.set(b)
if self.stop == 1:
return
self.root.after(50, self.update_clock,star)
root = Tk()
app = App(root)
root.mainloop()
希望本文所述對大家的Python程序設(shè)計(jì)有所幫助。
- 如何基于python實(shí)現(xiàn)年會抽獎(jiǎng)工具
- Python使用Tkinter實(shí)現(xiàn)轉(zhuǎn)盤抽獎(jiǎng)器的步驟詳解
- Python實(shí)現(xiàn)的企業(yè)粉絲抽獎(jiǎng)功能示例
- 詳解用python寫一個(gè)抽獎(jiǎng)程序
- python3實(shí)現(xiàn)小球轉(zhuǎn)動(dòng)抽獎(jiǎng)小游戲
- python實(shí)現(xiàn)抽獎(jiǎng)小程序
- python實(shí)現(xiàn)年會抽獎(jiǎng)程序
- python實(shí)現(xiàn)公司年會抽獎(jiǎng)程序
- 編寫python代碼實(shí)現(xiàn)簡單抽獎(jiǎng)器
相關(guān)文章
Python使用Kafka處理數(shù)據(jù)的方法詳解
Kafka是一個(gè)分布式的流數(shù)據(jù)平臺,它可以快速地處理大量的實(shí)時(shí)數(shù)據(jù)。在Python中使用Kafka可以幫助我們更好地處理大量的數(shù)據(jù),本文就來和大家詳細(xì)講講具體使用方法吧2023-04-04
Django?Rest?Framework實(shí)現(xiàn)身份認(rèn)證源碼詳解
這篇文章主要為大家介紹了Django?Rest?Framework實(shí)現(xiàn)身份認(rèn)證源碼詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
python正則表達(dá)式re.sub各個(gè)參數(shù)的超詳細(xì)講解
Python 的 re 模塊提供了re.sub用于替換字符串中的匹配項(xiàng),下面這篇文章主要給大家介紹了關(guān)于python正則表達(dá)式re.sub各個(gè)參數(shù)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07
Django項(xiàng)目實(shí)戰(zhàn)之配置文件詳解
這篇文章主要給大家介紹了關(guān)于Django項(xiàng)目實(shí)戰(zhàn)之配置文件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04
淺談Python在pycharm中的調(diào)試(debug)
今天小編就為大家分享一篇淺談Python在pycharm中的調(diào)試(debug),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-11-11
淺談python腳本設(shè)置運(yùn)行參數(shù)的方法
今天小編就為大家分享一篇淺談python腳本設(shè)置運(yùn)行參數(shù)的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-12-12
Pytorch 如何加速Dataloader提升數(shù)據(jù)讀取速度
這篇文章主要介紹了Pytorch 加速Dataloader提升數(shù)據(jù)讀取速度的操作,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-05-05

