def setItemListWidget(self, iconPath, iconName, wgName, adPath=''): icon = QtGui.QIcon() pixmap = QtGui.QPixmap(iconPath) icon.addPixmap(pixmap, QtGui.QIcon.Normal, QtGui.QIcon.Off) items = QtGui.QListWidgetItem(wgName) items.setIcon(icon) items.setText(iconName) if adPath and not os.path.exists(adPath): items.setBackground(QtGui.QColor(255, 0, 0))
def fillInTableIcon(self, row, column, text, iconPath, widget, color = [1, 1, 1]) : icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(iconPath), QtGui.QIcon.Normal, QtGui.QIcon.Off) item = QtGui.QTableWidgetItem() item.setText(str(text)) item.setIcon(icon) item.setBackgroundColor(QtGui.QColor(color[0], color[1], color[2])) cmd = 'self.ui.%s.setItem(row, column, item)' % widget eval(cmd)
def addListWidgetItem(self, listWidget, text, iconPath, color) : icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(iconPath),QtGui.QIcon.Normal,QtGui.QIcon.Off) cmd = 'QtGui.QListWidgetItem(self.ui.%s)' % listWidget item = eval(cmd) item.setIcon(icon) item.setText(text) item.setBackground(QtGui.QColor(color[0], color[1], color[2])) size = 90 cmd2 = 'self.ui.%s.setIconSize(QtCore.QSize(%s, %s))' % (listWidget, size, size) eval(cmd2)
def addEntityListWidget(self, listWidget, text1, text2, bgColor, iconPath) : myCustomWidget = customWidget.customQWidgetItem() myCustomWidget.setText1(text1) myCustomWidget.setText2(text2) myCustomWidget.setTextColor1([200, 200, 200]) myCustomWidget.setTextColor2([120, 120, 120]) item = eval('QtGui.QListWidgetItem(self.ui.%s)' % listWidget) item.setSizeHint(myCustomWidget.sizeHint()) item.setBackground(QtGui.QColor(bgColor[0], bgColor[1], bgColor[2])) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(iconPath),QtGui.QIcon.Normal,QtGui.QIcon.Off) item.setIcon(icon) eval('self.ui.%s.addItem(item)' % listWidget) eval('self.ui.%s.setItemWidget(item, myCustomWidget)' % listWidget)
def addComboBoxItem(self, i, text, iconPath) : self.ui.status_comboBox.addItem(text) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(iconPath), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ui.status_comboBox.setItemIcon(i, icon)