def log_filter_by_tag(document: QTextDocument, tag_selected: dict): """ Filter a document, setting visibility according to the tag """ document: QTextDocument block: QTextBlock block = document.begin() while block.isValid(): data = block.userData() if data is not None: tag: dict = data.get_data() if tag is not None: if tag_selected == LOGGER_TAGS[0]: block.setVisible(True) elif tag != LOGGER_TAGS[0] and tag != tag_selected: block.setVisible(False) else: block.setVisible(True) block = block.next()