Hi i'm trying to create a GUI in PyQt4 in which the user can tag faces extracted from a video/images. I have a folder in which I have stored all the faces(images).
pic4.setPixmap(QtGui.QPixmap(os.getcwd() + "/faces/Testimg3.png"))
pic5 = QtGui.QLabel(window)
pic5.setGeometry(500,200,70,70)
pic5.setPixmap(QtGui.QPixmap(os.getcwd() + "/faces/Testimg4.png"))
pic6 = QtGui.QLabel(window)
pic6.setGeometry(500,340,70,70)
pic6.setPixmap(QtGui.QPixmap(os.getcwd() + "/faces/Testimg5.png"))
te1 = QtGui.QTextEdit(window)
te1.setGeometry(160,70,140,30)
te2 = QtGui.QTextEdit(window)
te2.setGeometry(160,210,140,30)
te3 = QtGui.QTextEdit(window)
te3.setGeometry(160,350,140,30)
currently I have something like this. Pix-maps followed by text edits to get the tags. This I have hard coded to display 6 images from my folder along with the text edits. Can anyone guide me on how to make this dynamic, i.e. the display should show all the images in the folder along with the text edits. Note: No. of images in the folder may change.
A pretty easy way to do this would be with a QTableWidget or QTreeWidget.
Get a list of the images in your folder and then add an item to the Table or Tree for each one.
tree = QTreeWidget()
tree.setHeaderLabels(['Path', 'Image'])
paths = ['/path/one', '/path/two']
for path in paths:
pixmap = QPixmap(path)
label = QLabel()
label.setPixmap(pixmap)
item = QTreeWidgetItem()
item.setText(0, path)
tree.addTopLevelItem(item)
tree.setItemWidget(item, 1, label)