班级信息收集
2021/12/12 6:17:24
本文主要是介绍班级信息收集,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import wx
import shuru
class MyFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,title="班级信息收集程序",size=(600,400))
pl = wx.Panel(self)
self.title = wx.StaticText(pl,label="请输入要收集的班级、姓名、学号",pos=(2000,20))
self.label_id = wx.StaticText(pl,label="学号:",pos=(140,50))
self.text_id = wx.TextCtrl(pl,pos=(190,50),size=(235,25),style=wx.TE_LEFT)
self.label_bj = wx.StaticText(pl,label="班级:",pos=(140,90))
self.text_bj = wx.TextCtrl(pl, pos=(190, 90), size=(235, 25), style=wx.TE_LEFT)
self.label_xm = wx.StaticText(pl, label="姓名:", pos=(140, 130))
self.text_xm = wx.TextCtrl(pl, pos=(190, 130), size=(235, 25), style=wx.TE_LEFT)
self.bt_bc = wx.Button(pl,label="保存",pos=(190,170))
self.bt_bc.Bind(wx.EVT_BUTTON,self.Baochun)
self.bt_qx = wx.Button(pl,label="取消",pos=(290,170))
self.bt_qx.Bind(wx.EVT_BUTTON, self.Cancel)
def Baochun(self,event):
id = self.text_id.GetValue()
bj = self.text_bj.GetValue()
xm = self.text_xm.GetValue()
if id =='' or bj == '' or xm == '':
message = '输入为空!'
else:
shuru.baochuninformation(id,bj,xm)
message = '保存成功!'
wx.MessageBox(message)
def Cancel(self,event):
self.text_xm.SetValue('')
self.text_bj.SetValue('')
self.text_id.SetValue('')
wx.MessageBox('取消成功!')
if __name__ == '__main__':
app = wx.App()
frame = MyFrame(parent=None,id=-1)
frame.Show()
app.MainLoop()
import wx
import shuru
class MyFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,title="班级信息查询程序",size=(400,300))
pl = wx.Panel(self)
self.title = wx.StaticText(pl, label="班级信息查询程序", pos=(140, 20))
self.label_id = wx.StaticText(pl, label="请输入要查询同学的学号:", pos=(50, 50))
self.text_id = wx.TextCtrl(pl, pos=(50, 70), size=(235, 25), style=wx.TE_LEFT)
self.bt_bc = wx.Button(pl, label="查询", pos=(100, 140))
self.bt_bc.Bind(wx.EVT_BUTTON, self.Chaxun)
self.bt_qx = wx.Button(pl, label="取消", pos=(200, 140))
self.bt_qx.Bind(wx.EVT_BUTTON, self.Cancel)
def Chaxun(self,event):
id = self.text_id.GetValue()
if id =='':
message = '输入为空!'
else:
(a,b,c) = shuru.chaxuninformation(id)
message = """
该同学姓名为: {:s}
班级为:{:s}
""".format(c,b)
wx.MessageBox(message)
pass
def Cancel(self, event):
self.text_id.SetValue('')
wx.MessageBox('取消成功!')
if __name__ == '__main__':
app = wx.App()
frame = MyFrame(parent=None,id=-1)
frame.Show()
app.MainLoop()
import sqlite3
def baochuninformation(a,b,c):
"""
:param a: 学生的学号 (id)
:param b: 班级 (bj)
:param c: 姓名 (xm)
:return:
"""
conn = sqlite3.connect('mrsoft.db')
cursor = conn.cursor()
e = (a,b,c)
cursor.execute('insert into classinformation (id,bj,xm) values (?,?,?)', e)
cursor.close()
conn.commit()
conn.close()
def chaxuninformation(a):
'''
:param a: 学号
:return: 返回元组
'''
b=()
conn = sqlite3.connect('mrsoft.db')
cursor = conn.cursor()
a=int(a)
cursor.execute('select * from classinformation where id = ?', (a,))
b= cursor.fetchone()
cursor.close()
conn.close()
return b
if __name__=='__main__':
conn = sqlite3.connect('mrsoft.db')
cursor = conn.cursor()
#cursor.execute('create table classinformation (id int(15) primary key, bj varchar (20), xm varchar (4))')
a = ('23', '信计1班', '蔡浩鑫')
#cursor.execute('insert into classinformation (id,bj,xm) values (?,?,?)', a)
#cursor.execute('delete from classinformation where id = ?', (20,))
cursor.execute('select * from classinformation where id = ?', (20,))
b = cursor.fetchone()
print(b)
cursor.close()
conn.commit()
conn.close()
这篇关于班级信息收集的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-102025 蛇年,J 人直播带货内容审核团队必备的办公软件有哪 6 款?
- 2025-01-10高效运营背后的支柱:文档管理优化指南
- 2025-01-10年末压力山大?试试优化你的文档管理
- 2025-01-10跨部门协作中的进度追踪重要性解析
- 2025-01-10总结 JavaScript 中的变体函数调用方式
- 2025-01-10HR团队如何通过数据驱动提升管理效率?6个策略
- 2025-01-10WBS实战指南:如何一步步构建高效项目管理框架?
- 2025-01-10实现精准执行:团队协作新方法
- 2025-01-10如何使用工具提升活动策划团队的工作效率?几个必备工具推荐
- 2025-01-10WiX 标签使用介绍:打造专业安装程序的利器