基于tkinter的点名
import datetime import random import tkinter as tk import time class chas_lp(): def __init__(self): self.tr=tk.Tk() self.tr.title('点名') self.tr.geometry('500x200') self.qew3=tk.StringVar() self.lp=['qwe','qwe1','zxc','fgh','rty'] self.a=0 self.c=0 def qwe2(self): self.qew3.set(self.lp[self.a]) xcv=self.tr.after(100,self.qwe2) self.a+=1 if self.a==len(self.lp): self.a=0 if self.c%2!=0: self.tr.after_cancel(xcv) def fgh(self): self.c+=1 if self.c%2==0: self.qwe2() print(self.c) def qwe11(self): # self.qwe2() bhu=tk.Label(self.tr,textvariable=self.qew3,font=('黑体',30),fg='red') bhu.pack() qwe=tk.Button(self.tr,text='停止',width=10,height=5,command=lambda :self.fgh()) qwe.pack() self.qwe2() self.tr.mainloop() if __name__ == '__main__': chang_op=chas_lp() chang_op.qwe11()