from tkinter import *
from tkinter.messagebox import *
import sqlite3
from tkinter import ttk

dbstr = “H:\mydb.db”

root = Tk()
root.geometry(‘800x600’)
root.title(‘学生管理系统’)

Label(root, text=“学号:”).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=‘学生信息管理’, 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=‘学号’)
dataTreeview.heading(‘name’, text=‘名字’)
dataTreeview.heading(‘phone’, text=‘电话’)
dataTreeview.heading(‘address’, text=‘地址’)

dataTreeview.place(rely=0.3, relwidth=0.97)

  1. List item

可否帮忙解读一下这组代码(帮忙写个注释)相关推荐

  1. java面试题25 在程序代码中写的注释太多,会使编译后的程序尺寸变大。

    java面试题25 在程序代码中写的注释太多,会使编译后的程序尺寸变大. A:正确 B:错误 蒙蔽树上蒙蔽果,蒙蔽树下你和我 拿到这道题,我觉得说的贼有道理,注释太多,尺寸变大.无疑与就和驾考 一样, ...

  2. linux代码windows能跑吗,能不能帮忙改一下下面这些代码,原来是在windows系统上运行的,要让它能在linux上终端跑。该如何处理...

    当前位置:我的异常网» C语言 » 能不能帮忙改一下下面这些代码,原来是在windows系 能不能帮忙改一下下面这些代码,原来是在windows系统上运行的,要让它能在linux上终端跑.该如何处理 ...

  3. 解读一个四路组相联cache代码

    解读一个四路组相联cache代码 在<计算机组成原理,软硬件接口>中,第五章便是cache的学习.本人初学cache,难免有疏漏之处,源代码github地址:https://github. ...

  4. php 递归算法,解读php全排列递归算法代码

    解读php全排列递归算法代码 php全排列递归算法代码,需要的朋友可以参考下,就跟随百分网小编一起去了解下吧,想了解更多相关信息请持续关注我们应届毕业生考试网! 算法原理 如果用P表示n个元素的`全排 ...

  5. 拨号键输入两组代码,轻松鉴别手机正品还是翻新,技巧让你涨知识

    拨号键输入两组代码,轻松鉴别手机正品还是翻新!技巧让你涨知识 无论我们是在实体店还是网上购买手机,大家最担心的问题之一就是害怕以新机的价格买到翻新机.那么我们在购买手机的时候,如何才能快速的识别呢?你 ...

  6. 基于pytorch搭建多特征CNN-LSTM时间序列预测代码详细解读(附完整代码)

    系列文章目录 lstm系列文章目录 1.基于pytorch搭建多特征LSTM时间序列预测代码详细解读(附完整代码) 2.基于pytorch搭建多特征CNN-LSTM时间序列预测代码详细解读(附完整代码 ...

  7. 关于游戏王中卡组代码从ygomobile转ygopro的内容

    关于游戏王中卡组代码从ygomobile转ygopro的内容 mobile和ygopro代码的区别 首先软件通过代码导入卡组其本质上mobile和ygopro是一样的,其方法是通过卡牌的卡密进行导入. ...

  8. Python正则表达式工具类文件的封装实例,提供了多个实例,并且在代码中包含中文注释

    Python正则表达式工具类文件的封装实例,提供了多个实例,并且在代码中包含中文注释 import reclass RegexUtils:'''正则表达式工具类'''def __init__(self ...

  9. 写代码犹如写文章: “大师级程序员把系统当故事来讲,而不是当做程序来写” | 如何架构设计复杂业务系统? 如何写复杂业务代码?

    写代码犹如写文章: "大师级程序员把系统当故事来讲,而不是当做程序来写" | 如何架构设计复杂业务系统? 如何写复杂业务代码? Kotlin 开发者社区 "大师级程序员把 ...

最新文章

  1. java数据类型_java 数据类型
  2. activemq ObjectMessage 不鼓励使用,有安全隐患
  3. 逆天了:Nature一篇论文57000位作者,更厉害的是,大多数作者都是游戏玩家
  4. 贝叶斯神经网络计算核裂变碎片产额
  5. Trie Tree 实现中文分词器
  6. android activity解耦,Android与设计模式:用单一职责原则为Activity解耦
  7. 前端学习(1747):前端调试值之console用处
  8. 微服务 java9模块化_Java9系列第8篇-Module模块化编程
  9. MySQL 数据库设计规范
  10. 《Algorithms》Comparable 实现插入排序
  11. Linux阻止SSH暴力***
  12. D进制A+B(20)
  13. Mybatis框架Mybatis下载步骤
  14. SSLOJ 买装备 5月11日提高B组 T1
  15. 积分基础-如何积分运动方程
  16. 请教苹果虚拟机自动配置序列号ID脚本
  17. 获取手机设备的mac地址
  18. ktv服务器几套系统,KTV场所需要哪些设备
  19. 安装两个Mysql错误 ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)”
  20. 基础条件查询 where

热门文章

  1. 7-22 超市贴花 (15 分)
  2. openstack九大模块
  3. Spark SQL 的SQL处理引擎分析
  4. VLN阅读报告5:CVDN:Vision-and-Dialog Navigation
  5. 原生CANVAS语法实现的封装折线图和饼图
  6. SegmentFault 巨献 1024 程序员游戏「红岸的呼唤」第二天任务攻略
  7. MySQL Error 1236处理
  8. spark 2.3源码分析之SortShuffleWriter
  9. C语言中printf(“%d,%d,%d“,a,++a,a++)的输出问题
  10. SQL优化之四两拨千金