【Python + Mysql + UI】学生信息管理系统(附代码)

Python+tkinter 简易学生信息管理系统 Python+tkinter 简易学生信息管理系统 笔者基于tkinter和pymysql开发出一个简易的学生管理系统。 阅读详情

...........做了一个学生信息管理的简单数据库程序,写了一点简单的UI界面,功能不是很强大,代码组织也很不科学,洋洋洒洒竟然写了700多行.......分享出来,一起学习

/**********************************
@ author:    优快云 @WilliamCode
@ E-mail:    1327804001@qq.com
@ date:        2019-01-09
@ All Rights Reserved
@
@专业程序员,精通C,Python,Java,mysql数据库,python前端与后端开发
@欢迎各位朋友提出建议一起进步
@
@承接web前端外包,微信小程序外包,单片机相关外包,价格实惠,代码质量保证,欢迎联系
@邮箱1327804001@qq.com
@微信xiechunhao12138
**********************************/
 

创建数据库代码如下:

create database student_info_system;
use student_info_system
create table admin(username char(30),password char(30));
insert into admin values('admin','admin');
create table teacher_up(username char(30),password char(30));
create table student_up(username char(30), password char(30));

insert into teacher_up values('admin','admin');
insert into student_upvalues('admin','admin');

create table teacher_info(id bigint primary key,name char(10),gender char(2),age int,grade int);

create table student_info(id bigint primary key,name char(30),gender char(2),age int,grade int);

其中teacher_up(teacher username & password)存放老师账户的用户名和密码,其他up结尾的同样。以_info为结尾的表存放老师或者学生信息。先给管理员账户添加了初始账户和密码(admin,admin)

 

然后是代码,需要先安装pymysql库,安装命令pip3 install pymysql

下面是带UI的学生信息管理代码,在Python3.6下调试通过。


'''______________________________________-admin_______________________________________'''
from tkinter import *
from tkinter import ttk
import tkinter.messagebox

page = 0
who = 0

def admin_func():
	pass

def button_login_clicked():
	pass
def lb1(*args):
	indexs = listbox1.curselection()
	print(indexs)
	if(len(indexs) == 0):
		return None
	index = int(indexs[0]);
	print(123123123123)



def button2_clicked():
	global who
	who = 1
	page = 0
	display_current_page()

data_in = None

def display(i,data):
	global data_in
	data_in = data
	listbox1.delete(0,END)
	listbox2.delete(0,END)
	listbox3.delete(0,END)
	listbox4.delete(0,END)
	listbox5.delete(0,END)
	listbox6.delete(0,END)
	for d in data:
		if i==1:
			listbox1.insert(END,'学生')
		else:
			listbox1.insert(END,'老师')
		listbox2.insert(END, d[0])
		listbox3.insert(END, d[1])
		listbox4.insert(END, d[2])
		listbox5.insert(END, d[3])
		listbox6.insert(END, d[4])
	
def display_next_page():
	global page, who
	page+= 1
	if who == 1:
		cursor.execute("select * from student_info limit %d,%d" % (page*20, page*20+20))
		data = cursor.fetchall()
		display(who, data)
	else:
		cursor.execute("select * from teacher_info limit %d,%d" % (page*20, page*20+20))
		data = cursor.fetchall()
		display(who, data)

def button_next_page_clicked():
	display_next_page()


def display_previous_page():
	global page, who
	page -= 1
	page = max(page, 0)
	if who == 1:
		cursor.execute("select * from student_info limit %d,%d" % (page*20, page*20+20))
		data = cursor.fetchall()
		display(who, data)
	else:
		cursor.execute("select * from teacher_info limit %d,%d" % (page*20, page*20+20))
		data = cursor.fetchall()
		display(who, data)

def display_current_page():
	global page, who
	page = page
	if who == 1:
		cursor.execute("select * from student_info limit %d,%d" % (page*20, page*20+20))
		data = cursor.fetchall()
		display(who, data)
	else:
		cursor.execute("select * from teacher_info limit %d,%d" % (page*20, page*20+20))
		data = cursor.fetchall()
		display(who, data)

def button_teacher_clicked():
	global who, page
	who = 0
	page = 0
	display_current_page()


def button_delete_clicked():
	indexs1 = listbox1.curselection()
	indexs2 = listbox2.curselection()
	indexs3 = listbox3.curselection()
	indexs4 = listbox4.curselection()
	indexs5 = listbox5.curselection()
	indexs6 = listbox6.curselection()
	
	index = -1
	if len(indexs1) > 0:
		index = indexs1[0]
	elif len(indexs2) > 0:
		index = indexs2[0]
	elif len(indexs3) > 0:
		index = indexs3[0]
	elif len(indexs4) > 0:
		index = indexs4[0]
	elif len(indexs5) > 0:
		index = indexs5[0]
	elif len(indexs6) > 0:
		index = indexs6[0]

	if index == -1:
		tkinter.messagebox.showerror("Error","未选择要删除的数据")

	delete_id = listbox2.get(index,index)
	delete_who = listbox1.get(index,index)
	if delete_who[0] == "学生":
		cursor.execute("delete from student_info where id = %d" % int(delete_id[0]))
		print("delete from student_info where id = %d" % int(delete_id[0]))
		database.commit()
		display_current_page()
	else:
		cursor.execute("delete from teacher_info where id = %d" % int(delete_id[0]))
		database.commit()
		display_current_page()
	#print(delete_id)	


			
'''
combobox_ =2ttk.Combobox(myWindow, values = ['学生','教师'], width=17)
	combobox_2.grid(column = 0, row = 5)

	entry4=Entry(myWindow)
	entry4.grid(column = 1, row = 5)
	entry5=Entry(myWindow)
	entry5.grid(column = 2, row = 5)
	combobox_3 = ttk.Combobox(myWindow, values = ['男','女'], width=17)
	combobox_3.grid(column = 3, row = 5)
	entry7=Entry(myWindow)
	entry7.grid(column = 4, row = 5)
	entry8=Entry(myWindow)
	entry8.grid(column = 5, row = 5)'''
def button_add_clicked():
	index = combobox_2.current()
	if index < 0:
		tkinter.messagebox.showerror("Error","请选择身份")
		return None
	
	add_id = entry4.get().strip()
	if len(add_id)<=0:
		tkinter.messagebox.showerror("Error","请输入编号")
		return None
	try:
		add_id = int(add_id)
	except Exception as e:
		tkinter.messagebox.showerror("Error","输入编号错误")
		return None

	add_name = entry5.get().strip()
	if len(add_name)<=0:
		tkinter.messagebox.showerror("Error","请输入名字")
		return None

	add_gender = combobox_3.current()
	if add_gender < 0:
		tkinter.messagebox.showerror("Error","请选择性别")
		return None

	add_age = entry7.get().strip()
	if len(add_age)<=0:
		tkinter.messagebox.showerror("Error","请输入年龄")
		return None
	try:
		add_age = int(add_age)
	except Exception as e:
		tkinter.messagebox.showerror("Error","年龄输入错误")
		return None

	add_grade = entry7.get().strip()
	if len(add_grade)<=0:
		tkinter.messagebox.showerror("Error","请输入年级")
		return None
	try:
		add_grade = int(add_grade)
	except Exception as e:
		tkinter.messagebox.showerror("Error","输入年级错误")
		return None
	#print(index, add_id, add_name,add_gender,add_age,add_grade)
	if index == 0:
		cursor.execute('select * from student_info where id = %d' % add_id)
		data = cursor.fetchall()
		if len(data) > 0:
			tkinter.messagebox.showerror("Error","Existed id")
			return None
		cursor.execute('insert into student_info value(%d,"%s","%s",%d,%d)' % (add_id, add_name, "男" if add_gender == 0 else "女", add_age, add_grade))
		database.commit()
		display_current_page()
	else:
		cursor.execute('select * from teacher_info where id = %d' % add_id)
		data = cursor.fetchall()
		if len(data) > 0:
			tkinter.messagebox.showerror("Error","Existed id")
			return None
		cursor.execute('insert into teacher_info value(%d,"%s","%s",%d,%d)' % (add_id, add_name, "男" if add_gender == 0 else "女", add_age, add_grade))
		database.commit()
		display_current_page()
'''______________________________________-admin_______________________________________'''
import pymysql
from tkinter import *
from tkinter import ttk
import tkinter.messagebox


database = pymysql.connect('localhost', 'root', '', charset='utf8', port = 3306)
cursor = database.cursor()
if database.open == False:
	raise Exception("数据库未连接,请检查数据库服务是否启动")
cursor.execute('use student_info_system')

'''
id` bigint(20) NOT NULL,
  `name` char(30) DEFAULT NULL,
  `gender` char(2) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `grade` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)'''

mode = -1
def button_login_clicked():
 	global mode
 	index = combobox_login.current()
 	username_input = entry1.get().strip()
 	password_input = entry2.get().strip()
 	print(index, username_input, password_input)
 	if index == -1:
 		tkinter.messagebox.showerror("错误","请选择你的登陆身份")
 	elif len(username_input) == 0 or len(password_input) == 0:
 		tkinter.messagebox.showerror("错误","请输入用户名和密码")
 	else:
 		if index == 0:
 			cursor.execute('select * from admin where username = "%s" and password = "%s"' % (username_input,password_input))
 			if (len(cursor.fetchall()) > 0):
 				print("pass")
 				myWindow.destroy()
 				mode = 0

 			else:
 				tkinter.messagebox.showerror("错误","用户名或密码错误")
 		if index == 1:
 			cursor.execute('select * from teacher_up where username = "%s" and password = "%s"' % (username_input,password_input))
 			if (len(cursor.fetchall()) > 0):
 				print("pass")
 				myWindow.destroy()
 				mode = 1
 			else:
 				tkinter.messagebox.showerror("错误","用户名或密码错误")
 		if index == 2:
 			cursor.execute('select * from student_up where username = "%s" and password = "%s"' % (username_input,password_input))
 			if (len(cursor.fetchall()) > 0):
 				print("pass")
 				myWindow.destroy()
 				mode = 2
 			else:
 				tkinter.messagebox.showerror("错误","用户名或密码错误")
 

'''
Label(myWindow, text='身份无法修改',font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 4)
	Label(myWindow, text='编号无法修改',font=('Arial 12 bold'),width=10,height=1).grid(column = 1, row = 4)
	entry11=Entry(myWindow)
	entry11.grid(column = 2, row = 4)
	combobox_22 = ttk.Combobox(myWindow, values = ['男','女'], width=17)
	combobox_22.grid(column = 3, row = 4)
	entry22=Entry(myWindow)
	entry22.grid(column = 4, row = 4)
	entry33=Entry(myWindow)
	entry33.grid(column = 5, row = 4)
	button4 = Button(text = '修改',relief = 'raised', command = button_change_clicked)
	button4.grid(column = 6, row = 4)
'''
def button_change_clicked():
	indexs1 = listbox1.curselection()
	indexs2 = listbox2.curselection()
	indexs3 = listbox3.curselection()
	indexs4 = listbox4.curselection()
	indexs5 = listbox5.curselection()
	indexs6 = listbox6.curselection()
	print(indexs1,indexs2,indexs3,indexs4,indexs5,indexs6)
	index = -1
	if len(indexs1) > 0:
		index = indexs1[0]
	elif len(indexs2) > 0:
		index = indexs2[0]
	elif len(indexs3) > 0:
		index = indexs3[0]
	elif len(indexs4) > 0:
		index = indexs4[0]
	elif len(indexs5) > 0:
		index = indexs5[0]
	elif len(indexs6) > 0:
		index = indexs6[0]
	if index == -1:
		tkinter.messagebox.showerror("错误","请选择要修改的数据")
	change_id = listbox2.get(index,index)[0]
	change_who = listbox1.get(index,index)[0]

	change_name = entry11.get().strip()
	change_age = entry22.get().strip()
	change_grade = entry33.get().strip()
	index = combobox_22.current()

	if len(change_name) > 0:
		if (change_who == "学生"):
			try:
				change_id = int(change_id)
			except Exception as e:
				tkinter.messagebox.showerror("错误","输入错误")
				return None
			cursor.execute('update student_info set name = "%s" where id = %d' % (change_name, change_id))
			database.commit()
			display_current_page()
		else:
			try:
				change_id = int(change_id)
			except Exception as e:
				tkinter.messagebox.showerror("错误","输入错误")
				return None
			cursor.execute('update teacher_info set name = "%s" where id = %d' % (change_name, change_id))
			database.commit()	
			display_current_page()

	if len(change_age) > 0:
		if (change_who == "学生"):
			try:
				change_age = int(change_age)
			except Exception as e:
				tkinter.messagebox.showerror("错误","输入错误")
				return None
			cursor.execute('update student_info set age = "%s" where id = %d' % (int(change_age), int(change_id)))
			database.commit()
			display_current_page()
		else:
			try:
				change_age = int(change_age)
			except Exception as e:
				tkinter.messagebox.showerror("错误","输入错误")
				return None
			cursor.execute('update teacher_info set age = "%s" where id = %d' % (int(change_age), int(change_id)))
			database.commit()	
			display_current_page()
	if len(change_grade) > 0:
		if (change_who == "学生"):
			try:
				change_grade = int(change_grade)
			except Exception as e:
				tkinter.messagebox.showerror("错误","输入错误")
				return None
			cursor.execute('update student_info set grade = "%s" where id = %d' % (int(change_grade), int(change_id)))
			database.commit()
			display_current_page()
		else:
			try:
				change_grade = int(change_grade)
			except Exception as e:
				tkinter.messagebox.showerror("错误","输入错误")
				return None

			cursor.execute('update teacher_info set grade = "%s" where id = %d' % (int(change_grade), int(change_id)))
			database.commit()	
			display_current_page()
	if index != -1:
		if (change_who == "学生"):
			cursor.execute('update student_info set gender = "%s" where id = %d' % ("男" if index==0 else "女", int(change_id)))
			database.commit()
			display_current_page()
		else:
			cursor.execute('update teacher_info set gender = "%s" where id = %d' % ("男" if index==0 else "女", int(change_id)))
			database.commit()	
			display_current_page()


'''
	Label(myWindow, text="搜索选项:",font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 0)
	combobox_1 = ttk.Combobox(myWindow, values = ['按编号搜索','按姓名搜索'], width=17)
	combobox_1.grid(column = 1, row = 0)

	Label(myWindow, text="搜索关键字:",font=('Arial 12 bold'),width=10,height=1).grid(column = 2, row = 0)
	entry1=Entry(myWindow)
	entry1.grid(column = 3, row = 0)

	button1 = Button(text = '搜索',relief = 'raised', command = button_search_clicked)
	button1.grid(column = 4, row = 0)

'''
def button_search_clicked():
	
	
	index = combobox_1.current()
	content = entry1.get().strip()

	if index == -1:
		tkinter.messagebox.showerror("错误","请选择搜索依据")
		return None
	if len(content) == 0:
		tkinter.messagebox.showerror("错误","请输入搜索内容")
		return None

	if index == 0:
		try:
			search_id = int(content)
		except Exception as e:
			tkinter.messagebox.showerror("Error","请输入正确id")
			return None
		cursor.execute('select * from student_info where id = %d' % search_id)
		data1 = cursor.fetchall()
		cursor.execute('select * from teacher_info where id = %d' % search_id)
		data2 = cursor.fetchall()
		
		listbox1.delete(0,END)
		listbox2.delete(0,END)
		listbox3.delete(0,END)
		listbox4.delete(0,END)
		listbox5.delete(0,END)
		listbox6.delete(0,END)
		for d in data1:
			listbox1.insert(END,'学生')
			listbox2.insert(END, d[0])
			listbox3.insert(END, d[1])
			listbox4.insert(END, d[2])
			listbox5.insert(END, d[3])
			listbox6.insert(END, d[4])

		for d in data2:
			listbox1.insert(END,'老师')
			listbox2.insert(END, d[0])
			listbox3.insert(END, d[1])
			listbox4.insert(END, d[2])
			listbox5.insert(END, d[3])
			listbox6.insert(END, d[4])
	if index == 1:
		cursor.execute('select * from student_info where name = "%s"' % content)
		data1 = cursor.fetchall()
		cursor.execute('select * from teacher_info where name = "%s"' % content)
		data2 = cursor.fetchall()
		
		listbox1.delete(0,END)
		listbox2.delete(0,END)
		listbox3.delete(0,END)
		listbox4.delete(0,END)
		listbox5.delete(0,END)
		listbox6.delete(0,END)
		for d in data1:
			listbox1.insert(END,'学生')
			listbox2.insert(END, d[0])
			listbox3.insert(END, d[1])
			listbox4.insert(END, d[2])
			listbox5.insert(END, d[3])
			listbox6.insert(END, d[4])

		for d in data2:
			listbox1.insert(END,'老师')
			listbox2.insert(END, d[0])
			listbox3.insert(END, d[1])
			listbox4.insert(END, d[2])
			listbox5.insert(END, d[3])
			listbox6.insert(END, d[4])

#初始化Tk()
myWindow = Tk()
#设置标题
myWindow.title('学生信息管理系统登陆')
myWindow.geometry('360x240')
#创建一个标签,显示文本
Label(myWindow, text="用户名:",font=('Arial 12 bold'),width=10,height=1).place(relx = 0.10, rely = 0.3)
Label(myWindow, text="密码:",font=('Arial 12 bold'),width=10,height=1).place(relx = 0.10, rely = 0.5)
Label(myWindow, text="登陆身份:",font=('Arial 12 bold'),width=10,height=1).place(relx = 0.10, rely = 0.1)

combobox_login = ttk.Combobox(myWindow, values = ['管理员','教师','学生'], width=17)
combobox_login.place(relx = 0.45, rely = 0.1)

button_login = Button(text = '登陆',relief = 'raised', command = button_login_clicked)
button_login.place(relx = 0.5, rely = 0.7)

entry1=Entry(myWindow)
entry2=Entry(myWindow)
entry1.place(relx = 0.45, rely = 0.3)
entry2.place(relx = 0.45, rely = 0.5)
#进入消息循环
myWindow.mainloop()

'''
myWindow = Tk()
	#设置标题
	myWindow.title('学生界面')
	myWindow.geometry('1280x640')
	Label(myWindow, text='输入学号查询信息',font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 0)
	entry111=Entry(myWindow)
	entry111.grid(column = 1, row = 0)

	button111 = Button(text = '查询',relief = 'raised', command = Student_click)
	button111.grid(column = 2, row = 0)
'''
def Student_click():
	content = entry111.get()
	if len(content) == 0:
		tkinter.messagebox.showerror("Error","请输入学号")
	try:
		content = int(content)
	except Exception as e:
		tkinter.messagebox.showerror("Error","请输入正确学号")
		return None
	
	cursor.execute("select * from student_info where id = %d" % content)
	data = cursor.fetchall()
	if len(data) == 0:
		tkinter.messagebox.showerror("Error","学号不存在")	
		return None
	tkinter.messagebox.showinfo("学生信息","学号:%d\n姓名:%s\n性别:%s\n年龄:%d\n年级:%d" % (
			data[0][0], data[0][1], data[0][2], data[0][3], data[0][4]))	


if mode == 0:
	print("asdasd")
	page = 0
	who = 1
	#初始化Tk()
	myWindow = Tk()
	#设置标题
	myWindow.title('管理员界面')
	myWindow.geometry('1280x640')
	#创建一个标签,显示文本
	Label(myWindow, text="搜索选项:",font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 0)
	combobox_1 = ttk.Combobox(myWindow, values = ['按编号搜索','按姓名搜索'], width=17)
	combobox_1.grid(column = 1, row = 0)

	Label(myWindow, text="搜索关键字:",font=('Arial 12 bold'),width=10,height=1).grid(column = 2, row = 0)
	entry1=Entry(myWindow)
	entry1.grid(column = 3, row = 0)

	button1 = Button(text = '搜索',relief = 'raised', command = button_search_clicked)
	button1.grid(column = 4, row = 0)

	button2 = Button(text = '显示所有学生信息',relief = 'raised', command = button2_clicked)
	button2.grid(column = 5, row = 0)

	button3 = Button(text = '显示所有教师信息',relief = 'raised', command = button_teacher_clicked)
	button3.grid(column = 6, row = 0)

	Label(myWindow, text=" ",font=('Arial 12 bold'),width=4,height=1).grid(column = 0, row = 1)

	Label(myWindow, text="身份",font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 2)
	listbox1 = Listbox(myWindow,height=20,selectmode="browse",font=('Arial 12 bold'))
	listbox1.grid(column = 0, row = 3)


	Label(myWindow, text="编号",font=('Arial 12 bold'),width=10,height=1).grid(column = 1, row = 2)
	listbox2 = Listbox(myWindow,height=20,selectmode="browse",font=('Arial 12 bold'))
	listbox2.grid(column = 1, row = 3)


	Label(myWindow, text="姓名",font=('Arial 12 bold'),width=10,height=1).grid(column = 2, row = 2)
	listbox3 = Listbox(myWindow,height=20,width = 10,selectmode="browse",font=('Arial 12 bold'))
	listbox3.grid(column = 2, row = 3)


	Label(myWindow, text="性别",font=('Arial 12 bold'),width=10,height=1).grid(column = 3, row = 2)
	listbox4 = Listbox(myWindow,height=20,width = 5,selectmode="browse",font=('Arial 12 bold'))
	listbox4.grid(column = 3, row = 3)


	Label(myWindow, text="年龄",font=('Arial 12 bold'),width=10,height=1).grid(column = 4, row = 2)
	listbox5 = Listbox(myWindow,height=20,width = 8,selectmode="browse",font=('Arial 12 bold'))
	listbox5.grid(column = 4, row = 3)


	Label(myWindow, text="年级",font=('Arial 12 bold'),width=10,height=1).grid(column = 5, row = 2)
	listbox6 = Listbox(myWindow,height=20,width = 8,selectmode="browse",font=('Arial 12 bold'))
	listbox6.grid(column = 5, row = 3)


	Label(myWindow, text='身份无法修改',font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 4)
	Label(myWindow, text='编号无法修改',font=('Arial 12 bold'),width=10,height=1).grid(column = 1, row = 4)
	entry11=Entry(myWindow)
	entry11.grid(column = 2, row = 4)
	combobox_22 = ttk.Combobox(myWindow, values = ['男','女'], width=17)
	combobox_22.grid(column = 3, row = 4)
	entry22=Entry(myWindow)
	entry22.grid(column = 4, row = 4)
	entry33=Entry(myWindow)
	entry33.grid(column = 5, row = 4)
	button4 = Button(text = '修改',relief = 'raised', command = button_change_clicked)
	button4.grid(column = 6, row = 4)



	combobox_2 = ttk.Combobox(myWindow, values = ['学生','教师'], width=17)
	combobox_2.grid(column = 0, row = 5)

	entry4=Entry(myWindow)
	entry4.grid(column = 1, row = 5)
	entry5=Entry(myWindow)
	entry5.grid(column = 2, row = 5)
	combobox_3 = ttk.Combobox(myWindow, values = ['男','女'], width=17)
	combobox_3.grid(column = 3, row = 5)
	entry7=Entry(myWindow)
	entry7.grid(column = 4, row = 5)
	entry8=Entry(myWindow)
	entry8.grid(column = 5, row = 5)

	button5 = Button(text = '添加',relief = 'raised', command = button_add_clicked)
	button5.grid(column = 6, row = 5)

	button6 = Button(text = '删除',relief = 'raised', command = button_delete_clicked)
	button6.grid(column = 6, row = 6)

	button7 = Button(text = '上一页',relief = 'raised', command = display_previous_page)
	button7.grid(column = 3, row = 7)

	button8 = Button(text = '下一页',relief = 'raised', command = button_next_page_clicked)
	button8.grid(column = 4, row = 7)
	#进入消息循环
	myWindow.mainloop()


elif mode == 1:
	print("asdasd")
	page = 0
	who = 1
	#初始化Tk()
	myWindow = Tk()
	#设置标题
	myWindow.title('教师界面')
	myWindow.geometry('1280x640')
	#创建一个标签,显示文本
	Label(myWindow, text="搜索选项:",font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 0)
	combobox_1 = ttk.Combobox(myWindow, values = ['按编号搜索','按姓名搜索'], width=17)
	combobox_1.grid(column = 1, row = 0)

	Label(myWindow, text="搜索关键字:",font=('Arial 12 bold'),width=10,height=1).grid(column = 2, row = 0)
	entry1=Entry(myWindow)
	entry1.grid(column = 3, row = 0)

	button1 = Button(text = '搜索',relief = 'raised', command = button_search_clicked)
	button1.grid(column = 4, row = 0)

	button2 = Button(text = '显示所有学生信息',relief = 'raised', command = button2_clicked)
	button2.grid(column = 5, row = 0)


	Label(myWindow, text=" ",font=('Arial 12 bold'),width=4,height=1).grid(column = 0, row = 1)

	Label(myWindow, text="身份",font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 2)
	listbox1 = Listbox(myWindow,height=20,selectmode="browse",font=('Arial 12 bold'))
	listbox1.grid(column = 0, row = 3)


	Label(myWindow, text="编号",font=('Arial 12 bold'),width=10,height=1).grid(column = 1, row = 2)
	listbox2 = Listbox(myWindow,height=20,selectmode="browse",font=('Arial 12 bold'))
	listbox2.grid(column = 1, row = 3)


	Label(myWindow, text="姓名",font=('Arial 12 bold'),width=10,height=1).grid(column = 2, row = 2)
	listbox3 = Listbox(myWindow,height=20,width = 10,selectmode="browse",font=('Arial 12 bold'))
	listbox3.grid(column = 2, row = 3)


	Label(myWindow, text="性别",font=('Arial 12 bold'),width=10,height=1).grid(column = 3, row = 2)
	listbox4 = Listbox(myWindow,height=20,width = 5,selectmode="browse",font=('Arial 12 bold'))
	listbox4.grid(column = 3, row = 3)


	Label(myWindow, text="年龄",font=('Arial 12 bold'),width=10,height=1).grid(column = 4, row = 2)
	listbox5 = Listbox(myWindow,height=20,width = 8,selectmode="browse",font=('Arial 12 bold'))
	listbox5.grid(column = 4, row = 3)


	Label(myWindow, text="年级",font=('Arial 12 bold'),width=10,height=1).grid(column = 5, row = 2)
	listbox6 = Listbox(myWindow,height=20,width = 8,selectmode="browse",font=('Arial 12 bold'))
	listbox6.grid(column = 5, row = 3)


	Label(myWindow, text='身份无法修改',font=('Arial 12 bold'),width=10,height=1).grid(column = 0, row = 4)
	Label(myWindow, text='编号无法修改',font=('Arial 12 bold'),width=10,height=1).grid(column = 1, row = 4)
	entry11=Entry(myWindow)
	entry11.grid(column = 2, row = 4)
	combobox_22 = ttk.Combobox(myWindow, values = ['男','女'], width=17)
	combobox_22.grid(column = 3, row = 4)
	entry22=Entry(myWindow)
	entry22.grid(column = 4, row = 4)
	entry33=Entry(myWindow)
	entry33.grid(column = 5, row = 4)
	button4 = Button(text = '修改',relief = 'raised', command = button_change_clicked)
	button4.grid(column = 6, row = 4)



	combobox_2 = ttk.Combobox(myWindow, values = ['学生'], width=17)
	combobox_2.grid(column = 0, row = 5)

	entry4=Entry(myWindow)
	entry4.grid(column = 1, row = 5)
	entry5=Entry(myWindow)
	entry5.grid(column = 2, row = 5)
	combobox_3 = ttk.Combobox(myWindow, values = ['男','女'], width=17)
	combobox_3.grid(column = 3, row = 5)
	entry7=Entry(myWindow)
	entry7.grid(column = 4, row = 5)
	entry8=Entry(myWindow)
	entry8.grid(column = 5, row = 5)

	button5 = Button(text = '添加',relief = 'raised', command = button_add_clicked)
	button5.grid(column = 6, row = 5)

	button6 = Button(text = '删除',relief = 'raised', command = button_delete_clicked)
	button6.grid(column = 6, row = 6)

	button7 = Button(text = '上一页',relief = 'raised', command = display_previous_page)
	button7.grid(column = 3, row = 7)

	button8 = Button(text = '下一页',relief = 'raised', command = button_next_page_clicked)
	button8.grid(column = 4, row = 7)
	#进入消息循环
	myWindow.mainloop()


elif mode == 2:
	myWindow = Tk()
	#设置标题
	myWindow.title('学生界面')
	myWindow.geometry('1280x640')
	Label(myWindow, text='输入学号查询信息',font=('Arial 12 bold'),height=1).grid(column = 0, row = 0)
	entry111=Entry(myWindow)
	entry111.grid(column = 1, row = 0)

	button111 = Button(text = '查询',relief = 'raised', command = Student_click)
	button111.grid(column = 2, row = 0)

	myWindow.mainloop()

 

 

 

 

 

python做学生信息管理系统,python编辑学生信息系统 在我的前一篇博客中我使用了Tinker作为基础,但是Tinker的缺点就是太枯燥,在美化方面不是很容易进行,因此这次我想分享一下使用pyqt5制作的学生管理系统。当然这其实也是我的一个课时作业,在上次的基础上,我们不再使用表格,而是运用大家使用更多的储存数据的方式——mysql数据库,通过调用数据库中的数据来实现我们的增删改查,且带有登录界面的管理系统python简单图案代码。接下来我将与大家分享一下我的学生信息管理系统。 阅读详情

相关推荐

[附源码]基于flask框架学生信息管理系统(python+mysql+论文)

随着互联网技术的不断发展,传统的学生信息管理系统已经无法满足现代教育需求,因此,开发一款基于前端技术HTML+CSS+JavaScript+Vue和后端技术Python+Flask的学生信息管理系统显得尤为重要。Python版本为3.7.7,这是一个稳定且广泛支持的版本,确保了系统的兼容性和安全性。在数据库管理工具的选择上,使用了Navicat 11,这是一个用户友好且功能强大的数据库管理软件,它支持多种数据库系统,包括MySQL,并提供了图形化界面,使得数据库的管理和维护工作更加便捷。

计算机专业毕设程序 695

学生公寓管理系统-python+Django+Mysql(附视图代码)

数据库课设,附视图代码

qq_56341866的博客 1万+

基于Python guI的学生信息管理系统的设计与实现

讲述的是一个使用Python GUI的学习资料管理工具。通过使用Python的Tkinter库和mysql数据库,这个工具可以方便地记录、检索、更新学习资料。本文详细描述了系统的架构设计和实现过程,并对系统进行了功能测试和性能测试。结果表明,该系统具有良好的用户界面和稳定的性能,能够满足学生信息管理的需求。

m0_56073435的博客 3027

Python+MySQL+Tkinter设计学生信息管理系统(速成)

这里我们将先前在图形化界面创建好的数据对应上即可,这样就连接完成了#!# 打开数据库连接#生成数据库# 使用 cursor() 方法创建一个游标对象。

Keitheasun的博客 1万+

学生信息管理系统(Python版)详解

Python是一种广泛应用于系统开发的高级编程语言,以其简洁明了的语法和强大的库支持,成为了IT行业的宠儿。它非常适合快速开发应用程序,尤其在数据处理、网络爬虫、人工智能等领域有着卓越表现。MySQL是一个多用户、多线程的数据库管理系统,它使用客户机/服务器模型。MySQL的核心架构包括以下几个组件:连接器:处理客户端的连接请求。服务层:包含查询解析器、优化器和执行器。引擎层:负责具体的存储和检索数据。

weixin_42443533的博客 854

学生信息管理系统(python+GUI+mysql).zip

学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip 学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip 学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip 学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip 学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip,学生信息管理系统(python+GUI+mysql).zip 学生信息管理系统(python+GUI+mysql).zip

Java+Swing+sqlserver学生成绩管理系统

Java+Swing+sqlserver学生成绩管理系统一、系统介绍二、系统展示1.登陆2.课程分配3.选课管理4.学生打分--教师4.查询个人成绩--学生三、其他1.其它系统2.获取源码 一、系统介绍 管理员:登陆页面、课程管理、选课管理 老师:给学生打分 学生:查询个人成绩 二、系统展示 1.登陆 2.课程分配 3.选课管理 4.学生打分–教师 4.查询个人成绩–学生 三、其他 1.其它系统 Java+Swing实现学生选课管理系统 Java+Swing实现学校教务管理系统 Java+Swin

qq_33037637的博客 6952

最全中文停用词表(可直接复制)

最全的停用此表整理 词表名 词表文件 中文停用词表 cn_stopwords.txt 哈工大停用词表 hit_stopwords.txt 百度停用词表 baidu_stopwords.txt 机器智能实验室停用词库 scu_stopwords.txt 以上停用词表链接:https://github.com/goto456/stopwords 以下是我常用的1893个停用词,可直接复制 ! " # $ % & ' ( ) * + , - -- . .. ... ....

dilifish的博客 12万+

Python题目:学生信息管理系统-高级版(图形界面+MySQL数据库)

Python题目:学生信息管理系统-高级版(图形界面+MySQL数据库) 使用图形界面显示,选用list、tuple、dictionary或map等数据结构,操作数据库存储X个学生的三门课的成绩(机器学习、Python程序设计、研究生英语),并实现以下功能: 1.添加学生信息 2.修改学生信息 3.删除学生 4.添加学生的成绩 5.修改学生成绩 6.按姓名或者学号查找学生,显示学...

清晨的光明 8万+

AI 代码赋能短视频带货:服装及多赛道批量内容生产全流程实操

本文聚焦 AI 技术在短视频带货领域的落地应用,以服装赛道为核心,延伸至花卉绿植、图书、茶具等热门领域,系统拆解 AI 工具在选品、素材处理、视频制作(含动态效果、场景搭建)、运营优化等环节的实操方法。针对从业者普遍面临的 “内容生产低效”“无专业技术难出优质视频”“流量运营踩坑” 等痛点,提供从基础工具使用到高阶视频制作的全流程技术方案,助力相关从业者借助 AI 实现批量、高效的短视频内容产出。

m0_67958922的博客 3081

单片机如何获得5V电源

在单片机实际设计中,有时会需要在电路中用到5V电压源,那么这个常见的实验需求有哪些办法解决呢,我综合网上的资料,概括一下: 1)USB    这种方法在我们直接将单片机板与电脑连接调试的时候,算是简单又方便的办法了,但如果我所要得到的成品不直接连接外部的器件,这就得舍弃。     常用的,USB/5V插头线,这是一种专门的电源线,一端是USB通用接口,可以直插USB端口,另一端是内正外负电压

Echo_Ana的博客 3万+

python+mysql+tkinter学生信息管理系统

需求分析 (1)使用mysql存储学生和管理员信息 (2)通过tkinter模块创建图形界面,实现管理员的登录,对学生信息的增删改查,以及修改管理员自己的密码。 整个工程类与方法 数据库设计 使用mysql数据库创建 menege表和student表 menege表的创建: create table manege( user_name varchr(6) not null, user_pwd char(6) not null, user_state int(1) not null primary

weixin_43580438的博客 8976

基于Gardner环的QPSK定时同步MATLAB仿真:四倍采样与多场景性能分析

本文详细介绍了基于Gardner环的QPSK定时同步MATLAB仿真方法,重点分析了四倍采样技术在定时同步中的应用与性能优化。通过MATLAB代码实例展示了Gardner环的实现原理、多场景性能分析及常见问题解决方案,为数字通信系统的定时同步设计提供实用参考。

weixin_29083475的博客 373

python学生信息管理系统+MySql数据库

自学了python的数据库后,编写了一个简单的学生信息管理系统+MySQL数据库,希望能对各位读者有所帮助 源代码在后面!!! 也可以点击这里的下载: 先上图: 录入学生后的数据库信息: 另存的信息如下: 数据库信息: 本人使用的是MySQL5.7版本的数据库 数据库端口号为:3306 数据库连接名是:root 数据库用户名是:root 数据库名称是:mydatabase 建立的表是:student student的信息为: 源码: Database.py的代码: import pymysq

浮生~的博客 1万+

【eNSP 华为模拟器】单臂路由实战:从原理到配置全解析

本文详细解析了单臂路由技术,通过华为eNSP模拟器从原理到配置进行实战教学。文章阐述了单臂路由如何利用路由器单物理接口创建多个子接口,实现不同VLAN间通信,并提供了完整的操作步骤、配置命令及排错方法,帮助网络工程师掌握这一经典网络技术。

696

自定义载板RK3588HDMI输入配置完整解决方案

✅ HDMI输入信号检测✅ 自动时序识别(支持1080p@60Hz等标准格式)✅ V4L2视频设备接口✅ 实时视频流捕获✅ H.264编码录制✅ HDCP内容保护支持问题根因识别:发现了hdmim1模块资源冲突的本质问题硬件设计理解:明确了Orange Pi 5 Plus的真实硬件设计意图功能实现:成功启用HDMI输入功能,替代了无法使用的HDMI1输出完整验证:建立了从硬件检测到视频录制的完整测试流程。

梁俊星的博客 1271

python学生信息管理系统(Tkinter+GUI+MySQL)

python的tkinter编写的学生信息管理系统,使用MySQL存储数据,实现了登录、注册、增删改查和导出为Excel的功能。

浮生~的博客 2万+

Qt和FFmpeg的视频压缩工具

m_progressDialog = new QProgressDialog("正在压缩视频...", "取消", 0, 100, parent);QString file = QFileDialog::getOpenFileName(this, "选择视频文件", "",QString file = QFileDialog::getSaveFileName(this, "保存压缩文件", "",QMessageBox::warning(parent, "错误", "请设置输入和输出文件路径");

寒寒豆豆软件公司的博客 101

python 实现学生信息管理系统+MySql 数据库,包含源码及相关实现说明~

系统说明:python 编写的学生信息管理系统+MySQL数据库,实现了增删改查的基本功能。

早知晓的博客 2万+

大语言模型应用指南:幻觉和偏见问题

大语言模型应用指南:幻觉和偏见问题 1. 背景介绍 1.1 大语言模型的发展历程 1.1.1 早期的语言模型 1.1.2 Tr

AI天才研究院 958

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

基于python+django+Mysql的学生信息管理系统

💗博主介绍:✌计算机全栈开发工作室,接各类程序定制开发,有需要的滴滴✌💗主要内容:SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app、大数据、物联网、机器学习等设计与开发。✌💗👇🏻精彩专栏 推荐订阅👇🏻🌟文末获取源码+数据库🌟。

专注于大学生项目实战开发,讲解,毕业答疑辅导,高校老师/讲师/同行合作。以及产品测评宣传、工具推广等合作。全网粉丝30万+,优快云特邀博主,Java新星计划多届导师,掘金/知乎/华为云/阿里云/51CTO等平台优质创作者。 2086

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

基于Python和MySQL的学生信息管理系统

本文介绍了一个基于Python和MySQL的学生信息管理系统。该系统可以实现学生信息的录入、查询、更新、删除以及清空数据表等功能,适合用于学校或教育机构的日常管理。本项目实现了一个功能完善的学生信息管理系统,支持学生信息的录入、查询、更新、删除和清空数据表。通过Python和MySQL的结合,系统具有较高的稳定性和扩展性。未来可以进一步优化,例如增加用户界面、支持批量导入导出等。希望本文对您有所帮助!

2303_77248325的博客 725

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

【附源码】基于flask框架学生信息管理系统 (python+mysql+论文)

学生信息管理系统的建立,不仅能够实现学生信息的数字化、标准化管理,还能够通过系统的数据分析功能,帮助教育管理者掌握学生的学习状况和发展趋势,从而做出更加科学合理的教育决策。此外,一个良好的学生信息管理系统还能提升学校的信息化水平,增强学校对外的形象,同时也为学生和家长提供了一个透明、便捷的信息获取平台。在数据库管理工具的选择上,使用了Navicat 11,这是一个用户友好且功能强大的数据库管理软件,它支持多种数据库系统,包括MySQL,并提供了图形化界面,使得数据库的管理和维护工作更加便捷。

JAVA程序设计 1147

基于python+django+Mysql的学生信息管理系统(源码+lw+部署文档+讲解等)

基于 Python + Django + MySQL 的学生信息管理系统,借助 Python 的简洁高效、Django 的便捷开发特性以及 MySQL 强大的数据存储能力,为学校提供一个全面的学生信息管理解决方案。 Python 丰富的库能助力实现各类复杂业务逻辑。Django 作为 Web 框架,负责处理请求、响应,快速搭建系统的 Web 界面与交互逻辑。MySQL 则用于稳定存储学生的各类信息。 系统主要模块包括:学生信息管理模块,可对学生基本信息(姓名、性别、年龄、联系方式等)、学业信息(成绩、课程选

全网粉丝10W+、全栈领域优质创作者、掘金、阿里云等社区博客专家、专注于全栈领域和毕业项目实战 1145
上一篇: 强化学习-利用Q-Learning算法玩走方格游戏(C++)
下一篇: 【STM32 + HAL库】倒立摆
WilliamCode
博客等级 码龄11年 118粉丝 105原创
评论 10
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值