1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
self.proj_selected = self.tableWidget_ListProj.item(row, col).text()
try:
conn = psycopg2.connect("dbname='qgis_db' user='postgres' host='localhost' password='postgresql'")
except:
print "I am unable to connect to the database"
cur = conn.cursor()
self.dataProj= cur.execute(" SELECT pt_projname,pt_projnum, pt_x,pt_y,pt_z FROM point where pt_projname ='%s';"%(self.proj_selected))
self.dataProj = cur.fetchall()
self.dataProjstr={}
self.listdata =[]
self.intcle=-1
for cle in range(len(self.dataProj)):
self.dataProjstr.get('%s'%str(cle))
#print 'self.dataProjstr', self.dataProjstr
for i in self.dataProj :
self.intcle =self.intcle+1
self.strcle= str(self.intcle)
for j in i :
j= str(j)
self.listdata.append(j)
self.dataProjstr[self.strcle]=self.listdata
# print 'self.dataProjstr',self.dataProjstr
self.listdata=[]
print '____'
print 'dataProj str', self.dataProjstr
lignes = len(self.dataProj)
columns =5
i = 0
j = 0
self.tableWidget_DisplayProj.setRowCount(lignes)
self.tableWidget_DisplayProj.setColumnCount(columns)
self.tableWidget_DisplayProj.setHorizontalHeaderLabels(['name', 'num','x','y','z'])
self.tableWidget_DisplayProj.horizontalHeader().setResizeMode(0, QHeaderView.Stretch)
for i in range(lignes):
for j in range(columns):
item = QtGui.QTableWidgetItem(self.dataProjstr[i][j])
self.tableprojet = self.tableWidget_DisplayProj.setItem(i, j, item) |
Partager