PyQt:Combobox没有显示

时间:2016-10-11 20:43:18

标签: python python-2.7 pyqt4 qcombobox qcheckbox

我尝试使用PyQt编写python脚本。我想从sqlite db中获取一些信息,然后在滚动区域内的复选框中显示它,以防列表变得太大:

def addCheckBox(self):
    cbCurrentTxt = str(self.comboBox.currentText())
    db = sqlite3.connect("data.db")
    x = 10
    for checkBoxPop in db.execute("SELECT * FROM users WHERE week='"+cbCurrentTxt+"';"):
        print checkBoxPop
        self.checkBox = QtGui.QCheckBox(self.scrollArea)
        self.checkBox.setGeometry(QtCore.QRect(10, x, 95, 25))
        self.checkBox.setText(_translate("MainwiNdow", str(checkBoxPop[1]), None))

        self.checkBox_2 = QtGui.QCheckBox(self.scrollArea)        
        self.checkBox_2.setGeometry(QtCore.QRect(120, x, 95, 25))
        self.checkBox_2.setText(_translate("MainwiNdow", str(checkBoxPop[3]), None))         
        for i in checkBoxPop[1]:
            print "coord" + str(x)
            x += 4

我使用组合框来获得一周:

def populateWeekCB(self):
    db = sqlite3.connect("data.db")
    cursor = db.cursor()
    self.comboBox.clear()
    for cbItemsDB in db.execute("select * from week"):
        print cbItemsDB
        self.comboBox.addItem(cbItemsDB[0])
    self.comboBox.activated[str].connect(self.addCheckBox)

选择一周后,我想显示复选框,但它们没有显示。

0 个答案:

没有答案