python - how to obtain string values of a list -
python - how to obtain string values of a list -
i'm beginner in pyqt , made formular. self.tname1, self.tlname1, self.tcel, self.tcel1,self.tcc1, self.temail, self.ttel qlineedit , set these variables in list. then, made loop in order evaluate each qlineedit value , fill them if empty 'null'. loop works i'm trying print values within list. example: ['null','null','3176797100','null','null','1098685161','mm@gmail.com', 'null'] doesn't work.
self.tname1 = qtgui.qlineedit(self) self.tname1.move(85,176) self.tname1.resize(199,30) self.tlname1 = qtgui.qlineedit(self) self.tlname1.move(95,210) self.tlname1.resize(190,30) def eval(self): var=[self.tname1, self.tlname1, self.tcel, self.tcel1,self.tcc1, self.temail, self.ttel] i=0 in range(len(var)): if var[i]=="": var[i]='null' else: pass print var print self.tname1.text() print self.tname1
if print self.variable.text() nil appears. on other hand, if print self.name1 appears posotion of qlineedit: <pyqt4.qtgui.qlineedit object @ 0x7fb1046cc180>
. appreciate help!! :p
well, question not clear, line:
var=[self.tname1, self.tlname1, self.tcel, self.tcel1,self.tcc1, self.temail, self.ttel]
creates new list contains variables, , whatever alter in list, not impact values of original variables, have look:
>>> = "hello" >>> b = "world" >>> var = [a, b] >>> var ["hello", "world"] >>> var[0] = "hi" >>> hello >>> var ["hi", "world"] >>> = "whatsup" >>> var ["hi", "world"]
so if want alter original variable( in case self.tname1.text, self.tcel.text) have alter each 1 of them individually, think done with:
>>> if self.tname1.text()=="": .... self.tname1.settext("null")
and on.
i hope reply you.
edit: after comment, obtain text attribute object can seek this:
print [x.text() x in var]
python pyqt qlineedit
Comments
Post a Comment