...........做了一個學生信息管理的簡單數據庫程序,寫了一點簡單的UI界面,功能不是很強大,代碼組織也很不科學,洋洋灑灑竟然寫了700多行.......分享出來,一起學習
/**********************************
@ author:????CSDN @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()
?
?
?
?
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
