python项目--打字测试系统V1.0

更多功能正在开发中。。。
代码就在下方,欢迎大家一起交流,共同进步。
在这里插入图片描述
在这里插入图片描述

import threading
from tkinter import *
from tkinter import scrolledtext, filedialog, ttk
import tkinter.messagebox
import shutil
from tkinter import messagebox
import os
import time

import GVL
import TK_B2_2

t1 = '人言师者,捧着一颗心来,不带半根草去,或许我们与教师的境界相距尚远,但那一颗满怀希望与热情的心是相似的。我们因爱心和奉献相遇,二十个日夜,我们浅尝为师之艰、生活之苦'
seep=0

def b1():
    root = Tk()
    root.title("打字测试系统")
    root.geometry('500x500')
    root.wm_attributes('-topmost', 1)  # 弹出窗口置顶

    def B_1():
        GVL.h=1
        y = threading.Thread(target=re3)
        y.start()
        r()
    def B_2():
        GVL.h=0
        tkinter.messagebox.showinfo('测试结果', '打字结果:{}个/分钟'.format(seep))


    Bt_1 = Button(root, text='开始计时', command=B_1, width=10, height=1)
    Bt_1.place(x=100, y=0)

    Bt_2 = Button(root, text='计时结束', command=B_2, width=10, height=1)
    Bt_2.place(x=300, y=0)

    Et_1 = Entry(root, width=30, font=("黑体", 14))
    Et_1.place(x=100, y=100)

    Et_2 = Entry(root, width=30, font=("黑体", 14))
    Et_2.place(x=100, y=150)

    Et_3 = Entry(root, width=30, font=("黑体", 14))
    Et_3.place(x=100, y=200)

    Et_4 = Entry(root, width=30, font=("黑体", 14))
    Et_4.place(x=100, y=250)

    def r():
        E1 = Et_1.get()
        E2 = Et_2.get()
        E3 = Et_3.get()
        E4 = Et_4.get()
        y1 = len(E1)
        y2 = len(E2)
        y3 = len(E3)
        y4 = len(E4)
        if GVL.Dz1==0:
            Et_1.focus_set()  # 将光标移动至该文本框
            Et_1['state'] = 'normal'
            Et_2['state'] = 'disable'
            Et_3['state'] = 'disable'
            Et_4['state'] = 'disable'
            for e in range(15):
                if y1 > 0 and e < y1:
                    if E1[e] == t1[e]:
                        LB = Label(root, text=t1[e], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=75)
                    else:
                        LB = Label(root, text=t1[e], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=75)
                else:
                    LB = Label(root, text=t1[e], font=("黑体", 13)).place(x=(100 + (20 * e)), y=75)
                    LB = Label(root, text=t1[e + 15], font=("黑体", 13)).place(x=(100 + (20 * e)), y=125)
                    LB = Label(root, text=t1[e + 30], font=("黑体", 13)).place(x=(100 + (20 * e)), y=175)
                    LB = Label(root, text=t1[e + 45], font=("黑体", 13)).place(x=(100 + (20 * e)), y=225)
                if y1==15 and E1==t1[0:15]:
                    Et_1['state'] = 'disable'
                    Et_2['state'] = 'normal'
                    GVL.Dz1 = 1
        elif GVL.Dz1==1:
            Et_2.focus_set()
            for e in range(15):
                if y2 > 0 and e < y2:
                    if E2[e] == t1[e + 15]:
                        LB = Label(root, text=t1[e + 15], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=125)
                    else:
                        LB = Label(root, text=t1[e + 15], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=125)
                if y2==15 and E2==t1[15:30]:
                    Et_2['state'] = 'disable'
                    Et_3['state'] = 'normal'
                    GVL.Dz1 = 2
        elif GVL.Dz1==2:
            Et_3.focus_set()
            for e in range(15):
                if y3 > 0 and e < y3:
                    if E3[e] == t1[e + 30]:
                        LB = Label(root, text=t1[e + 30], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=175)
                    else:
                        LB = Label(root, text=t1[e + 30], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=175)
                if y3==15 and E3==t1[30:45]:
                    Et_3['state'] = 'disable'
                    Et_4['state'] = 'normal'
                    GVL.Dz1 = 3
        elif GVL.Dz1==3:
            Et_4.focus_set()
            for e in range(15):
                if y4 > 0 and e < y4:
                    if E4[e] == t1[e + 45]:
                        LB = Label(root, text=t1[e + 45], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=225)
                    else:
                        LB = Label(root, text=t1[e + 45], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=225)
                if y4==15 and E4==t1[45:60]:
                    Et_4['state'] = 'disable'
                    GVL.Dz1 = 4
                    GVL.h = 0
                    tkinter.messagebox.showinfo('测试结果', '打字结果:{}个/分钟'.format(seep))
                    return
        time.sleep(0.2)
        if GVL.h==1:
            o= threading.Thread(target=r)
            o.start()

    def re3():
        global seep
        for i in range(1, 100, 1):
            if GVL.h == 1:
                y = Et_1.get()+Et_2.get()+Et_3.get()+Et_4.get()
                a = len(y)
                seep = int((int(a) / int(i)) * 60)
                #LB = Label(root, text=int(seep), font=("黑体", 13)).place(x=10, y=75)
                time.sleep(1)
            else:
                return
        tkinter.messagebox.showinfo('测试结果', '打字结果:{}个/分钟'.format(seep))


    root.mainloop()

b1()

V2.0

import threading
from tkinter import *
from tkinter import scrolledtext, filedialog, ttk
import tkinter.messagebox
import shutil
from tkinter import messagebox
import os
import time

import GVL
import TK_B2_2

t1 = '1111111111111112222222222222223333333333333334444444444444446555555555555555555'
seep=0

def b1():
    root = Tk()
    root.title("打字测试系统")
    root.geometry('500x500')
    root.wm_attributes('-topmost', 1)  # 弹出窗口置顶

    def B_1():
        GVL.h=1
        y = threading.Thread(target=re3)
        y.start()
        r()
    def B_2():
        GVL.h=0
        tkinter.messagebox.showinfo('测试结果', '打字结果:{}个/分钟'.format(seep))


    Bt_1 = Button(root, text='开始计时', command=B_1, width=10, height=1)
    Bt_1.place(x=100, y=0)

    Bt_2 = Button(root, text='计时结束', command=B_2, width=10, height=1)
    Bt_2.place(x=300, y=0)

    Et_1 = Entry(root, width=30, font=("黑体", 14))
    Et_1.place(x=100, y=100)

    Et_2 = Entry(root, width=30, font=("黑体", 14))
    Et_2.place(x=100, y=150)

    Et_3 = Entry(root, width=30, font=("黑体", 14))
    Et_3.place(x=100, y=200)

    Et_4 = Entry(root, width=30, font=("黑体", 14))
    Et_4.place(x=100, y=250)

    def r():
        E1 = Et_1.get()
        E2 = Et_2.get()
        E3 = Et_3.get()
        E4 = Et_4.get()
        y1 = len(E1)
        y2 = len(E2)
        y3 = len(E3)
        y4 = len(E4)
        if GVL.Dz1==0:
            Et_1.focus_set()  # 将光标移动至该文本框
            Et_1['state'] = 'normal'
            Et_2['state'] = 'disable'
            Et_3['state'] = 'disable'
            Et_4['state'] = 'disable'
            for e in range(15):
                if y1 > 0 and e < y1:
                    if E1[e] == t1[e]:
                        LB = Label(root, text=t1[e], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=75)
                    else:
                        LB = Label(root, text=t1[e], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=75)
                else:
                    LB = Label(root, text=t1[e + 0 + (GVL.Dz1 * 15)], font=("黑体", 13)).place(x=(100 + (20 * e)), y=75)
                    LB = Label(root, text=t1[e + 15 + (GVL.Dz1 * 15)], font=("黑体", 13)).place(x=(100 + (20 * e)), y=125)
                    LB = Label(root, text=t1[e + 30 + (GVL.Dz1 * 15)], font=("黑体", 13)).place(x=(100 + (20 * e)), y=175)
                    LB = Label(root, text=t1[e + 45 + (GVL.Dz1 * 15)], font=("黑体", 13)).place(x=(100 + (20 * e)), y=225)
                if y1>=15 and E1[0:15]==t1[0 + (GVL.Dz1 * 15):15 + (GVL.Dz1 * 15)]:
                    Et_1['state'] = 'disable'
                    Et_2['state'] = 'normal'
                    GVL.Dz1 = 1
        elif GVL.Dz1==1:
            Et_2.focus_set()
            for e in range(15):
                if y2 > 0 and e < y2:
                    if E2[e] == t1[e + 15]:
                        LB = Label(root, text=t1[e + 15], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=125)
                    else:
                        LB = Label(root, text=t1[e + 15], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=125)
                else:
                    LB = Label(root, text=t1[e + 15], font=("黑体", 13)).place(x=(100 + (20 * e)), y=125)
                if y2>=15 and E2[0:15]==t1[15:30]:
                    Et_2['state'] = 'disable'
                    Et_3['state'] = 'normal'
                    GVL.Dz1 = 2
        elif GVL.Dz1==2:
            Et_1['state'] = 'normal'
            Et_1.delete(0, END)
            Et_3.focus_set()
            for e in range(15):
                if y3 > 0 and e < y3:
                    if E3[e] == t1[e + 30]:
                        LB = Label(root, text=t1[e + 30], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=175)
                    else:
                        LB = Label(root, text=t1[e + 30], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=175)
                if y3>=15 and E3[0:15]==t1[30:45]:
                    Et_3['state'] = 'disable'
                    Et_4['state'] = 'normal'
                    GVL.Dz1 = 3
        elif GVL.Dz1==3:
            Et_4.focus_set()
            for e in range(15):
                if y4 > 0 and e < y4:
                    if E4[e] == t1[e + 45]:
                        LB = Label(root, text=t1[e + 45], font=("黑体", 13), fg='green').place(x=(100+(20 * e)), y=225)
                    else:
                        LB = Label(root, text=t1[e + 45], font=("黑体", 13), fg='red').place(x=(100+(20 * e)), y=225)
                if y4>=15 and E4[0:15]==t1[45:60]:
                    Et_4['state'] = 'disable'
                    GVL.Dz1 = 4
                    GVL.h = 0
                    tkinter.messagebox.showinfo('测试结果', '打字结果:{}个/分钟'.format(seep))
                    return
        time.sleep(0.2)
        if GVL.h==1:
            o= threading.Thread(target=r)
            o.start()

    def re3():
        global seep
        for i in range(1, 100, 1):
            if GVL.h == 1:
                y = Et_1.get()+Et_2.get()+Et_3.get()+Et_4.get()
                a = len(y)
                seep = int((int(a) / int(i)) * 60)
                #LB = Label(root, text=int(seep), font=("黑体", 13)).place(x=10, y=75)
                time.sleep(1)
            else:
                return
        tkinter.messagebox.showinfo('测试结果', '打字结果:{}个/分钟'.format(seep))


    root.mainloop()

b1()
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
1.系统界面:就三项选择功能键。 练习/考试/设置 2.练习第一界面的用户选择及练习内容选择。 3.测试第一页面与练习页面基本相同,但没有测试项目的情况下无法进入本页。如只有一个测试项目的情况下系统不会出现选择文本的列表框。 4.练习/测试页面。应该是本系统最核心的部分了。 功能:1.页面内容无法复制及粘贴,包括从外都没无法复制到本输入框中,光标始终在输入文本最后,输入后无法修改中间的文本; 2.开始输入以键盘击键即开始,到时间或输入全部内容后结束。结束后无法再输入; 3.输入对错自动判断,当输入正确,原字符变绿,错误则变红,当前输入字符突出显示; 4.进度实时显示,并上传服务器。管理员可以随时了解每位学生的输入情况; 5.练习/测试的排名前10学生及输入速度显示。 5.管理员登录界面。 6.后台的学生导入。 7.后台的练习文本管理。练习时间的管理;添加/删除练习文本功能,学生使用练习文本的次数会被记录。 8.后台的测试文本管理。 功能:1.每个测试可设置独立的测试时间; 2.设置测试的开放时间和测试的结束时间,有此时间段外将无法登录测试; 3.测试内容的修改及删除功能; 9.练习/测试情况在线/结果的柱状实时显示。 10.练习/测试结果的显示与导出。 本系统基于.net 4.0开发,服务器环境要求:IIS+.net4.0

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值