forked from kadircet/ieeemetu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgiveaway.py
executable file
·59 lines (52 loc) · 1.52 KB
/
giveaway.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from Tkinter import *
import tkFont
from random import random as rand
from time import sleep
idu=0
def randUser(i=0,n=300):
global idu
if i==0:
root.after_cancel(idu)
userLb.config(fg="white")
elif i==-1:
userTx.set(userTx.get()[3:-3])
idu=root.after(300, randUser, n)
return
elif i==n:
userLb.config(fg="red")
userTx.set("***"+userTx.get()+"***")
idu=root.after(300, randUser, -1)
return
userTx.set(int(rand()*n)+1)
root.after(int(2**(i*8./n)), randUser, i+1)
idg = 0
def randGift(i=0, n=300):
global idg
gifts=["a", "b", "c", "d"]
if i==0:
root.after_cancel(idg)
giftLb.config(fg="white")
elif i==-1:
giftTx.set(giftTx.get()[3:-3])
idg = root.after(300, randGift, n)
return
elif i==n:
giftLb.config(fg="red")
giftTx.set("***"+giftTx.get()+"***")
idg = root.after(300, randGift, -1)
return
giftTx.set(gifts[int(rand()*len(gifts))])
root.after(int(2**(i*8./n)), randGift, i+1)
root = Tk()
customFont = tkFont.Font(family="Helvetica", size=50)
userTx = StringVar()
giftTx = StringVar()
userLb = Label(root, textvariable=userTx, width=20, height=2, font=customFont)
giftLb = Label(root, textvariable=giftTx, width=20, height=2, font=customFont)
randUsr=Button(root, text="Choose User", command=randUser)
randGft=Button(root, text="Choose Gift", command=randGift)
userLb.pack()
giftLb.pack()
randUsr.pack(side=LEFT)
randGft.pack(side=RIGHT)
root.mainloop()