def my_print(self, text_list: list, background: list): # self.show_info.clear() 这个可以清空显示 self.show_info.addItems([". . . . . . . . . . . . . . . . . . . . . . . . . " ". . . . . . . . . . . . . . . . . . . . . . . . . "]) for ind in range(len(text_list)): item = QListWidgetItem('%s' % text_list[ind]) item.setBackground(QColor(background[ind])) # 上色 self.show_info.addItem(item) self.show_info.scrollToBottom() # 自动到最后行
def AddItem(self, name): item = QListWidgetItem(name) item.setTextAlignment(Qt.AlignCenter) # item.setBackground(QColor(87, 195, 194)) item.setBackground(QColor(0, 0, 0, 0)) item.setSizeHint(QSize(90, 30)) item.setFlags(item.flags() & (~Qt.ItemIsSelectable)) self.addItem(item)
def create_current_item(self, flags): if self.active_stack.index() == 0: txt = _(' 0: Geladener Zustand des Dokuments') else: txt = _(' 0: Aktueller Zustand des Dokuments') current_item = QListWidgetItem(txt) current_item.setForeground(self.fg_black) current_item.setBackground(self.bg_grey) current_item.setFlags(flags) current_item.setIcon(IconRsc.get_icon('options')) return current_item
def UpdateEpsInfo(self): self.epsListWidget.clear() info = BookMgr().books.get(self.bookId) if not info: return downloadEpsId = self.owner().downloadForm.GetDownloadEpsId(self.bookId) for index, epsInfo in enumerate(info.eps): label = QLabel(epsInfo.title) label.setContentsMargins(20, 10, 20, 10) item = QListWidgetItem(self.epsListWidget) item.setSizeHint(label.sizeHint()) if index in downloadEpsId: item.setBackground(self.greed) else: item.setBackground(self.white) self.epsListWidget.setItemWidget(item, label)
def fill_widgets_with_emails(self): if not self.template or not self.xlsx_rows_list: return for xlsx_row in self.xlsx_rows_list: sample_row_text = ' '.join([ xlsx_row[col] if col != 'email' else ', '.join(xlsx_row[col]) for col in self.info_cols ]) item = QListWidgetItem(sample_row_text) item.xlsx_row = xlsx_row # Именно отсюда мы возьмём данные для отправки item.setCheckState(Qt.Checked) if xlsx_row[OKOK] == OKOK: item.setCheckState(Qt.Unchecked) item.setBackground(QBrush(QColor("lightGreen"))) # Вах! self.listWidget_emails.addItem(item) self.listWidget_emails.itemClicked.connect( self.update_preview_and_attaches_list) self.listWidget_attachments.itemClicked.connect(self.show_email_attach) self.update_preview_and_attaches_list(self.listWidget_emails.item(0))
def UpdateEpsData(self): self.epsListWidget.clear() info = BookMgr().books.get(self.bookId) if not info: return self.startRead.setEnabled(True) downloadIds = self.owner().downloadForm.GetDownloadCompleteEpsId( self.bookId) for index, epsInfo in enumerate(info.eps): label = QLabel(epsInfo.title) label.setContentsMargins(20, 10, 20, 10) item = QListWidgetItem(self.epsListWidget) if index in downloadIds: item.setBackground(QColor(18, 161, 130)) else: item.setBackground(QColor(0, 0, 0, 0)) item.setSizeHint(label.sizeHint()) self.epsListWidget.setItemWidget(item, label) self.tabWidget.setTabText(0, "章节({})".format(str(len(info.eps)))) return