Python實(shí)現(xiàn)GUI學(xué)生信息管理系統(tǒng)
本文實(shí)例為大家分享了Python實(shí)現(xiàn)GUI學(xué)生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
項(xiàng)目環(huán)境:
軟件環(huán)境:
OS:RedHat6.3
Lib:Pygtk
Language:Python
Support tool:Glade3
項(xiàng)目簡述:
①Glade3設(shè)計(jì)用戶的登錄窗口,功能主窗口
②通過Gtk.Builder初始化,載入界面
③在Mysql.py文件中實(shí)現(xiàn)Python操作數(shù)據(jù)庫。
④在stuManager.py中實(shí)現(xiàn)學(xué)生信息的查詢,刪除,修改,終端登錄,圖形統(tǒng)計(jì)等功能
⑤在Glade中定義函數(shù)觸發(fā)信號,實(shí)現(xiàn)功能的連接。
項(xiàng)目測試:
①登錄窗口
②主窗口
③刪除信息
④修改信息
⑤登錄終端
⑥學(xué)生成績
⑦圖形統(tǒng)計(jì)(沒做好)
⑧查找信息
部分代碼:
Terminal.py
#-*- coding=utf-8 -*- #!/usr/bin/python ##################################################################### ## Filename: terminal.py ## ## Copyright (C) 2014.6 ## Author: TangMeiHao@760209035@qq.com ## ## Description: python + pygtk(gtk)實(shí)現(xiàn)學(xué)生信息管理系統(tǒng) ## ###################################################################### 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): """當(dāng)terminal退出時(shí),直接重新產(chǎn)生一個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)實(shí)現(xiàn)學(xué)生信息管理系統(tǒng) ## ###################################################################### import gtk import gtk.glade from terminal import * import MySQLdb #系統(tǒng)類 class system: #定義數(shù)據(jù)庫的變量 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文件中讀取數(shù)據(jù),并鏈接必要的信號 for widget in self.glade.get_objects(): if issubclass(type(widget),gtk.Buildable):name=gtk.Buildable.get_name(widget) setattr(self,name,widget) #創(chuàng)建一個Terminal的實(shí)例,并且添加到登錄管理的標(biāo)簽頁中 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) #登錄窗口登錄,驗(yàn)證管理員用戶,密碼. 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: #驗(yàn)證成功,關(guān)閉登錄窗口 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]) ...........
更多學(xué)習(xí)資料請關(guān)注專題《管理系統(tǒng)開發(fā)》。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- python學(xué)生信息管理系統(tǒng)(完整版)
- python實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- python實(shí)現(xiàn)簡易學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼
- python實(shí)現(xiàn)簡單學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)(初級版)
- python學(xué)生信息管理系統(tǒng)實(shí)現(xiàn)代碼
- python代碼實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- Python結(jié)合MySQL數(shù)據(jù)庫編寫簡單信息管理系統(tǒng)完整實(shí)例
相關(guān)文章
tensorflow之tf.record實(shí)現(xiàn)存浮點(diǎn)數(shù)數(shù)組
今天小編就為大家分享一篇tensorflow之tf.record實(shí)現(xiàn)存浮點(diǎn)數(shù)數(shù)組,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02解決List.append()?在?Python?中不起作用的問題
在?Python?中,我們通常使用?List.append()?方法向列表末尾添加元素,然而,在某些情況下,你可能會遇到?List.append()?方法不起作用的問題,本文將詳細(xì)討論這個問題并提供解決方法,需要的朋友可以參考下2023-06-06詳解Python+OpenCV實(shí)現(xiàn)圖像二值化
圖像二值化就是將圖像上的像素點(diǎn)的灰度值設(shè)置為0或255,也就是將整個圖像呈現(xiàn)出明顯的黑白效果的過程。本文將通過Python+OpenCV實(shí)現(xiàn)這一過程,感興趣的可以學(xué)習(xí)一下2022-05-05Python異常處理與反射相關(guān)問題總結(jié)
今天給大家?guī)淼氖顷P(guān)于Python的相關(guān)知識,文章圍繞著Python異常處理與反射展開,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下2021-06-06

Python數(shù)據(jù)解析之BeautifulSoup4的用法詳解