class LogDialog(QDialog): def __init__(self, parent, rpt_file_path): self.rpt_file_path = rpt_file_path QDialog.__init__(self, parent) self.setWindowTitle('Log: ' + self.rpt_file_path) main_lay = QVBoxLayout(self) self.txt_log = QPlainTextEdit(self) self.txt_log.setMinimumWidth(500) self.txt_log.setMinimumHeight(300) main_lay.addWidget(self.txt_log) self.btn_close = QPushButton('Close') self.btn_close.clicked.connect(self.close_dialog) main_lay.addWidget(self.btn_close) self.fill_txt() def close_dialog(self): self.close() def fill_txt(self): with codecs.open(self.rpt_file_path, 'r', encoding='UTF-8') as inp_f: lines = inp_f.read().splitlines() for line in lines: self.txt_log.appendPlainText(line.replace('\b', '')) # Scroll up self.txt_log.moveCursor(QTextCursor.Start) self.txt_log.ensureCursorVisible()
def __init__(self): super(TestWindow, self).__init__() self.setWindowTitle("LivePlot Example Runner") layout = QHBoxLayout(self) button_layout = QVBoxLayout() time_layout = QHBoxLayout() time_spin = QSpinBox() self.timer = QTimer() time_spin.valueChanged.connect(self.timer.setInterval) self.timer.timeout.connect(self.iterate) self.progress_bar = QProgressBar() time_spin.setValue(50) time_spin.setRange(0, 1000) time_layout.addWidget(QLabel("Sleep Time (ms)")) time_layout.addWidget(time_spin) button_layout.addLayout(time_layout) tests = { 'plot y': test_plot_y, 'plot xy': test_plot_xy, 'plot parametric': test_plot_xy_parametric, 'plot z': test_plot_z, 'plot huge': test_plot_huge, 'append y': test_append_y, 'append xy': test_append_xy, 'append z': test_append_z, } fn_text_widget = QPlainTextEdit() fn_text_widget.setMinimumWidth(500) def make_set_iterator(iter): def set_iterator(): fn_text_widget.setPlainText(inspect.getsource(iter)) QApplication.instance().processEvents() self.iterator = iter() self.timer.start() return set_iterator for name, iter in tests.items(): button = QPushButton(name) button.clicked.connect(make_set_iterator(iter)) button_layout.addWidget(button) layout.addLayout(button_layout) text_layout = QVBoxLayout() text_layout.addWidget(fn_text_widget) text_layout.addWidget(self.progress_bar) layout.addLayout(text_layout)
def __init__(self): super(TestWindow, self).__init__() self.setWindowTitle("LivePlot Example Runner") layout = QHBoxLayout(self) button_layout = QVBoxLayout() time_layout = QHBoxLayout() time_spin = QSpinBox() self.timer = QTimer() time_spin.valueChanged.connect(self.timer.setInterval) self.timer.timeout.connect(self.iterate) self.progress_bar = QProgressBar() time_spin.setValue(50) time_spin.setRange(0, 1000) time_layout.addWidget(QLabel("Sleep Time (ms)")) time_layout.addWidget(time_spin) button_layout.addLayout(time_layout) tests = { 'plot y': test_plot_y, 'plot xy': test_plot_xy, 'plot parametric': test_plot_xy_parametric, 'plot z': test_plot_z, 'plot huge': test_plot_huge, 'append y': test_append_y, 'append xy': test_append_xy, 'append z': test_append_z, 'label': test_label, } fn_text_widget = QPlainTextEdit() fn_text_widget.setMinimumWidth(500) def make_set_iterator(iter): def set_iterator(): fn_text_widget.setPlainText(inspect.getsource(iter)) QApplication.instance().processEvents() self.iterator = iter() self.timer.start() return set_iterator for name, iter in tests.items(): button = QPushButton(name) button.clicked.connect(make_set_iterator(iter)) button_layout.addWidget(button) layout.addLayout(button_layout) text_layout = QVBoxLayout() text_layout.addWidget(fn_text_widget) text_layout.addWidget(self.progress_bar) layout.addLayout(text_layout)