Python实现GUI学生信息管理系统

[size=medium][list][color=blue][b]
项目环境:
软件环境:
OS:RedHat6.3
Lib:Pygtk
Language:Python
Support tool:Glade3

项目简述:
①Glade3设计用户的登录窗口,功能主窗口
②通过Gtk.Builder初始化,载入界面
③在Mysql.py文件中实现Python操作数据库。
④在stuManager.py中实现学生信息的查询,删除,修改,终端登录,图形统计等功能
⑤在Glade中定义函数触发信号,实现功能的连接。

项目测试:
①登录窗口
[img]http://dl2.iteye.com/upload/attachment/0099/2052/34f2447b-36b1-3867-8774-cdd2a1a88170.png[/img]
②主窗口
[img]http://dl2.iteye.com/upload/attachment/0099/2054/2303db32-e76f-32ba-81b3-1f993f2dee52.png[/img]
③删除信息
[img]http://dl2.iteye.com/upload/attachment/0099/2056/5d8f8358-6187-3b6e-b86e-14f60642768c.png[/img]
④修改信息
[img]http://dl2.iteye.com/upload/attachment/0099/2058/4c40327c-9236-32dc-8a54-3554c6927567.png[/img]
⑤登录终端
[img]http://dl2.iteye.com/upload/attachment/0099/2060/67cb7791-32f5-3813-8661-b8ffbab0743d.png[/img]
⑥学生成绩
[img]http://dl2.iteye.com/upload/attachment/0099/2062/a9f27248-d62d-3fc5-a378-f57b6496d834.png[/img]
⑦图形统计(没做好)
⑧查找信息
[img]http://dl2.iteye.com/upload/attachment/0099/2064/d0494f74-09ed-3246-9db5-b2d5ae575d75.png[/img]
[/list][/size][/color][/b]

部分代码:
[b]Terminal.py[/b]
#-*- coding=utf-8 -*-
#!/usr/bin/python
######################################################################
## Filename: terminal.py
##
## Copyright (C) 2014.6
## Author: TangMeiHao@760209035@qq.com
##
## Description: python + pygtk(gtk)实现学生信息管理系统
##
######################################################################

import vte
import gtk


class MyTerm():
def __init__(self):
"""初始化一个term对象"""
self.terminal=vte.Terminal()
self.terminal.connect("child-exited",lambda term: self.vte_exit())
self.terminal.fork_command()
self.terminal.set_size(10,20)

def vte_exit(self):
"""当terminal退出时,直接重新产生一个terminal,并clear初始化"""
self.terminal.fork_command()
self.terminal.feed_child("clear\n")

def vte_message(self):
pass


Stu_Sys.py
#!/usr/bin/python
#-*- coding:utf-8 -*-
######################################################################
## Filename: Stu_Sys.py
##
## Copyright (C) 2014.6
## Author: TangMeiHao@760209035@qq.com
##
## Description: python + pygtk(gtk)实现学生信息管理系统
##
######################################################################

import gtk
import gtk.glade
from terminal import *
import MySQLdb

#系统类
class system:
#定义数据库的变量
host='localhost'
user='root'
passwd='aixocm'
db='student'
port=3306
charset='utf8'

def __init__(self):
# 定义所使用的glade文件
self.glade_file = "Student.glade"
self.glade = gtk.Builder()
self.glade.add_from_file(self.glade_file)
self.glade.connect_signals(self)
self.glade.get_object("window1").set_size_request(800,500)
self.glade.get_object("window1").set_position(gtk.WIN_POS_CENTER)

#从xml文件中读取数据,并链接必要的信号
for widget in self.glade.get_objects():
if issubclass(type(widget),gtk.Buildable):name=gtk.Buildable.get_name(widget)
setattr(self,name,widget)

#创建一个Terminal的实例,并且添加到登录管理的标签页中
self.myterm=MyTerm()
self.glade.get_object("vbox2").add(self.myterm.terminal)

#登录窗口
self.dialog3.run()
self.dialog3.set_size_request(300,260)
self.dialog3.set_position(gtk.WIN_POS_CENTER)

#登录窗口登录,验证管理员用户,密码.
def on_login_click(self,widget,data=None):
try:
conn=MySQLdb.connect(host=system.host,user=system.user,passwd=system.passwd,
db=system.db,port=system.port,charset=system.charset)
cur=conn.cursor()
manager_name=cur.execute('select manager_name from manager')
name=cur.fetchmany(1)
manager_passwd=cur.execute('select manager_passwd from manager')


text16=self.entry16.get_text()
text17=self.entry17.get_text()

if text16!=name:
#验证成功,关闭登录窗口
self.dialog3.destroy()
#显示窗口
self.glade.get_object("window1").show_all()

else:
#提示框
login_waring='亲爱的管理员,你登录的用户或密码误'
self.dialog1buffer=self.textview3.get_buffer()
self.dialog1buffer.set_text(str(login_waring))
self.dialog1.set_size_request(300,260)
self.dialog1.set_position(gtk.WIN_POS_CENTER)
self.dialog1.run()

except MySQLdb.Error,e:
print "Mysql Error %d: %s" % (e.args[0], e.args[1])
...........

#ITeye这个编辑用起来不习惯啊,只能写成这样了。写详细点实在没时间.....
展开阅读全文

没有更多推荐了,返回首页