-
Notifications
You must be signed in to change notification settings - Fork 0
/
luckygod.py
executable file
·498 lines (422 loc) · 15.3 KB
/
luckygod.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
'''
-*-coding:UTF-8-*-
enviro: python3.12.4
Program function: This program is a lucky draw assistant, which can be used in class, party, etc.
This program is made by the greatest Eden Li, and the program is open source.
If you want to distribute this program, please contact the author.
If you want to use this program for commercial purposes, please contact the author.
If you want to use this program for illegal purposes, JUST DO IT and GOOD LUCK BRO.
'''
'''
------------------------------------------------------------------
|☺LuckyGod5.0 - Lottery Assistant |-|口|X|
------------------------------------------------------------------
|File|Mode|Gallery|Sound|About| |
------------------------------------------------------------------
| 十 · 一 · · | | | -- --- ---------- |
| 一 一 一 ---- - 曰 | | |_ | | | 0| |
| ¥ —___△___ ------- | | | _| .|__| |--------- |
| |
| __________________________________________________ _ |
|| | - - |
|| | - - - |
|| | - - |
|| | - |
|| | |
|| | |
|| | —————————— |
|| ||People 33| |
|| | —————————— |
|| | |
|| |Remain32people|
|| | |
|| | 口 Sound |
|| | |
|| | |
|| | |
|| | _____ |
|| | |START| |
|| | ----- |
|| | _____ |
|| | |STOP| |
|| | ----- |
|| | _____ |
|| | |EXIT| |
||__________________________________________________| ---- |
|________________________________________________________________|
'''
import random
from tkinter import *
import pygame as py
import tkinter as tk
import tkinter.messagebox
import threading
from PIL import Image, ImageTk
import cv2
import webbrowser
import time
import sys
#from os import environ
#environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
#########INIT##########
root= tk.Tk()
root.geometry("520x495")#The size of the window
root.title('LuckyGod5.0 - Lottery Assistant')#The title of the window
root.resizable(False,False)#The window can't be resized
root.iconbitmap('main.ico')#The icon of the window
root.flag = True
img = [None]
path = 'picture/gallery1/'
number_of_people = []
#The number of people
number_of_people.clear()
for i in range(1,34):
number_of_people.append(i)
###########################################################
#########################交互界面###########################
###########################################################
py.mixer.init()
musound = r'music/music1.mp3'
def sound1():
global musound
musound = r'music/music1.mp3'
def sound2():
global musound
musound = r'music/music2.mp3'
def sound3():
global musound
musound = r'music/music2.mp3'
def sound4():
global musound
musound = r'music/music2.mp3'
def sound5():
global musound
musound = r'music/music2.mp3'
def sound_start():
global musound
py.mixer.music.load(musound)
py.mixer.music.play(-1,0)
def sound_stop():
py.mixer.music.stop()
def fast_mode():
status["foreground"] = 'green'
time.sleep(0.1)
people = int(human.get())
xuanze = random.randrange(1,people+1)#This place must be added one
count_bar['text']=xuanze
filename = path + str(xuanze) + '.jpg'
img1 = cv2.imread(filename)
im1 = Image.fromarray(cv2.cvtColor(img1,cv2.COLOR_BGR2RGB))
img[0] = ImageTk.PhotoImage(image = im1)
photos.config(image=img[0])
root.update_idletasks()
status["foreground"] = 'red'
def status_colour_green():
t=threading.Thread(target=default_mode)
t.start()
sound_start()
status["foreground"] = 'green'
def status_colour_red():
root.flag = False
sound_stop()
status["foreground"] = 'red'
def no_duplication_mode_start():
if len(set(number_of_people))== 0:
tk.messagebox.showinfo("Information", "The number of people is 0, please reset the number of people.")
else:
a=threading.Thread(target=no_duplication_mode)
a.start()
sound_start()
status["foreground"] = 'green'
remainingPeople = tk.Label(root,
text="Remain 33 people")
remainingPeople.place(x=440, y=260, width=51, height=16)
remainingPeople.place_forget()
def no_duplication_mode_stop ():
root.flag = False
sound_stop()
status["foreground"] = 'red'
xuanze = int(random.choice(number_of_people))
count_bar['text']=xuanze
filename = path + str(xuanze) + '.jpg'
img1 = cv2.imread(filename)
im1 = Image.fromarray(cv2.cvtColor(img1,cv2.COLOR_BGR2RGB))
img[0] = ImageTk.PhotoImage(image = im1)
photos.config(image=img[0])
root.update_idletasks()
number_of_people.remove(xuanze)
remainingPeople['text']="Remain "+str(len(set(number_of_people)))+" people"
#########标题##########
biaoti = tk.Label(root,
text='LuckyGod V5.0', # The title of the window
font=('Arial', 48), # The font of the title
foreground='lightskyblue', #The color of the title
width=15, height=2 # The size of the title
)
biaoti.place(x=10, y=10, width=400, height=60)
##########菜单##########
menu0=Menu(root)#The menu of the window
#文件菜单
file=Menu(menu0,tearoff=False)#Define the menu name that can't be dragged
file.add_command(label= str('START Up'),
command = status_colour_green
)
file.add_command(label= str('STOP Down'),
command = status_colour_red
)
file.add_command(label= str('EXIT'),
command = sys.exit
)
menu0.add_cascade(label='File',menu=file)
#模式菜单
def changeto1():
fastb.place_forget()
resetb.place_forget()
norestart.place_forget()
norestop.place_forget()
remainingPeople.place_forget()
startb.place(x=410, y=295, width=100, height=50)
stopb.place(x=410, y=355, width=100, height=50)
exitb.place(x=410, y=415, width=100, height=50)
def changeto2():
startb.place_forget()
stopb.place_forget()
exitb.place_forget()
resetb.place_forget()
norestart.place_forget()
norestop.place_forget()
remainingPeople.place_forget()
fastb.place(x=410, y=295, width=100, height=170)
def changeto3():
fastb.place_forget()
exitb.place_forget()
startb.place_forget()
stopb.place_forget()
norestart.place(x=410, y=295, width=100, height=50)
norestop.place(x=410, y=355, width=100, height=50)
resetb.place(x=410, y=415, width=100, height=50)
remainingPeople.place(x=440, y=260, width=51, height=16)
mode=Menu(menu0,tearoff=False)
mode.add_command(label= str('Default Mode'),
command = changeto1
)
mode.add_command(label= str('Instant Mode'),
command = changeto2
)
mode.add_command(label= str('No Duplication Mode'),
command = changeto3
)
menu0.add_cascade(label='Mode',menu=mode)
#图库菜单
def picture1():
global path
path = 'picture/gallery1/'
def picture2():
global path
path = 'picture/gallery2/'
def picture3():
global path
path = 'picture/gallery3/'
def picture4():
global path
path = 'picture/gallery4/'
def picture5():
global path
path = 'picture/gallery5/'
gallery=Menu(menu0,tearoff=False)
gallery.add_command(label= str('Gallery1'),
command = picture1
)
gallery.add_command(label= str('Gallery2'),
command = picture2
)
gallery.add_command(label= str('Gallery3'),
command = picture3
)
gallery.add_command(label= str('Gallery4'),
command = picture4
)
gallery.add_command(label= str('Gallery5'),
command = picture5
)
menu0.add_cascade(label='Gallery',menu=gallery)
#音效菜单
soundeffects=Menu(menu0,tearoff=False)#定义不可拖移菜单名称
soundeffects.add_command(label= str('Sound1'),
command = sound1
)
soundeffects.add_command(label= str('Sound2'),
command = sound2
)
soundeffects.add_command(label= str('Sound3'),
command = sound3
)
soundeffects.add_command(label= str('Sound4'),
command = sound4
)
soundeffects.add_command(label= str('Sound5'),
command = sound5
)
menu0.add_cascade(label='Sound',menu=soundeffects)
'''
def leadtoweb():
webbrowser.open("http://www.baidu.com", new=0)
'''
def show_donate_message():
tk.messagebox.showinfo('Donate','If you like this program, you can donate to the author.')
about=Menu(menu0,tearoff=False)#定义不可拖移菜单名称
'''
about.add_command(label=str('官方网站'),
command = leadtoweb
)
'''
about.add_command(label=str('Donate'),
command = show_donate_message
)
menu0.add_cascade(label='About',menu=about)
##########COUNT_BAR##########
count_bar = tk.Label(root,
# bg='white',
anchor='se',
font=('黑体', 35),
bd=10,
text = '0',
)
count_bar.place(x=410, y=10, width=100, height=60)
##########按钮##########
#抽签
fastb = tk.Button(root,
text='LOTTERY',
font=('黑体', 20),
command=fast_mode,
)
#开始
startb = tk.Button(root,
text='START',
font=('黑体', 20),
command=status_colour_green,
)
startb.place(x=410, y=295, width=100, height=50)
#停止
stopb = tk.Button(root,
text='STOP',
font=('黑体', 20),
command=status_colour_red
)
stopb.place(x=410, y=355, width=100, height=50)
#退出
exitb = tk.Button(root,
text='EXIT',
font=('黑体', 20),
command=sys.exit
)
exitb.place(x=410, y=415, width=100, height=50)
norestart = tk.Button(root,
text='START',
font=('黑体', 20),
command=no_duplication_mode_start,
)
startb.place(x=410, y=295, width=100, height=50)
norestop = tk.Button(root,
text='STOP',
font=('黑体', 20),
command=no_duplication_mode_stop
)
stopb.place(x=410, y=355, width=100, height=50)
norestart.place_forget()
##########状态灯##########
status = tk.Label(root,
text='◉',
font=('黑体', 80),
foreground='red',
)
status.place(x=410, y=80, width=100, height=100)
norestart.place_forget()
##########ADJUST_PEOPLE##########
human = StringVar()
human.set(33)
label_renshu = tk.Label(root,
text='People',
font=('Arial', 12),
bd=10)
label_renshu.place(x=410, y=210, width=30, height=20)
def updateNumberOfPeople():
number_of_people.clear()
for i in range(1,int(human.get())+1):
number_of_people.append(i)
remainingPeople['text']="Remain "+str(len(set(number_of_people)))+" people"
resetb = tk.Button(root,
text='Reset',
font=('黑体', 20),
command=updateNumberOfPeople
)
dognumber = tk.Spinbox(root,
from_ = 1,
to = 5000,
textvariable = human,
command = updateNumberOfPeople,
increment = 1,
)
dognumber.place(x=440, y=210, width=70, height=20)
##########SOUND##########
var = IntVar()
if var.get() == 1:
py.mixer.music.set_volume(1.0)
else:
py.mixer.music.set_volume(0)
def switch_audio():
if var.get() == 1:
py.mixer.music.set_volume(1.0)
else:
py.mixer.music.set_volume(0)
soundeffectchoose = tk.Checkbutton(root,
text='Sound',
variable=var,
command=switch_audio
)
soundeffectchoose.place(x=440, y=240, width=51, height=16)
#############IMAGE###########
photos = tk.Label(root,
image = '',
# bg='white',
bd=10)
photos.place(x=10, y=75, width=390, height=390)
###########################################################
#########################MAIN_PROGRAM######################
###########################################################
##########DEFAULT_MODE##########
def default_mode ():
root.flag=True
global path
while root.flag:
people = int(human.get())
xuanze = random.randrange(1,people+1)#This place must be added one
count_bar['text']=xuanze
filename = path + str(xuanze) + '.jpg'
img1 = cv2.imread(filename)
im1 = Image.fromarray(cv2.cvtColor(img1,cv2.COLOR_BGR2RGB))
img[0] = ImageTk.PhotoImage(image = im1)
photos.config(image=img[0])
root.update_idletasks()
##########NO_DUPLICATION_MODE############
def no_duplication_mode():
root.flag=True
global path
while root.flag:
xuanze = int(random.choice(number_of_people))
count_bar['text']=xuanze
filename = path + str(xuanze) + '.jpg'
img1 = cv2.imread(filename)
im1 = Image.fromarray(cv2.cvtColor(img1,cv2.COLOR_BGR2RGB))
img[0] = ImageTk.PhotoImage(image = im1)
photos.config(image=img[0])
root.update_idletasks()
#hotkey
def start(event):
status_colour_green()
def stop(event):
status_colour_red()
root.bind_all("<KeyPress-Up>", start)
root.bind_all("<KeyPress-Down>", stop)
root['menu']=menu0#The menu of the window
root.mainloop()