赞
踩
- import tkinter as tk
- from tkinter import *
- import webbrowser
- import tkinter.messagebox
- import sys
- import pymysql
- from page import StudentMain
-
- class StudentLogin(Frame):
- def __init__(self,master=None):
- super().__init__(master)
- self.master = master
- self.pack()
- self.createWidget()
-
- def createWidget(self):
- tk.Label(self,text='学号').grid(row=0,column=0)
- self.ID = tk.IntVar()
- tk.Entry(self,textvariable=self.ID).grid(row=0,column=1)
-
- tk.Label(self,text='密码').grid(row=1,column=0)
- self.password = tk.StringVar()
- tk.Entry(self,textvariable=self.password,show='*').grid(row=1,column=1)
-
- tk.Button(self, text='登陆', bg='red', fg='white', width=10, relief="flat",command=self.login).grid(row=2, column=0,columnspan=10,pady=10)
- tk.Button(self, text='忘记密码', relief="flat",command=self.ForgetPassword).grid(row=1, column=2, columnspan=10,padx=10)
- tk.Button(self,text='注册',relief='flat',command=self.register).grid(row=0,column=2,padx=10)
- def login(self):
- id = self.ID.get()
- pwd = self.password.get()
-
- #数据库处理
- conn = pymysql.connect(host='localhost',user='root',password='000000',port=3306,database='kaoqin',charset='utf8')
- cur = conn.cursor()
- sql = 'select * from students'
- cur.execute(sql)
- result = cur.fetchall()
- id_list = [it[0] for it in result]
- PAS = result[id_list.index(id)][2]
- if not(id and pwd):
- tk.messagebox.showwarning(title='警告', message=
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。