|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
写模块时,模块A,B调用出现问题,问题是A->B可以,B->A也可以,但是A再到B就报错了
源代码如下:from tkinter import *
from SQLserver import *
from student_surface import *
from log_in import *
def test():
def log():
a=Tk()
msg=SQLServer(server="localhost",user="MADAO",password="mayixiang",database="test05")
sql='select * from syuser'
result = msg.ExecQuery(sql)
d=0
for row in result:
if(e1.get()==row[0].rstrip()):
cipher=row[3].rstrip()
c=row[4]
d=1
break
elif(row[1].rstrip()==e1.get()):
cipher=row[3].rstrip()
c=row[4]
d=1
break
elif(row[2].rstrip()==e1.get()):
cipher=row[3].rstrip()
c=row[4]
d=1
break
if d==0:
Label(a,text='账号错误!').pack()
Button(a,text='确认',width=10,command=a.destroy).pack()
e2.delete(0,len(e2.get()))
elif d==1:
if cipher!=e2.get():
Label(a,text='密码错误!').pack()
Button(a,text='确认',width=10,command=a.destroy).pack()
e2.delete(0,len(e2.get()))
else:
Label(a,text='登入成功!').pack()
Button(a,text='确认',width=10,command=a.destroy).pack()
if c==1:
sql2='select sname from student where sno=%s'%e1.get()
result2=msg.ExecQuery(sql2)
for row2 in result2:
sname=row2[0]
surface(e1.get(),sname)
root.destroy()
a.mainloop()
root=Tk()
root.iconbitmap('.//ganda.ico')
root.title('学生管理系统')
v1=StringVar()
v2=StringVar()
Label(root,text='账号:').grid(row=0,column=0)
Label(root,text='密码:').grid(row=1,column=0)
e1=Entry(root,textvariable=v1)
e2=Entry(root,textvariable=v2,show='*')
e1.grid(row=0,column=1,padx=10,pady=5)
e2.grid(row=1,column=1,padx=10,pady=5)
Button(root,text='登入',width=10,command=log).grid(row=3,column=0,sticky=W,padx=10,pady=5)
Button(root,text='退出',width=10,command=root.destroy).grid(row=3,column=1,sticky=E,padx=10,pady=5)
root.mainloop()
if __name__=="__main__":
test()
from tkinter import *
from SQLserver import *
from log_in import *
from student_surface import *
from tkinter import ttk
def surface(sno,sname):
def log():
root1.destroy()
test()
root1=Tk()
root1.iconbitmap('.//ganda.ico')
root1.title('***********学生管理系统(学生模式)************')
group=LabelFrame(root1,text='用户',padx=5,pady=5)
group.grid(row=0,column=0)
Label(group,text='姓名:'+sname).pack(anchor=W)
Label(group,text='账号:'+sno).pack(anchor=W)
Button(group,text='注销',width=10,command=log).pack()
Button(group,text='修改密码',width=10).pack()
group2=LabelFrame(root1,text='请选择你的操作',padx=5,pady=5)
group2.grid(row=1,column=0)
Button(group2,text='查询',width=10).pack()
Button(group2,text='修改',width=10).pack()
Button(group2,text='增加',width=10).pack()
Button(group2,text='删除',width=10).pack()
group3=LabelFrame(root1,text='',padx=5,pady=5)
group3.grid(row=1,column=1)
tree_date=ttk.Treeview(group3,show="headings",height=5)
tree_date['columns']=['sno','sname','ssex','sage','sdept']
tree_date.pack()
tree_date.column('sno',width=100)
tree_date.column('sname',width=100)
tree_date.column('ssex',width=100)
tree_date.column('sage',width=100)
tree_date.column('sdept',width=100)
tree_date.heading('sno',text='学号')
tree_date.heading('sname',text='姓名')
tree_date.heading('ssex',text='性别')
tree_date.heading('sage',text='年龄')
tree_date.heading('sdept',text='系别')
msg=SQLServer(server="localhost",user="MADAO",password="mayixiang",database="test05")
sql="select * from student where sno='%s'"%sno
result = msg.ExecQuery(sql)
for row in result:
i=0
tree_date.insert('',i,values=row)
i=i+1
if __name__=="__main__":
surface('0','0' )
|
|