|
发表于 2018-1-1 18:09:44
|
显示全部楼层
- import random
- from tkinter import *
- import sys
- root = Tk()
- studentsname = "李敏 李德涵 王嘉佳 郭润旭 秦懿格 秦子淏 马瑞涵 殷悦 厉承峻 王喜悦 丁明轩 刘亚欣 徐嘉澜 聂平 张浩哲 孔德润 毕艺 王玲瑜 秦梓程 曹彦昊 冯思瑜 李奕璇 张信杰 李双龙 田莎莎 栾杰 郑广浩 董记锐 张钰宸 郑一搏 李宜芹 张博洋 朱姝颖 何静 安修杭 徐梓豪 刘硕6.6 黄亚鹏 刘云丹 刘子慧 王栋 袁铭阳 文昊敬".split()
- spam = range(45)
- name = spam[random.randint(0,44)]
- num = name + 1
- x = str("请" + str(num) + "号同学"+ '\n' + studentsname[name] + "回答问题")
- root['bg'] = 'white'
- root.title("李德涵教育服务系统")
- def xrange():
- spam = range(45)
- name = spam[random.randint(0,44)]
- num = name + 1
- x = str("请" + str(num) + "号同学"+ '\n' + studentsname[name] + "回答问题")
- theLabel['font'] = ('楷体',72)
- theLabel['text']=x
-
- def exit1():
- sys.exit(0)
- def to20():
- spam = range(20)
- name = spam[random.randint(0,19)]
- num = name + 1
- x = str("请" + str(num) + "号同学"+ '\n' + studentsname[name] + "回答问题")
- theLabel['font'] = ('楷体',72)
- theLabel['text']=x
- def to45():
- spam = range(45)
- name = spam[random.randint(20,44)]
- num = name + 1
- x = str("请" + str(num) + "号同学"+ '\n' + studentsname[name] + "回答问题")
- theLabel['font'] = ('楷体',72)
- theLabel['text']=x
- def instead():
- theLabel['font'] = ('楷体',20)
- theLabel['text'] = "本软件版权归@幻夜风暴工作室所有,若有侵犯,必究责任\n\n\
- 教师可通过先进的随机提问技术进行提问,\n\
- 《随机》键随机提问1—45号的同学\n\
- 其他键设定了两大范围,更能在一定范围内准确地进行提问\n\
- 《退出》键直接退出"
- topFrame = Frame(root,relief =SUNKEN)
- topFrame.pack(fill=X)
- centerFrame = Frame(root,relief =SUNKEN)
- centerFrame.pack(fill=X)
- centerFrame1 = Frame(centerFrame,relief =SUNKEN)
- centerFrame1.pack(anchor=CENTER)
- centerFrameLeft = Frame(centerFrame1,relief =SUNKEN)
- centerFrameLeft.pack(side=LEFT)
- centerFrameRight = Frame(centerFrame1,relief =SUNKEN)
- centerFrameRight.pack(side=LEFT)
- centerFrameRightTop = Frame(centerFrameRight,relief =SUNKEN)
- centerFrameRightTop.pack(fill=X)
- centerFrameRightBottom = Frame(centerFrameRight,relief =SUNKEN)
- centerFrameRightBottom.pack(fill=X)
- bottomFrame = Frame(root,relief =SUNKEN)
- bottomFrame.pack(fill=X)
- bottomFrame1 = Frame(bottomFrame,relief =SUNKEN)
- bottomFrame1.pack(anchor=CENTER)
- theLabel = Label(topFrame,text='欢迎使用\n@幻夜风暴工作室\n产品',font=('楷体',72),bg='white',fg='black')
- theLabel.pack()
-
- Button1 = Button(centerFrameLeft,text="随机",command=xrange, width=20, height =6,\
- padx=40,pady=20,bg='white')
- Button1.pack()
- Button2 = Button(bottomFrame1,text="退出",fg='red',width=20, height =6,\
- command=exit1,padx=40,pady=20,bg='green')
- Button2.pack(side=LEFT)
- Button3 = Button(centerFrameRightTop,text='指定01-20号同学',command=to20,width=20, \
- padx=40,pady=20,bg='pink',fg='brown')
- Button3.pack()
- Button4 = Button(centerFrameRightBottom,text='指定21-45号同学', command=to45,width=20, \
- padx=40,pady=20,bg='yellow',fg='brown')
- Button4.pack()
- Button5 = Button(bottomFrame1,text='使用说明',command=instead,width=20, height =6,\
- padx=40,pady=20,fg='green', bg='blue')
- Button5.pack(side=LEFT)
- #Button6:皮肤,Button5标签(着重颜色)
- mainloop()
复制代码 |
|