输入用户自己想要的号码,开始运行系统会随机输出一个号码。
示例:
from tkinter import *
import random
window = Tk()
window.title("摇号系统")
window.geometry('350x200')
lbl = Label(window,text = "输入想要的号码")
lbl.grid(column=0,row=0)
lb = Label(window)
txt = Entry(window,width=10)
txt.grid(column=1,row=0)
def clicked():
number = range(1,int(txt.get()))
lb.configure(text = "最终结果是" + str(random.choices(number)))
lb.grid(column=0,row=1)
btn = Button(window,fg="black",bg="green",text="开始",command=clicked)
btn.grid(column=10,row=0)
window.mainloop()
输出:
ow.mainloop()
输出:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FgCvYEvI-1654169211211)(C:\Users\86139\AppData\Roaming\Typora\typora-user-images\image-20220602191128299.png)]