尝试使用MySQL在Python中制作tkinter密码管理器,需要逻辑

问题描述

因此,我一直在尝试使用TKinter和simplecrypt创建一个密码管理器,并使用MysqL存储密码。我要运行的方式是用户可以创建不同的帐户,并在这些帐户中存储密码以及服务名和用户ID。到目前为止,这是我的代码

import MysqL.connector as MysqL
import tkinter as tk

from simplecrypt import *

def createusr():
    global oo
    global pss
    global hiint
    top1 = tk.Toplevel(root)
    top1.title('Create new user ')
    top1.geometry('480x360')
    oo = tk.StringVar()
    pss = tk.StringVar()
    hiint = tk.StringVar()
    userid = tk.Label(top1,text = 'Enter User ID: ')
    userid.place(relx = 0.09,rely = 0.1,relheight = 0.058,relwidth = 0.24)
    entrusr = tk.Entry(top1,bg = 'gray',textvariable = oo)
    entrusr.place(relx = 0.3,relwidth = 0.24)
    pwd = tk.Label(top1,text = "enter password: ")
    pwd.place(relx = 0.08,rely = 0.18,relwidth = 0.24)
    pwde = tk.Entry(top1,textvariable = pss)
    pwde.place(relx = 0.3,relwidth = 0.24)
    hnt = tk.Label(top1,text = "hint: ")
    hnt.place(relx = 0.15,rely = 0.33,relwidth = 0.24)
    hnte = tk.Entry(top1,textvariable = hiint)
    hnte.place(relx = 0.3,relwidth = 0.24)
    createacc = tk.Button(top1,text = 'Create Account',font = 50,command = newacc)
    createacc.place(relx = 0.1,rely = 0.42,relwidth = 0.24)


def settings():
    top3 = tk.Toplevel(root)
    top3.title('Settings')
    top3.geometry('480x360')
    url = tk.Intvar()
    #darkt = tk.Intvar()
    #lightt = tk.Intvar()
    ourl = tk.Checkbutton(top3,text = "open URL of service instantly",variable = url)
    ourl.pack()
    #theme = tk.Label(top3,text = 'Theme:')
    #theme.pack()
    #dark = tk.Checkbutton(top3,text = 'Dark',variable = darkt,command = reset(f = True))
    #dark.pack()
    #light = tk.Checkbutton(top3,text = 'Light',variable = lightt,command = reset)
    #light.pack()


def forgott():
    top2 = tk.Toplevel(root)
    top2.title('recover password')
    top2.geometry('480x360')
    hint = tk.Label(top2)

def newacc():
    check = str("DROP TABLE IF EXISTS " + str(oo.get()))
    table = "CREATE TABLE {0} (SERVICE VARCHAR(100),USERNAME VARCHAR(100),PASSWORD VARCHAR(256))".format(str(oo.get()))
    cursor.execute(table)
    msql.commit()

def show_passwords():
    top4 = tk.Toplevel(root)



root = tk.Tk()
root.title('Cipher')
canvas = tk.Canvas(root,height=480,width=360)
canvas.pack()
msql = MysqL.connect(user='root',password='7014403396',database='cipher')
cursor = msql.cursor()
coolimg = tk.PhotoImage(file='images-4.png')
settt = tk.PhotoImage(file='settings+icon-1320183238404656194_16.png')
useridlogin = tk.StringVar()
useridpassword = tk.StringVar()



img = tk.Label(root,image = coolimg)
img.place(relx = 0.3,rely = 0.07,relheight = 0.5,relwidth = 0.4)
Userid = tk.Label(root,text = 'User ID: ',width = 20)
Userid.place(relx = 0.2,rely = 0.6,relheight = 0.04,relwidth = 0.2)
passwd = tk.Label(root,text = 'Password: ',width = 20)
passwd.place(relx = 0.2,rely = 0.65,relwidth = 0.2)
create = tk.Button(root,text = 'Create',command = createusr)
create.place(relx = 0,rely = 0.9,relwidth = 0.3)
forgot = tk.Button(root,text = 'Forgot?',font = 50)
forgot.place(relx = 0.72,relwidth = 0.3)
usrent = tk.Entry(root,textvariable = useridlogin)
usrent.place(relx = 0.37,relheight = 0.045,relwidth = 0.24)
psent = tk.Entry(root,textvariable = useridpassword)
psent.place(relx = 0.37,relwidth = 0.24)
sett = tk.Button(root,image = settt,command = settings)
sett.place(relx = 0.9,relheight = 0.05,relwidth = 0.05)
login = tk.Button(root,text = 'Log in',font = 50)
login.place(relx = 0.2,rely = 0.7,relwidth = 0.48)

root.mainloop()

所以我一直使用用户帐户作为表名和MysqL,并将密码服务名和用户ID存储在表中。现在,我需要帮助弄清楚如何确保仅在输入正确的密码后才打开表,换句话说,如何在创建时将用户acc与密码关联起来。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)