def Log(self, log_text, log_type=LogType.Normal): prefix = "" # Since the expectation is that the user provides ints that are converted to the respective log type, this # can lead to an invalid log type. If this ever happens, just default to the normal style try: converted_type = LogType(log_type) color = self.log_colors[converted_type] prefix = self.log_prefixes[converted_type] except Exception as exc: print( f"Failed to determine log color type - Resorting to normal colors: {exc}" ) color = self.log_colors[LogType.Normal] prefix = self.log_colors[LogType.Normal] # Convert the string list structure we use to a int list using some sketchy conversions color = list(map(int, color.split(", "))) new_entry = QListWidgetItem(datetime.now().strftime("%H:%M:%S") + ": " + prefix + log_text) new_entry.setForeground(QColor(color[0], color[1], color[2])) new_entry.setFont(self.log_font) self.log_ui.log_list.addItem(new_entry) # Since Qt only refreshes widgets when it regains control of the main thread, force the update here # as long updates are high priority in terms of visibility self.log_ui.log_list.repaint() self.log_ui.repaint()
def familyChanged(self,currentText): if not currentText == "Aircraft Family" and not currentText == "": self.familyMenu.setCurrentText("Aircraft Family") index = self.familyMenu.findText(currentText) if currentText.endswith(self.checkMark): newText = currentText[0:-2] self.familyMenu.setItemText(index,newText) subTypes = self.acSchema[0][newText] fullNames = [] for subType in subTypes: fullNames.append(self.acSchema[1][subType]) self.current_subTypeVector[subType] = False for index in range(self.subTypeList.count()-1,-1,-1): if self.subTypeList.item(index).text() in fullNames: self.subTypeList.takeItem(index) else: self.familyMenu.setItemText(index,currentText+"\t"+self.checkMark) subTypes = self.acSchema[0][currentText] for subType in subTypes: item = QListWidgetItem(self.acSchema[1][subType]) item.setForeground(QtGui.QColor('green')) self.subTypeList.addItem(item) self.current_subTypeVector[subType] = True ############SORT SUBTYPE LIST!!!!!!!!!!!################# self.sendAircraft()
def _display_annotation_in_qlistwidget(self, annt): '''Add a line to the annotation list It does not erase previous lines. Parameters ---------- annt : list of (dict, str) dict : contains the key 'annotationtype' and determines the annotation color also contains all other annotation data needed for right click menu/double click str : The string to add to the list ''' # clear the previous annotation box self.app_window.w_dblist.clear() for cannt in annt: details = cannt[0] newitem = QListWidgetItem(cannt[1]) newitem.setData(QtCore.Qt.UserRole, details) if details['annotationtype'] == 'diffexp': ccolor = QtGui.QColor(0, 0, 200) elif details['annotationtype'] == 'contamination': ccolor = QtGui.QColor(200, 0, 0) elif details['annotationtype'] == 'common': ccolor = QtGui.QColor(0, 200, 0) elif details['annotationtype'] == 'highfreq': ccolor = QtGui.QColor(0, 200, 0) else: ccolor = QtGui.QColor(0, 0, 0) newitem.setForeground(ccolor) self.app_window.w_dblist.addItem(newitem)
def processDone(self): global transcripts global s2t global fs global data wavlength = len(data) / float(fs) ydata = [i[0] for i in data] xdata = range(len(ydata)) graphLineColor = (200, 200, 234) graphCriticalLineColor = (255, 128, 128) timeCount = 0 for i in s2t: dataPointLeft = int((timeCount / wavlength) * len(ydata)) dataPointRight = int((i[1] / wavlength) * len(ydata)) color = graphCriticalLineColor if profanity.contains_profanity( i[0]) else graphLineColor self.graphWidget.plot(xdata[dataPointLeft:dataPointRight], ydata[dataPointLeft:dataPointRight], pen=pg.mkPen(color=color)) timeCount = i[1] self.transcriptBox.clear() criticalBrush = QBrush(QColor(41, 41, 61)) for tr in transcripts: item = QListWidgetItem(str(profanity.censor(tr)).capitalize()) if profanity.contains_profanity(tr): item.setForeground(criticalBrush) item.setBackground(QColor(255, 128, 128)) self.transcriptBox.addItem(item) self.recordButtonOn = True
def familyChanged(self, currentText): if not currentText == "Aircraft Family" and not currentText == "": self.familyMenu.setCurrentText("Aircraft Family") index = self.familyMenu.findText(currentText) if currentText.endswith(self.checkMark): newText = currentText[0:-2] self.familyMenu.setItemText(index, newText) subTypes = self.acSchema[0][newText] fullNames = [] for subType in subTypes: fullNames.append(self.acSchema[1][subType]) self.current_subTypeVector[subType] = False for index in range(self.subTypeList.count() - 1, -1, -1): if self.subTypeList.item(index).text() in fullNames: self.subTypeList.takeItem(index) else: self.familyMenu.setItemText( index, currentText + "\t" + self.checkMark) subTypes = self.acSchema[0][currentText] for subType in subTypes: item = QListWidgetItem(self.acSchema[1][subType]) item.setForeground(QtGui.QColor('green')) self.subTypeList.addItem(item) self.current_subTypeVector[subType] = True ############SORT SUBTYPE LIST!!!!!!!!!!!################# self.sendAircraft()
def refresh_filename_list(self, color_dict): self.file_list_widget.clear() for filename in self.data: item = QListWidgetItem() item.setText(filename) brush = QBrush(color_dict[filename]) item.setForeground(brush) self.file_list_widget.addItem(item)
def addCategory(self, title): item = QListWidgetItem(title) item.setBackground(QBrush(QColor(S.highlightLight))) item.setForeground(QBrush(QColor(S.highlightedTextDark))) item.setFlags(Qt.ItemIsEnabled) f = item.font() f.setBold(True) item.setFont(f) self.list.addItem(item)
def addCategory(self, title): item = QListWidgetItem(title) item.setBackground(QBrush(lightBlue())) item.setForeground(QBrush(Qt.darkBlue)) item.setFlags(Qt.ItemIsEnabled) f = item.font() f.setBold(True) item.setFont(f) self.list.addItem(item)
def _decorateLoggerItem(self, item: QListWidgetItem, logger: logging.Logger) -> None: """Decorate an entry in the logger list reflecting the properties of the logger. """ item.setForeground(self._colorForLogLevel(logger.getEffectiveLevel())) font = item.font() font.setBold(bool(logger.level)) item.setFont(font) item.setBackground(Qt.lightGray if logger.disabled else Qt.white)
def set_prohibited_item(prohibited_item: QtWidgets.QListWidgetItem, item_type: str) -> None: # add list item that user does not have permission to upload prohibited_item.setText(f'{each} ⚠️') prohibited_item.setForeground(QColor(255, 0, 0)) prohibited_item.setToolTip( f'You do not have permission to upload this {item_type}') prohibited_item.setFlags(list_item.flags() & ~QtCore.Qt.ItemIsUserCheckable) prohibited_item.setCheckState(QtCore.Qt.Unchecked)
def default_clicked(self): """ Set everything to the default values. """ # Checkboxes self.ui.topmost_CheckBox.setCheckState(Qt.Checked) self.ui.skip_background_CheckBox.setCheckState(Qt.Checked) self.ui.update_canvas_CheckBox.setCheckState(Qt.Checked) self.ui.update_canvas_end_CheckBox.setCheckState(Qt.Checked) self.ui.draw_lines_CheckBox.setCheckState(Qt.Checked) self.ui.double_click_CheckBox.setCheckState(Qt.Unchecked) self.ui.show_info_CheckBox.setCheckState(Qt.Checked) self.ui.show_preview_CheckBox.setCheckState(Qt.Unchecked) self.ui.hide_preview_CheckBox.setCheckState(Qt.Unchecked) self.ui.paint_background_CheckBox.setCheckState(Qt.Unchecked) self.ui.opacities_CheckBox.setCheckState(Qt.Checked) self.ui.hidden_colors_CheckBox.setCheckState(Qt.Unchecked) # Comboboxes self.ui.quality_ComboBox.setCurrentIndex(default_settings["quality"]) self.ui.brush_type_ComboBox.setCurrentIndex(default_settings["brush_type"]) # Lineedits self.ui.ctrl_x_LineEdit.setText(str(default_settings["ctrl_x"])) self.ui.ctrl_y_LineEdit.setText(str(default_settings["ctrl_y"])) self.ui.ctrl_w_LineEdit.setText(str(default_settings["ctrl_w"])) self.ui.ctrl_h_LineEdit.setText(str(default_settings["ctrl_h"])) self.ui.pause_key_LineEdit.setText(default_settings["pause_key"]) self.ui.skip_key_LineEdit.setText(default_settings["skip_key"]) self.ui.abort_key_LineEdit.setText(default_settings["abort_key"]) rgb = hex_to_rgb(default_settings["background_color"]) if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186: self.qpalette.setColor(QPalette.Text, QColor(0, 0, 0)) else: self.qpalette.setColor(QPalette.Text, QColor(255, 255, 255)) self.qpalette.setColor(QPalette.Base, QColor(rgb[0], rgb[1], rgb[2])) self.ui.background_LineEdit.setPalette(self.qpalette) self.ui.background_LineEdit.setText(default_settings["background_color"]) self.ui.click_delay_LineEdit.setText(str(default_settings["click_delay"])) self.ui.ctrl_delay_LineEdit.setText(str(default_settings["ctrl_area_delay"])) self.ui.line_delay_LineEdit.setText(str(default_settings["line_delay"])) self.ui.min_line_width_LineEdit.setText(str(default_settings["minimum_line_width"])) # Set skip color list to default self.ui.skip_colors_ListWidget.clear() if default_settings["skip_colors"] != []: for hex in default_settings["skip_colors"]: rgb = hex_to_rgb(hex) i = QListWidgetItem(hex) i.setBackground(QColor(rgb[0], rgb[1], rgb[2])) if (rgb[0]*0.299 + rgb[1]*0.587 + rgb[2]*0.114) > 186: i.setForeground(QColor(0, 0, 0)) else: i.setForeground(QColor(255, 255, 255)) self.ui.skip_colors_ListWidget.addItem(i)
def append_color(self, color): """ Appends a color to the list """ hex = rgb_to_hex(color) i = QListWidgetItem(str(self.color_index) + "\t" + str(hex)) i.setBackground(QColor(color[0], color[1], color[2])) if (color[0]*0.299 + color[1]*0.587 + color[2]*0.114) > 186: i.setForeground(QColor(0, 0, 0)) else: i.setForeground(QColor(255, 255, 255)) self.ui.colors_ListWidget.addItem(i) self.color_index += 1
def updateDataList(self): self.listWidget_data.clear() for data in self.Rawdata: dataitem = QListWidgetItem(parent=self.listWidget_data) dataitem.setText(data.name) dataitem.setData(32, data.uid) self.listWidget_data.addItem(dataitem) if data.checkset() is False: dataitem.setForeground(QtGui.QBrush(QtGui.QColor(255, 0, 0))) if data.checkset() is True: dataitem.setForeground(QtGui.QBrush(QtGui.QColor(0, 255, 0)))
def create_item(self, unit): if unit.generic: item = QListWidgetItem(str(unit.klass) + ': L' + str(unit.level)) else: item = QListWidgetItem(unit.id) klass = Data.class_data.get(unit.klass) if klass: item.setIcon(EditorUtilities.create_icon(klass.get_image(unit.team, unit.gender))) if not unit.position: item.setForeground(QColor("red")) return item
def populate_list(self): """ Populates the colors list """ for i, color in enumerate(rust_palette): hex = rgb_to_hex(color) i = QListWidgetItem(str(i) + "\t" + str(hex)) i.setBackground(QColor(color[0], color[1], color[2])) if (color[0] * 0.299 + color[1] * 0.587 + color[2] * 0.114) > 186: i.setForeground(QColor(0, 0, 0)) else: i.setForeground(QColor(255, 255, 255)) self.ui.colors_ListWidget.addItem(i)
def add_user(user_info): item = QListWidgetItem(user_info["nickname"]) item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsSelectable) item.setTextAlignment(Qt.AlignRight) # make operators blue if user_info["role"] != 1: item.setForeground(QColor(0, 0, 255, 255)) self.users_list_items[user_info["id"]] = item self.logs_form.users.addItem(item)
def addImages(self, imgList): self.imageList.clear() for imgPath in imgList: item = QListWidgetItem() icon = QIcon() pixmap = QPixmap(imgPath) icon.addPixmap(pixmap) item.setFont(QFont("Times", 1)) item.setForeground(QColor("white")) item.setText(imgPath) item.setIcon(icon) self.imageList.addItem(item)
def show_list_users(self, list_users): self.messages.addItem(QListWidgetItem('')) # TODO move strings to utils title = QListWidgetItem('Currently available users in this room:') title.setForeground(QColor("#07125c")) self.messages.addItem(title) users = QListWidgetItem(' ' + list_users) users.setForeground(QColor("#363434")) self.messages.addItem(users) self.messages.addItem(QListWidgetItem('')) self.messages.scrollToBottom()
def refresh_widget(self): self.email_list.clear() self.set_email_config_form() for record in get_user_email_conf(self.user_info['username']).get( 'records', []): item = QListWidgetItem(record['addr']) if record['is_default'] == 1: brush = QtGui.QBrush(QtGui.QColor(1, 203, 31)) brush.setStyle(QtCore.Qt.NoBrush) item.setForeground(brush) item.data = record self.email_list.addItem(item)
def set_restricted_item( restricted_item: QtWidgets.QListWidgetItem) -> None: # add list item (only applies to subdirectories, not files) that user does have full access to restricted_item.setText(f'{each} ⚠️') restricted_item.setForeground(QColor(255, 130, 0)) restricted_item.setToolTip( f'At least some files/folders in this subdirectory cannot be uploaded (you do ' f'not have permission)') restricted_item.setData(QtCore.Qt.UserRole, "subdirectory") restricted_item.setFlags(list_item.flags() | QtCore.Qt.ItemIsUserCheckable) restricted_item.setCheckState(QtCore.Qt.Checked)
def testSucceededUnexpected(self, test, id): """ Public method called if a test succeeds unexpectedly. @param test name of the test (string) @param id id of the test (string) """ self.unexpectedSuccessCount += 1 self.progressCounterUnexpectedSuccessCount.setText(str(self.unexpectedSuccessCount)) itm = QListWidgetItem(self.tr(" Unexpected Success")) itm.setForeground(Qt.red) self.testsListWidget.insertItem(1, itm)
def add_no_found(self): #Load no results found message noFoundItem = QListWidgetItem( QIcon(resources.IMAGES['delete']), 'No results were found!') font = noFoundItem.font() font.setBold(True) noFoundItem.setSizeHint(QSize(20, 30)) noFoundItem.setBackground(QBrush(Qt.lightGray)) noFoundItem.setForeground(QBrush(Qt.black)) noFoundItem.setFont(font) self.listWidget.addItem(noFoundItem)
def __init__(self, file_path): QWidget.__init__(self) Ui_Form.__init__(self) self.setupUi(self) self.listWidget.installEventFilter(self) self.label.installEventFilter(self) self.point = QtCore.QPoint() self.setWindowTitle("HashUtil") self.init_style() if not os.path.isfile(file_path): widget_item = QListWidgetItem(self.listWidget) widget_item.setTextAlignment(Qt.AlignCenter) widget_item.setForeground(QColor("red")) widget_item.setText("未检测到文件") return widget_item = QListWidgetItem(self.listWidget) widget_item.setText(os.path.basename(file_path)) widget_item.setFlags(Qt.NoItemFlags) widget_item = QListWidgetItem(self.listWidget) widget_item.setText(file_path) widget_item.setFlags(Qt.NoItemFlags) widget_item = QListWidgetItem(self.listWidget) widget_item.setText(format_size(os.path.getsize(file_path))) widget_item.setFlags(Qt.NoItemFlags) item0 = self.gen_list_item("MD5 ", "Calculating...") self.listWidget.addItem(item0) item1 = self.gen_list_item("SHA1 ", "Calculating...") self.listWidget.addItem(item1) item2 = self.gen_list_item("SHA256", "Calculating...") self.listWidget.addItem(item2) # 开启3个线程分别计算hash值 self.thread0 = ThreadCalHash(HashUtil.MD5, file_path, "MD5 : ", item0) self.thread0.start() self.thread0.cal_end.connect(self.cal_end_callback) self.thread1 = ThreadCalHash(HashUtil.SHA1, file_path, "SHA1 : ", item1) self.thread1.start() self.thread1.cal_end.connect(self.cal_end_callback) self.thread2 = ThreadCalHash(HashUtil.SHA256, file_path, "SHA256 : ", item2) self.thread2.start() self.thread2.cal_end.connect(self.cal_end_callback) self.listWidget.itemClicked.connect(self.item_click)
def testFailedExpected(self, test, exc, id): """ Public method called if a test fails expectedly. @param test name of the test (string) @param exc string representation of the exception (string) @param id id of the test (string) """ self.expectedFailureCount += 1 self.progressCounterExpectedFailureCount.setText(str(self.expectedFailureCount)) itm = QListWidgetItem(self.tr(" Expected Failure")) itm.setForeground(Qt.blue) self.testsListWidget.insertItem(1, itm)
def testSkipped(self, test, reason, id): """ Public method called if a test was skipped. @param test name of the test (string) @param reason reason for skipping the test (string) @param id id of the test (string) """ self.skippedCount += 1 self.progressCounterSkippedCount.setText(str(self.skippedCount)) itm = QListWidgetItem(self.tr(" Skipped: {0}").format(reason)) itm.setForeground(Qt.blue) self.testsListWidget.insertItem(1, itm)
def listdata(self,data,color): temp=QListWidgetItem(data) if color=='red': temp.setForeground(Qt.red) if color=='darkGreen': temp.setForeground(Qt.darkGreen) if color=='yellow': temp.setForeground(Qt.yellow) if color=='white': temp.setForeground(Qt.white) if color=='black': temp.setForeground(Qt.black) self.status_list.addItem(temp)
def testSucceededUnexpected(self, test, id): """ Public method called if a test succeeds unexpectedly. @param test name of the test (string) @param id id of the test (string) """ self.unexpectedSuccessCount += 1 self.progressCounterUnexpectedSuccessCount.setText( str(self.unexpectedSuccessCount)) itm = QListWidgetItem(self.tr(" Unexpected Success")) itm.setForeground(Qt.red) self.testsListWidget.insertItem(1, itm)
def workerError(self, current_time, exceptionString): item = QListWidgetItem(current_time + " : ERROR: " + exceptionString) item.setForeground(Qt.red) self.dlg.process_list.addItem(item) enditem = QListWidgetItem(current_time + "Process aborted...") self.dlg.process_list.addItem(enditem) self.worker.deleteLater() self.thread.quit() self.thread.wait() self.thread.deleteLater() self.dlg.progressBar.setRange(0, 1)
def testFailedExpected(self, test, exc, id): """ Public method called if a test fails expectedly. @param test name of the test (string) @param exc string representation of the exception (string) @param id id of the test (string) """ self.expectedFailureCount += 1 self.progressCounterExpectedFailureCount.setText( str(self.expectedFailureCount)) itm = QListWidgetItem(self.tr(" Expected Failure")) itm.setForeground(Qt.blue) self.testsListWidget.insertItem(1, itm)
def add_message_to_chat(self, sender_name, message, is_attached=False): """ Add message to QList, return the index of message """ # Check if message already on the list if self.listMessages.size() > 0: for else: msg_label = QListWidgetItem() msg_label.setText("{} on {}:".format(sender_name, datetime.datetime.fromtimestamp( int(message.timestamp) ).strftime('%Y-%m-%d %H:%M:%S'))) self.application.get_qpixmap_identicon(message.from_address, lambda pixmap: msg_label.setIcon(QIcon(pixmap))) self.listMessages.addItem(msg_label) msg_text = QListWidgetItem() msg_text.setText(message.text) if not is_attached: msg_label.setForeground(QColor("gray")) msg_text.setForeground(QColor("gray")) else: msg_label.setForeground(QColor("black")) msg_text.setForeground(QColor("black")) self.listMessages.addItem(msg_text)
def add_chat_item(self, talker, text): if talker == 'Darwin': item = QListWidgetItem(talker + ': ' + text) item.setFont(QFont("Arial", 15)) item.setForeground(QColor(255, 0, 0)) item.setTextAlignment(Qt.AlignLeft) self.chat1.addItem(item) item = QListWidgetItem(talker + ': ' + text) item.setFont(QFont("Arial", 15)) item.setForeground(QColor(255, 255, 255)) item.setTextAlignment(Qt.AlignLeft) self.chat2.addItem(item) else: item = QListWidgetItem(talker + ': ' + text) item.setFont(QFont("Arial", 15)) item.setForeground(QColor(0, 0, 255)) item.setTextAlignment(Qt.AlignRight) self.chat2.addItem(item) item = QListWidgetItem(talker + ': ' + text) item.setFont(QFont("Arial", 15)) item.setForeground(QColor(255, 255, 255)) item.setTextAlignment(Qt.AlignRight) self.chat1.addItem(item) self.chat1.scrollToBottom() self.chat2.scrollToBottom()
def add_session_log(self, log): try: if len(log) > 0: for i, l in enumerate(log): item = QListWidgetItem(str(l)) item.setForeground(l.level.value) self.view.ui.lvVisitsLog.addItem(item) self.view.ui.statusbarCurrentEvent.showMessage(log[len(log) - 1].event) except TypeError: item = QListWidgetItem(str(log)) item.setForeground(log.level.value) self.view.ui.lvVisitsLog.addItem(item) self.view.ui.statusbarCurrentEvent.showMessage(log.event)
def send_ssh_msg(self): msg_txt = self.ssh_text.text() #print("my text is " + msg_txt) self.chat_text.scrollToBottom() if msg_txt != '': item = QListWidgetItem('%s' % (self.my_user.name + "shh req >> " + msg_txt)) item.setForeground(QtGui.QColor(COLORS.white)) item.setBackground(QtGui.QColor(COLORS.black)) self.chat_text.addItem(item) self.ssh_text.setText("") t = Thread(target=self.my_user.send_ssh_message, args=(self.friend_id, msg_txt)) t.daemon = True t.start() #self.my_user.send_ssh_message(self.friend_id, msg_txt) self.chat_text.scrollToBottom()
def create_item(self, unit): if unit.generic: item = QListWidgetItem(unit.pack + '_' + str(unit.event_id) + ' -- L' + str(unit.level)) else: item = QListWidgetItem(unit.pack + '_' + str(unit.event_id) + ' -- ' + unit.id) klass = Data.class_data.get(unit.klass) if klass: item.setIcon(EditorUtilities.create_icon(klass.get_image(unit.team, unit.gender))) if not unit.position: item.setForeground(QColor("red")) if unit.pack not in self.packs: self.packs.append(unit.pack) self.pack_view_combobox.addItem(unit.pack) self.pack_view_combobox.setCurrentIndex(self.pack_view_combobox.count() - 1) return item
def emit(self, record): try: item = QListWidgetItem(self.format(record)) if record.levelno > logging.INFO: item.setIcon(QIcon.fromTheme("dialog-warning")) item.setForeground(QBrush(Qt.red)) else: item.setIcon(QIcon.fromTheme("dialog-information")) self.app.exec_in_main(self._add_item, item) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record)
def addtocdblist(self,info): """ add to cdb list without clearing """ for cinfo in info: # test if the supercooldb annotation if type(cinfo)==tuple: details=cinfo[0] newitem=QListWidgetItem(cinfo[1]) newitem.setData(Qt.UserRole,details) if details['annotationtype']=='diffexp': ccolor=QtGui.QColor(0,0,200) elif details['annotationtype']=='contamination': ccolor=QtGui.QColor(200,0,0) elif details['annotationtype']=='common': ccolor=QtGui.QColor(0,200,0) elif details['annotationtype']=='highfreq': ccolor=QtGui.QColor(0,200,0) else: ccolor=QtGui.QColor(0,0,0) newitem.setForeground(ccolor) self.lCoolDB.addItem(newitem) else: self.lCoolDB.addItem(cinfo)
def add_help(self): #Load help fileItem = QListWidgetItem( QIcon(resources.IMAGES['locate-file']), '@\t(Filter only by Files)') font = fileItem.font() font.setBold(True) fileItem.setSizeHint(QSize(20, 30)) fileItem.setBackground(QBrush(Qt.lightGray)) fileItem.setForeground(QBrush(Qt.black)) fileItem.setFont(font) self.listWidget.addItem(fileItem) classItem = QListWidgetItem( QIcon(resources.IMAGES['locate-class']), '<\t(Filter only by Classes)') self.listWidget.addItem(classItem) classItem.setSizeHint(QSize(20, 30)) classItem.setBackground(QBrush(Qt.lightGray)) classItem.setForeground(QBrush(Qt.black)) classItem.setFont(font) methodItem = QListWidgetItem( QIcon(resources.IMAGES['locate-function']), '>\t(Filter only by Methods)') self.listWidget.addItem(methodItem) methodItem.setSizeHint(QSize(20, 30)) methodItem.setBackground(QBrush(Qt.lightGray)) methodItem.setForeground(QBrush(Qt.black)) methodItem.setFont(font) attributeItem = QListWidgetItem( QIcon(resources.IMAGES['locate-attributes']), '-\t(Filter only by Attributes)') self.listWidget.addItem(attributeItem) attributeItem.setSizeHint(QSize(20, 30)) attributeItem.setBackground(QBrush(Qt.lightGray)) attributeItem.setForeground(QBrush(Qt.black)) attributeItem.setFont(font) thisFileItem = QListWidgetItem( QIcon(resources.IMAGES['locate-on-this-file']), '.\t(Filter only by Classes and Methods in this File)') font = thisFileItem.font() font.setBold(True) thisFileItem.setSizeHint(QSize(20, 30)) thisFileItem.setBackground(QBrush(Qt.lightGray)) thisFileItem.setForeground(QBrush(Qt.black)) thisFileItem.setFont(font) self.listWidget.addItem(thisFileItem) tabsItem = QListWidgetItem( QIcon(resources.IMAGES['locate-tab']), '/\t(Filter only by the current Tabs)') font = tabsItem.font() font.setBold(True) tabsItem.setSizeHint(QSize(20, 30)) tabsItem.setBackground(QBrush(Qt.lightGray)) tabsItem.setForeground(QBrush(Qt.black)) tabsItem.setFont(font) self.listWidget.addItem(tabsItem) lineItem = QListWidgetItem( QIcon(resources.IMAGES['locate-line']), ':\t(Go to Line)') font = lineItem.font() font.setBold(True) lineItem.setSizeHint(QSize(20, 30)) lineItem.setBackground(QBrush(Qt.lightGray)) lineItem.setForeground(QBrush(Qt.black)) lineItem.setFont(font) self.listWidget.addItem(lineItem) nonPythonItem = QListWidgetItem( QIcon(resources.IMAGES['locate-nonpython']), '!\t(Filter only by Non Python Files)') self.listWidget.addItem(nonPythonItem) nonPythonItem.setSizeHint(QSize(20, 30)) nonPythonItem.setBackground(QBrush(Qt.lightGray)) nonPythonItem.setForeground(QBrush(Qt.black)) nonPythonItem.setFont(font)
def addCategory(self, title): item = QListWidgetItem(title) item.setBackground(QBrush(QColor(S.highlightLight))) item.setForeground(QBrush(QColor(S.highlightedTextDark))) item.setFlags(Qt.ItemIsEnabled) self.list.addItem(item)