From 6ec7ab5603863cb1f80a04e09fdb634c6ba6f380 Mon Sep 17 00:00:00 2001 From: Clemens Richter Date: Tue, 18 Apr 2017 12:29:06 +0200 Subject: [PATCH] added auto_scroll to tmc_parser --- grc/multirds_tmc_parser.xml | 16 +++++++++++++++- python/tmc_parser.py | 11 ++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/grc/multirds_tmc_parser.xml b/grc/multirds_tmc_parser.xml index ce2f26a..7f70b2d 100644 --- a/grc/multirds_tmc_parser.xml +++ b/grc/multirds_tmc_parser.xml @@ -9,7 +9,7 @@ #if not $label() #set $label = '"%s"'%$id #end if -$(parser) = multirds.tmc_parser($workdir, $log, $debug, $writeDB,$maxheight) +$(parser) = multirds.tmc_parser($workdir, $log, $debug, $writeDB,$maxheight,$auto_scroll) $(win) = $(parser).getqtwidget() $(gui_hint()($win)) @@ -66,6 +66,20 @@ $(gui_hint()($win)) False + + auto_scroll + auto_scroll + True + bool + + + write Database writeDB diff --git a/python/tmc_parser.py b/python/tmc_parser.py index 00eb54b..44ddc5c 100644 --- a/python/tmc_parser.py +++ b/python/tmc_parser.py @@ -33,7 +33,7 @@ class tmc_parser(gr.sync_block): """ docstring for block tmc_parser """ - def __init__(self, workdir,log,debug,writeDB,maxheight): + def __init__(self, workdir,log,debug,writeDB,maxheight,auto_scroll): gr.sync_block.__init__(self, name="tmc_parser", in_sig=None, @@ -42,7 +42,7 @@ class tmc_parser(gr.sync_block): self.debug=debug self.workdir=workdir self.writeDB=writeDB - self.qtwidget=tmc_parser_Widget(self,maxheight) + self.qtwidget=tmc_parser_Widget(self,maxheight,auto_scroll) self.message_port_register_in(pmt.intern('in')) self.set_msg_handler(pmt.intern('in'), self.handle_msg) self.tmc_meta={} @@ -251,6 +251,10 @@ class tmc_parser_Widget(QtGui.QWidget): if self.parser.tmc_messages.matchFilter(tmc_msg,filters): self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.log_string())) self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.multi_str())) + if self.auto_scroll: + scroll_max=self.logOutput.verticalScrollBar().maximum() + self.logOutput.verticalScrollBar().setValue(scroll_max) + #code.interact(local=locals()) def updateui(self): print("updating ui") def filterChanged(self): @@ -260,11 +264,12 @@ class tmc_parser_Widget(QtGui.QWidget): filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(filters))) print("filter changed") - def __init__(self, parser,maxheight): + def __init__(self, parser,maxheight,auto_scroll): QtGui.QWidget.__init__(self) layout = Qt.QVBoxLayout() self.setLayout(layout) self.parser=parser + self.auto_scroll=auto_scroll self.tmc_message_label=QtGui.QLabel("TMC messages:") self.event_filter=QtGui.QLineEdit()#QPlainTextEdit ? self.location_filter=QtGui.QLineEdit(u"Baden-Württemberg")