怎么在python中利用tkinter实现一个学生管理系统

  介绍

这篇文章将为大家详细讲解有关怎么在python中利用tkinter实现一个学生管理系统,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

python可以做什么

python是一种编程语言,内置了许多有效的工具,python几乎无所不能,该语言通俗易懂,容易入门,功能强大,在许多领域中都有广泛的应用,例如最热门的大数据分析,人工智能,网页开发等。

具体内容如下,

得到tkinter  import  *   得到tkinter.messagebox  import  *   import  sqlite3   得到tkinter  import  ttk   ,   时间=dbstr “H: \ mydb.db"   ,   root =, Tk ()   root.geometry (& # 39; 700 x1000 # 39;)   root.title(& # 39;学生管理系统& # 39;)   ,   文本标签(根,,=把Ш?“).place (relx=0,,=0.05,, relwidth=0.1)   文本标签(根,,=靶彰?“).place (relx=0.5,=0.05,, relwidth=0.1)   文本标签(根,,=暗缁?“).place (relx=0,,=0.1,, relwidth=0.1)   文本标签(根,,=暗刂?“).place (relx=0.5,=0.1,, relwidth=0.1)   ,   时间=sid  StringVar ()   时间=name  StringVar ()   时间=phone  StringVar ()   时间=address  StringVar ()   条目(根,textvariable=sid) .place (relx=0.1,=0.05,, relwidth=0.37,,身高=25)   条目(根,textvariable=名字).place (relx=0.6,=0.05,, relwidth=0.37,,身高=25)   ,   条目(根,textvariable=电话).place (relx=0.1,=0.1,, relwidth=0.37,,身高=25)   条目(根,textvariable=地址).place (relx=0.6,=0.1,, relwidth=0.37,,身高=25)   ,   文本标签(根,,=& # 39;学生信息管理& # 39;,,bg=& # 39;白色# 39;,,fg=& # 39;红色# 39;,,字体=(& # 39;宋体& # 39;,,15)).pack(一边=,,填补=& # 39;x # 39;)   ,   ,   def  showAllInfo ():=,,x  dataTreeview.get_children ()   ,for  item  x:拷贝   dataTreeview.delete才能(项)=,,con  sqlite3.connect (dbstr)=,,cur  con.cursor ()   ,cur.execute (“select  *,得到student")=,,lst  cur.fetchall ()   ,for  item  lst拷贝:   dataTreeview.insert才能(“,,,1,,文本=發ine1",,值=项目)   ,cur.close ()   ,con.close ()   ,   ,   def  appendInfo ():   ,if  sid.get (),==,““:   showerror才能(title=& # 39;提示& # 39;,,消息=& # 39;输入不能为空& # 39;)   ,elif  name.get (),==,““:   showerror才能(title=& # 39;提示& # 39;,,消息=& # 39;输入不能为空& # 39;)   ,elif  phone.get (),==,““:   showerror才能(title=& # 39;提示& # 39;,,消息=& # 39;输入不能为空& # 39;)   ,elif  address.get (),==,““:   showerror才能(title=& # 39;提示& # 39;,,消息=& # 39;输入不能为空& # 39;)   ,其他的:   时间=x 才能;dataTreeview.get_children ()   for 才能;item  x:拷贝   ,,dataTreeview.delete(项)   时间=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 值(?,?,?,?)“,,元组(list1))   con.commit才能()   cur.execute才能(“select  *,得到student")   时间=lst 才能;cur.fetchall ()   for 才能;item  lst:拷贝   ,,dataTreeview.insert(“,,, 1,,文本=發ine1",,值=项目)   cur.close才能()   con.close才能()   ,   ,   def  deleteInfo ():=,,con  sqlite3.connect (dbstr)=,,cur  con.cursor ()   ,cur.execute (“select  *,得到student")=,,studentList  cur.fetchall ()   ,cur.close ()   ,con.close ()   ,打印(studentList)   ,=,,num  sid.get ()   flag =, 0   ,if  num.isnumeric(),==,错误的:   showerror才能(title=& # 39;提示& # 39;,,消息=& # 39;删除失败& # 39;)   ,for 小姐:拷贝范围(len (studentList)):   for 才能;item 拷贝studentList[我]:   ,,if  int (num),==,单品:   ,,,flag =1   ,,,con =, sqlite3.connect (dbstr)   ,,,cur =, con.cursor ()   ,,,cur.execute(得到student 获“delete  where  id =, ?“,, (int (num)))   ,,,con.commit ()   ,,,cur.close ()   ,,,con.close ()   ,才能打破   ,if  flag ==, 1:   ,,showinfo (title=& # 39;提示& # 39;,,消息=& # 39;删除成功! & # 39;)   ,其他的:   showerror才能(title=& # 39;提示& # 39;,,消息=& # 39;删除失败& # 39;)   ,=,,x  dataTreeview.get_children ()   ,for  item  x:拷贝   dataTreeview.delete才能(项)   ,=,,con  sqlite3.connect (dbstr)=,,cur  con.cursor ()   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

怎么在python中利用tkinter实现一个学生管理系统