在python中填充多个QLineEdits

时间:2019-02-17 17:18:16

标签: python-2.7

对不起,如果我的英语不好,我是巴西人,我不会说英语,我正在使用Google翻译进行交流。我在PYQT4中创建了一个表单,并尝试使用与特定记录相关的字段填充多个QLineEdits。我的代码:

   from PyQt4 import QtCore, QtGui
    import MySQLdb

def pesqAbrev(self):

    varIdPolo = self.edtNroPolo.text()

    try:
    con = MySQLdb.connect(host="127.0.0.1", user="root", passwd="", 
    charset='utf8', db="siscomedb")
    c = con.cursor()
    c.execute("select abEscola from tblescolas where codPolo=%s", (varIdPolo))
    d = c.fetchall()
    #Here it counts how many occurrences there are in the select.
    c.execute("select count(abEscola) from tblescolas where codPolo=%s", (varIdPolo))
    tot = c.fetchall()
    t = "%d" % (tot[0])
    result = int(t)

    #List with 20 QLineEdt. I want to fill only the number that returns in the second select.
    varList = [self.edtAbrev_1,self.edtAbrev_2,self.edtAbrev_3,...20]

    #Here it fills all 20 QLineEdits and only comma the first occurrence of select.
    row = [item[0] for item in dados]
            for edt in varList:
                edt.setText(unicode(item[0]))

在此先感谢可以帮助我的人。

0 个答案:

没有答案