main.py
"""
__author__ = 'bearcarl'
__version__ = '1.0'
from tkinter import *
from tkinter import ttk
from tkinter import messagebox # 导入提示窗口包
from connect_mysql import Mysql_conn
from dLink import DouLink, Node
# 设置窗口大小
def center_window(root, width, height):
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
root.geometry(size)
class GUI:
"""给每个组件都命名是为了以后迭代方便"""
def __init__(self, root):
# 创建双向链表
self.dl = DouLink()
root.title('信息管理系统')
# 设置窗口大小
center_window(root, 800, 600)
root.maxsize(1200, 800)
root.minsize(300, 240)
# root.iconbitmap('1.ico')
# delete_event
search_label = ttk.Label(root, text='删除教师编号').grid(row=0, column=4)
dl_entry1 = ttk.Entry(root)
dl_entry1.grid(row=0, column=5)
button1 = ttk.Button(root, text='删除', command=lambda: delete_event(dl_entry1.get())).grid(row=0,
column=6)
search_label = ttk.Label(root, text='教师编号').grid(row=0, column=1)
search_entry1 = ttk.Entry(root)
search_entry1.grid(row=0, column=2)
button1 = ttk.Button(root, text='查询', command=lambda: search_event(1, search_entry1.get())).grid(row=0,
column=3)
search_labe2 = ttk.Label(root, text='教师姓名').grid(row=1, column=1)
search_entry2 = ttk.Entry(root)
search_entry2.grid(row=1, column=2)
button2 = ttk.Button(root, text='查询', command=lambda: search_event(2, search_entry2.get())).grid(row=1,
column=3)
search_labe3 = ttk.Label(root, text='出生年月').grid(row=2, column=1)
search_entry3 = ttk.Entry(root)
search_entry3.grid(row=2, column=2)
button3 = ttk.Button(root, text='查询', command=lambda: search_event(3, search_entry3.get())).grid(row=2,
column=3)
search_labe4 = ttk.Label(root, text='工资').grid(row=3, column=1)
search_entry4 = ttk.Entry(root)
search_entry4.grid(row=3, column=2)
button4 = ttk.Button(root, text='查询', command=lambda: search_event(4, search_entry4.get())).grid(row=3,
column=3)
search_labe5 = ttk.Label(root, text='参加工作时间').grid(row=4, column=1)
search_entry5 = ttk.Entry(root)
search_entry5.grid(row=4, column=2)
button5 = ttk.Button(root, text='查询', command=lambda: search_event(5, search_entry5.get())).grid(row=4,
column=3)
add_button = ttk.Button(root, text='添加', command=lambda: addwindow_event()).grid(row=0, column=0)
updata_button = ttk.Button(root, text='更新信息', command=lambda: upadatawindow_event()).grid(row=1, column=0)
all_button = ttk.Button(root, text='查询全部', command=lambda: reload()).grid(row=2, column=0)
# 信息提示框
info_label = ttk.Label(root, text="信息展示窗口", background='#66ccff', width=100, anchor='center') \
.grid(row=7, column=0, columnspan=8)
# 信息展示
Listbox(root, height=8, width=110).grid(row=8, column=0, columnspan=10)
# 选择函数, 直接用SQL进行排序
def sort_event(n):
# 连接数据库
conn_1 = Mysql_conn()
if n == 1:
# 构造查询SQL
sw = 'SELECT * FROM STUDENT ORDER BY ID'
stu_info = conn_1.select(sw)
show_listbox = Listbox(root, height=8, width=110)
for row in stu_info:
show_listbox.insert(END, row)
show_l