当前位置:   article > 正文

python+tkinter+mysql实现登录注册+修改密码_python实现用户注册,登录,修改密码,注销

python实现用户注册,登录,修改密码,注销
  1. import tkinter as tk
  2. from tkinter import *
  3. import webbrowser
  4. import tkinter.messagebox
  5. import sys
  6. import pymysql
  7. from page import StudentMain
  8. class StudentLogin(Frame):
  9. def __init__(self,master=None):
  10. super().__init__(master)
  11. self.master = master
  12. self.pack()
  13. self.createWidget()
  14. def createWidget(self):
  15. tk.Label(self,text='学号').grid(row=0,column=0)
  16. self.ID = tk.IntVar()
  17. tk.Entry(self,textvariable=self.ID).grid(row=0,column=1)
  18. tk.Label(self,text='密码').grid(row=1,column=0)
  19. self.password = tk.StringVar()
  20. tk.Entry(self,textvariable=self.password,show='*').grid(row=1,column=1)
  21. tk.Button(self, text='登陆', bg='red', fg='white', width=10, relief="flat",command=self.login).grid(row=2, column=0,columnspan=10,pady=10)
  22. tk.Button(self, text='忘记密码', relief="flat",command=self.ForgetPassword).grid(row=1, column=2, columnspan=10,padx=10)
  23. tk.Button(self,text='注册',relief='flat',command=self.register).grid(row=0,column=2,padx=10)
  24. def login(self):
  25. id = self.ID.get()
  26. pwd = self.password.get()
  27. #数据库处理
  28. conn = pymysql.connect(host='localhost',user='root',password='000000',port=3306,database='kaoqin',charset='utf8')
  29. cur = conn.cursor()
  30. sql = 'select * from students'
  31. cur.execute(sql)
  32. result = cur.fetchall()
  33. id_list = [it[0] for it in result]
  34. PAS = result[id_list.index(id)][2]
  35. if not(id and pwd):
  36. tk.messagebox.showwarning(title='警告', message=
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/556193
推荐阅读
相关标签
  

闽ICP备14008679号