。 。

 

大家不用看了,我要结题了,麻烦了。

望采纳,谢谢

def accuracyRate():
    datalist = []
    test_data = []
    rel_name = os.listdir(path['pic_path'])
    with open(path['filename'], 'r')as f:
        while True:
            data = f.readline().strip()
            # print data[0]
            if not data:
                break
            datalist.append(data.split(' ')[0])

    with open(path['filename1'], 'r')as fs:
        while True:
            tdata = fs.readline().strip()
            if not tdata:
                break
            test_data.append(tdata.split(' ')[0])

    file_inter = set(datalist).intersection(set(test_data))
    file_union = set(test_data).union(set(datalist))
    file_cha = file_union - file_inter

    path['union'] = list(file_cha)
    accry_xiugai()
    accuracy_file = list(file_inter) + path['re_name']
    print len(datalist), len(accuracy_file), len(test_data)
    filename = float(len(datalist)) / len(accuracy_file)
    filename1 = float(len(test_data)) / len(accuracy_file)
    Label(root, text='file 1 的准确率:').grid(row=5, column=3)
    t1 = StringVar()
    t1.set(filename)
    Entry(root, textvariable=t1).grid(row=5, column=4)
    Label(root, text='file 2 的准确率:').grid(row=6, column=3)
    t2 = StringVar()
    t2.set(filename1)
    Entry(root, textvariable=t2).grid(row=6, column=4)

代码如上,望采纳,不胜感谢

注册实现

import tkinter as tk
import  tkinter.messagebox
import  pickle
window = tk.Tk()
window.title('login')
window.geometry('400x300')
# 登陆界面
tk.Label(window, text='账户:').place(x=100,y=100)
tk.Label(window, text='密码:').place(x=100, y=140)

var_usr_name = tk.StringVar()
enter_usr_name = tk.Entry(window, textvariable=var_usr_name)
enter_usr_name.place(x=160, y=100)

var_usr_pwd = tk.StringVar()
enter_usr_pwd = tk.Entry(window, textvariable=var_usr_pwd, show='*')
enter_usr_pwd.place(x=160, y=140)

#登陆
def usr_log_in():
    #输入框内容
    usr_name = var_usr_name.get()
    usr_pwd = var_usr_pwd.get()
    try:
        with open('usr_info.pickle', 'rb') as usr_file:
            usrs_info=pickle.load(usr_file)
    except:
        with open('usr_info.pickle', 'wb') as usr_file:
            usrs_info={'admin':'admin'}
            pickle.dump(usrs_info, usr_file)

    # 判断
    if usr_name in usrs_info:
        if usr_pwd == usrs_info[usr_name]:
            tk.messagebox.showinfo(title='Welcome', message='###'+usr_name)
        else:
            tk.messagebox.showerror(message='ERROR!')
    # 用户名密码不能为空
    elif usr_name == '' or usr_pwd == '':
        tk.messagebox.showerror(message='用户名不能为空!')

def usr_sign_quit():
    window.destroy()

def usr_sign_up():
    def signtowcg():
        NewName = new_name.get()
        NewPwd = new_pwd.get()
        ConfirPwd = pwd_comfirm.get()
        try:
            with open('usr_info.pickle', 'rb') as usr_file:
                exist_usr_info = pickle.load(usr_file)
        except FileNotFoundError:
            exist_usr_info = {}
        if NewName in exist_usr_info:
            tk.messagebox.showerror(message='用户名存在!')
        elif NewName == '' and NewPwd == '':
            tk.messagebox.showerror(message='用户名和密码不能为空!')
        elif NewPwd != ConfirPwd:
            tk.messagebox.showerror(message='密码前后不一致!')
        else:
            exist_usr_info[NewName] = NewPwd
            with open('usr_info.pickle', 'wb') as usr_file:
                pickle.dump(exist_usr_info, usr_file)
                tk.messagebox.showinfo(message='注册成功!')
                window_sign_up.destroy()

    # 新建注册窗口
    window_sign_up = tk.Toplevel(window)
    window_sign_up.geometry('400x300')
    window_sign_up.title('sign_up')

    # 注册编辑框
    new_name = tk.StringVar()
    new_pwd = tk.StringVar()
    pwd_comfirm = tk.StringVar()

    tk.Label(window_sign_up, text='账户名:').place(x=90,y=50)
    tk.Entry(window_sign_up, textvariable=new_name).place(x=160, y=50)

    tk.Label(window_sign_up, text='密码:').place(x=90,y=100)
    tk.Entry(window_sign_up, textvariable=new_pwd, show='*').place(x=160, y=100)

    tk.Label(window_sign_up, text='确认密码:').place(x=90, y=150)
    tk.Entry(window_sign_up, textvariable=pwd_comfirm, show='*').place(x=160, y=150)
#确认注册
    bt_confirm = tk.Button(window_sign_up, text='确定', command=signtowcg).place(x=180,y=220)

#登录 注册按钮
bt_login = tk.Button(window,text='登录',command=usr_log_in)
bt_login.place(x=120,y=230)

bt_signup = tk.Button(window,text='注册',command=usr_sign_up)
bt_signup.place(x=190,y=230)

bt_logquit = tk.Button(window,text='退出',command=usr_sign_quit)
bt_logquit.place(x=260,y=230)

window.mainloop()

鼠标获取


rom tkinter import *

app = Tk()

#通过event形参来获取对应事件描述
def callback(event): 
    print("当前位置:",event.x,event.y)

#创建框架,窗口尺寸
frame = Frame(app, width = 200, height = 200)
#frame.bind("<Motion>",callback)
frame.bind("<Button-1>",callback)
frame.bind("<Button-2>",callback)
frame.bind("<Button-3>",callback)
frame.pack()
#<Button-1>Button:表示鼠标的点击事件 “—”左边是事件本身,右边是事件描述
#1:表示左键 2:中间键的滚轮点击 3:右键

mainloop()