Beispiel #1
0
class LogViewHandler(logging.Handler, QWidget):
    def __init__(self, parent):
        logging.Handler.__init__(self)
        QWidget.__init__(self, parent)

        self.ui = Ui_LogViewTab()
        self.ui.setupUi(self)
        self.model = LogModel()
        self.filter_model = FilteredLogModel()
        self.filter_model.setSourceModel(self.model)
        self.ui.logView.setModel(self.filter_model)
        self.ui.filterSlider.valueChanged.connect(self.setFilter)
        self.ui.filterSlider.setValue(3)

        self.parent().addClearAction()
        self.parent().clearRequested.connect(self.model.clear)

    def emit(self, record):
        self.model.insertMessage(record)
        self.updateView()

    def updateView(self):
        self.ui.logView.resizeColumnsToContents()
        if self.ui.logView.columnWidth(2) > 500:
            self.ui.logView.setColumnWidth(2, 500)
        self.ui.logView.scrollToBottom()

    def setFilter(self, value):
        self.filter_model.setMinimum(value * 10)
        self.updateView()
Beispiel #2
0
    def __init__(self, parent):
        logging.Handler.__init__(self)
        QWidget.__init__(self, parent)

        self.ui = Ui_LogViewTab()
        self.ui.setupUi(self)
        self.model = LogModel()
        self.filter_model = FilteredLogModel()
        self.filter_model.setSourceModel(self.model)
        self.ui.logView.setModel(self.filter_model)
        self.ui.filterSlider.valueChanged.connect(self.setFilter)
        self.ui.filterSlider.setValue(3)

        self.parent().addClearAction()
        self.parent().clearRequested.connect(self.model.clear)