def CreatTable_CGCS(self,tablepath,type=0): """修改参数界面的表格绘制函数""" self.tableinfor_2 = FiveFileParser.readTable(tablepath) self.UI.tableWidget.clear() if self.tableinfor_2 is not None: self.tableinfor_2=Dict(self.tableinfor_2[self.tableinfor_2.keys()[0]]['cellContent']) self.tableinfor_2Save = copy.deepcopy(self.tableinfor_2)#获取存储数据 row,col=CalculateRowCol(self.tableinfor_2.keys()) self.currentfilepath.setdefault('row',row) self.currentfilepath.setdefault('col',col) self.SetTableRowCol_CGCS(row,col)#更新表格的个数 for i,data in enumerate(self.tableinfor_2.iteritems()): itemkey = QtWidgets.QTableWidgetItem() itemvalue=QtWidgets.QTableWidgetItem() if type==0: itemkey.setBackground(QtGui.QBrush(QtGui.QColor(200, 184, 7))) else: itemkey.setBackground(QtGui.QBrush(QtGui.QColor(188, 229, 255))) itemkey.setText(data[0]) itemvalue.setText(data[1]) itemkey.setFlags(QtCore.Qt.ItemIsEnabled) self.UI.tableWidget.setItem(i % self.currentfilepath['row'], (i // self.currentfilepath['row']) * 2, itemkey) self.UI.tableWidget.setItem(i%self.currentfilepath['row'],(i // self.currentfilepath['row']) * 2+1,itemvalue) else: self.tableinfor_2=None
def SlotDealWithQuerryData(self,where,data): """处理来自数据库查询的数据""" if where.startswith('cs'):#处理数据发出的用于绘图的数据 try: if data!=(): data = np.array(data)[:, 0] self.ZaiRuWindow.addLines((0,),(tuple(data),),('r',)) else: self.SlotMessageBox('错误!','此表无数据!') except: pass print '来自数据库的数据' elif where.startswith('ex*'):#处理数据发出的用于导出的数据 where=where.lstrip('ex*')#去除信息前缀 oldfilepath,newfiledir=where.split('*')#来自哪个数据表,数据应该存储的位置 infor = FiveFileParser.readTable(oldfilepath) infor=infor[infor.keys()[0]]['cellContent']#获取文件中的表 temppath=os.path.split(oldfilepath)[1]#获取文件名 temppath=temppath.replace('.d','.txt')#替换文件后缀名 with open(os.path.join(newfiledir,temppath),'w') as f:#创建数据文件 pass #首先存储参数表 FiveFileParser.insertTable(infor,'所使用参数',os.path.join(newfiledir,temppath),-1) #创建线程来存数数据 fd=threading.Thread(target=saveData2File,args=(os.path.join(newfiledir,temppath),data)) fd.start() self.SlotMessageBox('提示','数据导出成功!')
def getRegions(self): path = self.logintablePath regioninfor = FiveFileParser.readTable(path) if regioninfor != None: for _, item in regioninfor.iteritems(): regions = item['cellContent'] for keys, values in regions.iteritems(): self.regions.append([keys, values]) break self.ui.LOGIN_region.currentIndexChanged.connect( self.activeComboxGen) self.activeComboxRegin()
def CreateTable_TJCS(self,table): """创建参数表""" temp= FiveFileParser.readTable(table) self.UI.table_tianjiacanshu.clear() if temp is not None: temp=Dict(temp[temp.keys()[0]]['cellContent']) self.tableinfor = Dict() row, col = CalculateRowCol(temp.keys()) self.parefile['row'], self.parefile['col']=row,col self.SetTableRowCol_TJCS(row,col) self.tableinfor.setdefault('存储为','MUBAN') for data in temp.iteritems(): self.tableinfor.setdefault(data[0],data[1]) for i,data in enumerate(self.tableinfor.iteritems()): item = QtWidgets.QTableWidgetItem() item.setText(data[0]) item.setFlags(QtCore.Qt.ItemIsEnabled) self.UI.table_tianjiacanshu.setItem(i % self.parefile['row'], (i // self.parefile['row']) * 2, item) else: self.tableinfor=Dict() self.tableinfor.setdefault('存储为', 'MUBAN')