python実現の簡易抽選プログラム
1461 ワード
サークルは以前抽选で大物がjava版のプログラムを书いたことがあるので、今自分でpythonを学んで小さい抽选プログラムを书きたいと思って、少しごみがあって、でもやはり记录したいです
import tkinter
import threading
import random
windows = tkinter.Tk()
windows.title(' ')
windows.geometry('1000x500')
label1 = tkinter.Label(windows, text=' ') #
label1.pack()
e = tkinter.Entry()
e.pack()
starts = 0
#
notround = False
#
def round():
t = threading.Thread(target=started)
t.start()
def started():
global notround
while True:
#
if notround == True:
notround = False
return starts
#
number = e.get()
number = int(number)
things = range(1, number + 1)
maxvalue = len(things)
luckboy = random.choice(things)
label3 = tkinter.Label(windows, fg='red', text=' ')
label3.place(x=450, y=250)
label2 = tkinter.Label(windows, fg='red', text=luckboy, font=('Arial', 20), width=15, height=5)
label2.place(x=350, y=300)
print(luckboy)
def stops():
global notround
notround = True
btn1 = tkinter.Button(windows, text=' ', bg='white', command=round)
btn1.place(x=450, y=100, width=130, height=40)
btn2 = tkinter.Button(windows, text=' ', bg='white', command=stops)
btn2.place(x=450, y=150, width=130, height=40)
windows.mainloop()