我毕业设计一个模块的python代码
python真是太强大了,越用越喜欢,都担心能否够毕业设计要求的代码量了,嘻嘻。
这个模块的功能就是选取选取自己喜欢的分类然后保存选取的结果
1,主程序文件,resume
#!/usr/bin/python
import resume_imp
import resume_view
if __name__== "__main__":
resume_view.CResumeView(resume_imp.CResumeImp())
resume_view.main()
2,界面文件resume_view.py
#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk
class CResumeView:
def __init__(self,resume_imp):
self.resume_imp = resume_imp
self.init_gui()
def check_callback(self, widget,data=None):
i = data
state = widget.get_active()
res=self.resume_imp.select_do(i,state)
if(res
def button_callback(self, widget, data=None):
self.resume_imp.finish_resume()
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def init_gui(self):
#windows init
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(20)
n = self.resume_imp.get_list_len()
table = gtk.Table(n+1,4,True)
self.window.add(table)
#check button init
i = 0
while i
def main():
gtk.main()
return 0
3,实现文件resume_imp.py
#!/usr/bin/python
import resume_node
class CResumeImp:
def __init__(self):
self.init_resume()
def init_resume(self):
self.class_list = []
self.max_active_class = 5
self.list_len = self.init_raw_resume()
self.num_active_class = self.init_last_resume()
def init_raw_resume(self):
n=0
f=file('class.db')
while True:
line = f.readline()
if len(line) == 0:
break
n = n+1
self.class_list.append(self.split_entry(self.get_string(line)))
f.close()
return n
def init_last_resume(self):
f=file('resume.db')
n = 0
while True:
line = f.readline()
if len(line) == 0:
break
n = n + 1
i = self.find_entry(self.get_string(line))
# not find out
if (i
def find_entry(self, elem):
i = 0
while i
def finish_resume(self):
self.write_resume_file()
def write_resume_file(self):
if self.num_active_class == 0:
print "please choice at least one class"
return
f=file('resume.db','w')
n = len(self.class_list)
i=0
while i
def get_list_len(self):
return self.list_len
def get_show_name(self,i):
# all is not used
#id = self.class_list.id
#name = self.class_list.name
#n = self.get_class_level(id)
#result = ""
#i=0
#while i
def get_class_level(self, index):
id = self.class_list[index].id
n = 0
while True:
i = id.find('.')
if i
def select_do(self,i,state):
if state == True :
self.num_active_class = self.num_active_class + 1
if(self.num_active_class > self.max_active_class):
return -1
self.set_active(i)
else:
self.num_active_class = self.num_active_class - 1
self.set_inactive(i)
return 0
def get_class_state(self, i):
return self.class_list.state
def get_max_active_class(self):
return self.max_active_class
def set_active(self,i):
self.class_list.state = 'active'
def set_inactive(self,i):
self.class_list.state = 'inactive'
4,列表节点类文件
#/usr/bin/python
class CResumeNode:
def __init__(self,id,name,state='inactive'):
self.id=id
self.name=name
self.state=state