• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

python编写简单抽奖系统

python 水墨上仙 3001次浏览

python编写简单抽奖系统

#!/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编写简单抽奖系统
喜欢 (0)
加载中……