部分代码:
Terminal.py
#-*- coding=utf-8 -*- #!/usr/bin/python ###################################################################### ## Filename: terminal.py ## ## Copyright (C) 2014.6 ## Author: TangMeiHao@[email protected] ## ## 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@[email protected] ## ## 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这个编辑用起来不习惯啊,只能写成这样了。写详细点实在没时间.....