欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python+tkinter實(shí)現(xiàn)學(xué)生管理系統(tǒng)

 更新時(shí)間:2019年08月20日 14:23:18   作者:WF帆少  
這篇文章主要為大家詳細(xì)介紹了python+tkinter實(shí)現(xiàn)學(xué)生管理系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了python+tkinter實(shí)現(xiàn)學(xué)生管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下 


from tkinter import *
from tkinter.messagebox import *
import sqlite3
from tkinter import ttk
 
dbstr = "H:\mydb.db"
 
root = Tk()
root.geometry('700x1000')
root.title('學(xué)生管理系統(tǒng)')
 
Label(root, text="學(xué)號(hào):").place(relx=0, rely=0.05, relwidth=0.1)
Label(root, text="姓名:").place(relx=0.5, rely=0.05, relwidth=0.1)
Label(root, text="電話:").place(relx=0, rely=0.1, relwidth=0.1)
Label(root, text="地址:").place(relx=0.5, rely=0.1, relwidth=0.1)
 
sid = StringVar()
name = StringVar()
phone = StringVar()
address = StringVar()
Entry(root, textvariable=sid).place(relx=0.1, rely=0.05, relwidth=0.37, height=25)
Entry(root, textvariable=name).place(relx=0.6, rely=0.05, relwidth=0.37, height=25)
 
Entry(root, textvariable=phone).place(relx=0.1, rely=0.1, relwidth=0.37, height=25)
Entry(root, textvariable=address).place(relx=0.6, rely=0.1, relwidth=0.37, height=25)
 
Label(root, text='學(xué)生信息管理', bg='white', fg='red', font=('宋體', 15)).pack(side=TOP, fill='x')
 
 
def showAllInfo():
 x = dataTreeview.get_children()
 for item in x:
  dataTreeview.delete(item)
 con = sqlite3.connect(dbstr)
 cur = con.cursor()
 cur.execute("select * from student")
 lst = cur.fetchall()
 for item in lst:
  dataTreeview.insert("", 1, text="line1", values=item)
 cur.close()
 con.close()
 
 
def appendInfo():
 if sid.get() == "":
  showerror(title='提示', message='輸入不能為空')
 elif name.get() == "":
  showerror(title='提示', message='輸入不能為空')
 elif phone.get() == "":
  showerror(title='提示', message='輸入不能為空')
 elif address.get() == "":
  showerror(title='提示', message='輸入不能為空')
 else:
  x = dataTreeview.get_children()
  for item in x:
   dataTreeview.delete(item)
  list1 = []
  list1.append(sid.get())
  list1.append(name.get())
  list1.append(phone.get())
  list1.append(address.get())
  con = sqlite3.connect(dbstr)
  cur = con.cursor()
  cur.execute("insert into student values(?,?,?,?)", tuple(list1))
  con.commit()
  cur.execute("select * from student")
  lst = cur.fetchall()
  for item in lst:
   dataTreeview.insert("", 1, text="line1", values=item)
  cur.close()
  con.close()
 
 
def deleteInfo():
 con = sqlite3.connect(dbstr)
 cur = con.cursor()
 cur.execute("select * from student")
 studentList = cur.fetchall()
 cur.close()
 con.close()
 print(studentList)
 
 num = sid.get()
 flag = 0
 if num.isnumeric() == False:
  showerror(title='提示', message='刪除失敗')
 for i in range(len(studentList)):
  for item in studentList[i]:
   if int(num) == item:
    flag = 1
    con = sqlite3.connect(dbstr)
    cur = con.cursor()
    cur.execute("delete from student where id = ?", (int(num),))
    con.commit()
    cur.close()
    con.close()
    break
 if flag == 1:
  showinfo(title='提示', message='刪除成功!')
 else:
  showerror(title='提示', message='刪除失敗')
 
 x = dataTreeview.get_children()
 for item in x:
  dataTreeview.delete(item)
 
 con = sqlite3.connect(dbstr)
 cur = con.cursor()
 cur.execute("select * from student")
 lst = cur.fetchall()
 for item in lst:
  dataTreeview.insert("", 1, text="line1", values=item)
 cur.close()
 con.close()
 
 
Button(root, text="顯示所有信息", command=showAllInfo).place(relx=0.2, rely=0.2, width=100)
Button(root, text="追加信息", command=appendInfo).place(relx=0.4, rely=0.2, width=100)
Button(root, text="刪除信息", command=deleteInfo).place(relx=0.6, rely=0.2, width=100)
 
 
dataTreeview = ttk.Treeview(root, show='headings', column=('sid', 'name', 'phone', 'address'))
dataTreeview.column('sid', width=150, anchor="center")
dataTreeview.column('name', width=150, anchor="center")
dataTreeview.column('phone', width=150, anchor="center")
dataTreeview.column('address', width=150, anchor="center")
 
dataTreeview.heading('sid', text='學(xué)號(hào)')
dataTreeview.heading('name', text='名字')
dataTreeview.heading('phone', text='電話')
dataTreeview.heading('address', text='地址')
 
dataTreeview.place(rely=0.3, relwidth=0.97)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python的類實(shí)例屬性訪問(wèn)規(guī)則探討

    Python的類實(shí)例屬性訪問(wèn)規(guī)則探討

    這篇文章主要介紹了Python的類實(shí)例屬性訪問(wèn)規(guī)則,本文總結(jié)了一些對(duì)C++和Java程序員來(lái)說(shuō)不是很直觀的地方來(lái)說(shuō)明Python中的類實(shí)例屬性訪問(wèn),需要的朋友可以參考下
    2015-01-01
  • python圣誕樹(shù)編寫實(shí)例詳解

    python圣誕樹(shù)編寫實(shí)例詳解

    在本篇文章里小編給大家整理的是關(guān)于python圣誕樹(shù)代碼的相關(guān)內(nèi)容,有興趣的朋友們可以學(xué)習(xí)下。
    2020-02-02
  • python游戲?qū)崙?zhàn)項(xiàng)目之童年經(jīng)典超級(jí)瑪麗

    python游戲?qū)崙?zhàn)項(xiàng)目之童年經(jīng)典超級(jí)瑪麗

    史上十大最經(jīng)典小霸王游戲中魂斗羅只能排在第二,那么第一是誰(shuí)?最經(jīng)典最風(fēng)靡的當(dāng)屬超級(jí)瑪麗,那個(gè)戴帽子的大胡子穿著背帶褲的馬里奧哪個(gè)不認(rèn)得,小編帶你用python實(shí)現(xiàn)超級(jí)瑪麗緬懷童年
    2021-09-09
  • 不可錯(cuò)過(guò)的十本Python好書

    不可錯(cuò)過(guò)的十本Python好書

    不可錯(cuò)過(guò)的十本Python好書,分別適合入門、進(jìn)階到精深三個(gè)不同階段的人來(lái)閱讀,感興趣的小伙伴們可以參考一下
    2017-07-07
  • python區(qū)塊鏈地址的簡(jiǎn)版實(shí)現(xiàn)

    python區(qū)塊鏈地址的簡(jiǎn)版實(shí)現(xiàn)

    這篇文章主要為大家介紹了python區(qū)塊鏈地址的簡(jiǎn)版實(shí)現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-05-05
  • Python 占位符的使用方法詳解

    Python 占位符的使用方法詳解

    這篇文章主要介紹了Python 占位符的使用方法詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • python深度學(xué)習(xí)tensorflow1.0參數(shù)初始化initializer

    python深度學(xué)習(xí)tensorflow1.0參數(shù)初始化initializer

    這篇文章主要為大家介紹了python深度學(xué)習(xí)tensorflow1.0參數(shù)初始化initializer示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • pandas?dataframe寫入到hive方式

    pandas?dataframe寫入到hive方式

    這篇文章主要介紹了pandas?dataframe寫入到hive方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • Python遞歸函數(shù)反轉(zhuǎn)序列的實(shí)現(xiàn)

    Python遞歸函數(shù)反轉(zhuǎn)序列的實(shí)現(xiàn)

    本文主要介紹了Python遞歸函數(shù)反轉(zhuǎn)序列的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • Python+tkinter使用40行代碼實(shí)現(xiàn)計(jì)算器功能

    Python+tkinter使用40行代碼實(shí)現(xiàn)計(jì)算器功能

    這篇文章主要為大家詳細(xì)介紹了Python+tkinter使用40行代碼實(shí)現(xiàn)計(jì)算器功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-01-01

最新評(píng)論