def __init__(self): self.gladeFile=sys.path[0]+"/ui.glade" self.gladeMain = gtk.Builder() self.gladeMain.add_objects_from_file(self.gladeFile,["mainDlg"]) self.gladeMain.connect_signals(self) #添加主界面 self.mainDlg = self.gladeMain.get_object("mainDlg") #self.mainDlg.set_default_size(320,240) self.mainDlg.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.mainDlg.connect('destroy',lambda q :gtk.main_quit()) self.build_list() self.mainDlg.show() try: gctrl.globalControl.read_from_file() str_name=gctrl.globalControl.uname str_email=gctrl.globalControl.email str_pwd=gctrl.globalControl.pword class MrLogin(threading.Thread): def __init__(self,i_status): super(MrLogin, self).__init__() self.status=i_status def run(self): self.status['running']=True try: self.status['return_value']=mrc.login(str_name,str_email,str_pwd) except Exception,e: print e self.status['return_value']=444 self.status['running']=False try: status={} _mrlogin=MrLogin(status) _mrlogin.start() _procdlg=procDlg(status) _procdlg.main() print status return_value=status['return_value'] try: return_value=int(return_value) self.gladeMain.get_object("statusbar").push(0, '登录失败:'+gctrl.codeToString(return_value)) except Exception,e: self.gladeMain.get_object("statusbar").push(0, gctrl.globalControl.uname+' 登录成功') self.refreshTreeView() except Exception,e: pass
def refreshTreeView(self): try: self.mainList.clear() idict={} str_name=gctrl.globalControl.uname str_email=gctrl.globalControl.email str_pwd=gctrl.globalControl.pword res=mrc.getlist(str_name,str_email,str_pwd,idict) print res if(res!=200 or 'return_value' not in idict): self.gladeMain.get_object("statusbar").push(0, '刷新列表失败:'+gctrl.codeToString(res)) else: itemlist=idict['return_value'] for lines in itemlist.split('\n'): print lines lines=lines.split('___SPLIT___') self.mainList.append([lines[0],int(lines[1])]) except Exception,e: print e self.gladeMain.get_object("statusbar").push(0, '刷新列表失败:请先登录或检查网络连接')
def on_btn_OK_clicked(self,*args): str_name=self.gladeMain.get_object('reg_entry_name').get_text() str_email=self.gladeMain.get_object('reg_entry_email').get_text() str_pwd1=self.gladeMain.get_object('reg_entry_pword1').get_text() str_pwd2=self.gladeMain.get_object('reg_entry_pword2').get_text() if(str_name=='' or str_email=='' or str_pwd1!=str_pwd2): gctrl.MessageBox('提示信息','输入有误,请核实','ERROR') else: class MrReg(threading.Thread): def __init__(self,i_status): super(MrReg, self).__init__() self.status=i_status def run(self): self.status['running']=True try: self.status['return_value']=mrc.register(str_name,str_email,str_pwd1) except: pass self.status['running']=False try: status={} _mrreg=MrReg(status) _mrreg.start() _procdlg=procDlg(status) _procdlg.main() return_value=status['return_value'] except Exception,e: print e gctrl.MessageBox('提示信息','网络连接错误!','ERROR') return try: return_value=int(return_value) if(return_value==200): gctrl.MessageBox('提示信息','注册成功!','INFO') gtk.Widget.destroy(self.mainDlg) else: gctrl.MessageBox('提示信息',gctrl.codeToString(return_value),'ERROR') except Exception,e: print e gctrl.MessageBox('提示信息','未能解析的错误','INFO')
def on_loginDlg_ok_clicked(self,*args): str_name=self.gladeMain.get_object('entry_name').get_text() str_email=self.gladeMain.get_object('entry_email').get_text() str_pwd=self.gladeMain.get_object('entry_pword').get_text() if(str_name=='' or str_email=='' or str_pwd==''): gctrl.MessageBox('提示信息','输入有误,请核实','ERROR') else: class MrLogin(threading.Thread): def __init__(self,i_status): super(MrLogin, self).__init__() self.status=i_status def run(self): self.status['running']=True try: self.status['return_value']=mrc.login(str_name,str_email,str_pwd) except: pass self.status['running']=False try: status={} _mrlogin=MrLogin(status) _mrlogin.start() _procdlg=procDlg(status) _procdlg.main() return_value=status['return_value'] except: gctrl.MessageBox('提示信息','网络连接错误!','ERROR') return try: return_value=int(return_value) gctrl.MessageBox('提示信息',gctrl.codeToString(return_value),'ERROR') except: auto_login=self.gladeMain.get_object("chkbtn_autoLogin").get_active() if(auto_login): gctrl.globalControl.write_to_file() gtk.Widget.destroy(self.mainDlg) self.res_list.append(True)
except Exception,e: print 'MrUpload '+str(e) self.status['return_value']=205 finally: self.status['running']=False status={} _mrupload=MrUpload(status) _mrupload.start() _procdlg=procDlg(status) _procdlg.main() if('return_value' in status): return_value=status['return_value'] if(return_value==200): self.gladeMain.get_object("statusbar").push(0, path.split('/')[-1]+' 上传成功') else: self.gladeMain.get_object("statusbar").push(0, '上传文件失败:'+gctrl.codeToString(return_value)) else: self.gladeMain.get_object("statusbar").push(0, '上传失败:请先登录或检查网络连接') elif response == gtk.RESPONSE_CANCEL: fcDlg.destroy() self.refreshTreeView() def on_treeview_cursor_changed(self,*args): try: self.selectedRow = self.mainTreeView.get_cursor()[0][0] except: self.selectedRow = -1 def on_toolbtn_del_clicked(self,*args): #print self.mainList.get_value(_iter,0) try: _iter=self.mainList.get_iter(self.selectedRow)