本文整理汇总了Python中PyQt4.Qt.QTableWidgetItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QTableWidgetItem.setText方法的具体用法?Python QTableWidgetItem.setText怎么用?Python QTableWidgetItem.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem.setText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: populate_tbl_helper
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setText [as 别名]
def populate_tbl_helper(hsgui, tbl, col_headers, col_editable, row_list, row2_data_tup ):
#tbl = main_skel.chip_TBL
hheader = tbl.horizontalHeader()
sort_col = hheader.sortIndicatorSection()
sort_ord = hheader.sortIndicatorOrder()
tbl.sortByColumn(0, Qt.AscendingOrder) # Basic Sorting
prevBlockSignals = tbl.blockSignals(True)
tbl.clear()
tbl.setColumnCount(len(col_headers))
tbl.setRowCount(len(row_list))
tbl.verticalHeader().hide()
tbl.setHorizontalHeaderLabels(col_headers)
tbl.setSelectionMode( QAbstractItemView.SingleSelection )
tbl.setSelectionBehavior( QAbstractItemView.SelectRows)
tbl.setSortingEnabled(False)
for row in iter(row_list):
data_tup = row2_data_tup[row]
for col, data in enumerate(data_tup):
item = QTableWidgetItem()
try:
int_data = int(data)
item.setData(Qt.DisplayRole, int_data)
except ValueError: # for strings
item.setText(str(data))
except TypeError: #for lists
item.setText(str(data))
item.setTextAlignment(Qt.AlignHCenter)
if col_editable[col]: item.setFlags(item.flags() | Qt.ItemIsEditable)
else: item.setFlags(item.flags() ^ Qt.ItemIsEditable)
tbl.setItem(row, col, item)
tbl.setSortingEnabled(True)
tbl.sortByColumn(sort_col,sort_ord) # Move back to old sorting
tbl.show()
tbl.blockSignals(prevBlockSignals)
示例2: setText
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setText [as 别名]
def setText(self, txt):
self.current_value = txt
QTableWidgetItem.setText(txt)
示例3: residuals2
# 需要导入模块: from PyQt4.Qt import QTableWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QTableWidgetItem import setText [as 别名]
def residuals2(self):
self.AObs=self.posterioriValue*self.A*(self.A.T*self.P*self.A)**-1*self.A.T
self.cofactorM=self.A*(self.A.T*self.P*self.A)**-1*self.A.T
self.AResObs=self.posterioriValue*(self.P**-1 - self.A*(self.A.T*self.P*self.A)**-1*self.A.T)
# print (self.A.T*self.P*self.A)**-1
# print self.posterioriValue
# print self.posterioriValue*(self.A.T*self.P*self.A)**-1
self.cofactorAObs.clear()
self.cofactorZ.clear()
self.residA=OrderedDict()
self.residARe=OrderedDict()
# print self.cofactorM
count = 0
for i,j in self.obs.iteritems():
for k,l in j.iteritems():
count+=1
self.obsCount=count
self.cofactorAObs.setColumnCount(count)
self.cofactorAObs.setRowCount(count)
self.cofactorZ.setColumnCount(count)
self.cofactorZ.setRowCount(count)
for i in range (count):
for j in range (count):
temp=QTableWidgetItem()
temp.setText(str(self.cofactorM[i,j]))
self.cofactorAObs.setItem(i,j,temp)
for i in range (count):
for j in range (count):
temp=QTableWidgetItem()
temp.setText(str(self.AResObs[i,j]))
self.cofactorZ.setItem(i,j,temp)
i=0
for x,sta in self.obs.iteritems():
for tn,tar in sta.iteritems():
name=x
# name=x[0:-2]
if not self.residA.has_key(x+tn):
self.residA[x+tn]=[None]
if not self.residARe.has_key(x+tn):
self.residARe[x+tn]=[None]
self.residA[x+tn][0]=sqrt(self.AObs[i,i])
self.residARe[x+tn][0]=sqrt(self.AResObs[i,i])
i+=1
# print self.residA
# print self.residARe
for x,sta in self.obs.iteritems():
for tn,target in sta.iteritems():
name=x+tn
item1 = QTreeWidgetItem(self.stdDevAtree)
item2 = QTreeWidgetItem(self.stdDevObsTree)
if tn[-1]=="D":
item1.setText(0, "Direction from"+ x +"to :"+tn[0:-2])
item2.setText(0,"Direction from"+ x+"to :"+tn[0:-2])
elif tn[-1]=="d":
item1.setText(0, "Distance from"+ x+"to :"+tn[0:-2])
item2.setText(0,"Distance from"+ x+"to :"+tn[0:-2])
item1.setText(1, str(round(float(self.residA[name][0]),3)))
item2.setText(1, str(round(float(self.residARe[name][0]),3)))