From f5acdd8f76d2a81d8d567949f2b8dc955fe834dc Mon Sep 17 00:00:00 2001 From: michaellans Date: Thu, 23 Oct 2025 16:24:28 -0700 Subject: [PATCH 1/4] set AutoScroll for any relative time --- trace/main.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/trace/main.py b/trace/main.py index f5a414b..2ae9579 100644 --- a/trace/main.py +++ b/trace/main.py @@ -14,6 +14,7 @@ QDialog, QWidget, QMenuBar, + QLineEdit, QSplitter, QFileDialog, QHBoxLayout, @@ -231,8 +232,57 @@ def build_toolbar(self, parent: QWidget) -> QWidget: timespan_buttons = self.build_timespan_buttons(toolbar_widget) tool_layout.addWidget(timespan_buttons) + self.timespan_lineEdit = QLineEdit() + self.timespan_lineEdit.returnPressed.connect(self.parse_time_input) + self.timespan_lineEdit.setFixedWidth(120) + self.timespan_lineEdit.setPlaceholderText("Enter timescale") + tool_layout.addWidget(self.timespan_lineEdit) + return toolbar_widget + def parse_time_input(self) -> None: + """ + Parse user entered time input. Allows user to add 'm' 'h', 'd', 'w', or 'M' + to the end of a float timescale to select minutes, hours, days, weeks, or months. + Timescale multiplier is set accordingly, and if the remaining entry can be + converted to a float, the timescale is changed accordingly. + + Parameters + ---------- + None + Gets time setting from user entered text on GUI + + Returns + ------- + None + Calls set_auto_scroll_span with float arg timescale + + """ + + MULTIPLIERS = {"m": 60, "h": 3600, "d": 86400, "w": 604800, "M": 2628300} + + time_str = self.timespan_lineEdit.text() + + if time_str == "": + return + + if time_str[0] == "-": + time_str = time_str[1:] + + final_char = time_str[-1] + if final_char not in MULTIPLIERS: + return + + try: + time = float(time_str[:-1]) + except ValueError: + return + + multiplier = MULTIPLIERS.get(final_char) + + time_sec = time * multiplier + self.set_auto_scroll_span(time_sec) + def build_timespan_buttons(self, parent: QWidget) -> QWidget: """Build the timespan buttons for the toolbar. This includes buttons for users to set enable autoscrolling for various timespans. From acd4b6cccf03ddb09a07d70aeef9b0aae42a18bf Mon Sep 17 00:00:00 2001 From: michaellans Date: Thu, 23 Oct 2025 16:34:15 -0700 Subject: [PATCH 2/4] updated docs with time span LineEdit --- docs/overview/plot_section.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/overview/plot_section.md b/docs/overview/plot_section.md index a027795..115570e 100644 --- a/docs/overview/plot_section.md +++ b/docs/overview/plot_section.md @@ -28,6 +28,11 @@ For instance, toggling the 1h button will result in the last hour of data being +## Time Span LineEdit + +Next to the time span buttons is a LineEdit where the user can enter any timescale as an int or float, with the last character specified as 'm', 'h', 'd', 'w', or 'M' to specify minutes, hours, days, weeks, or months. Entering a timescale here and hitting the return key will result in the specified timescale being displayed on the plot. For example, entering '1h' will display the last hour of data, '2w' will display the last two weeks. + + ## Plot Settings Users can change the settings of the plot using the settings button in the top left corner of the plot marked with a :octicons-gear-24: icon. From 8a89578f4b53f13d77d2497449ada1400ee3d6ed Mon Sep 17 00:00:00 2001 From: michaellans Date: Thu, 23 Oct 2025 17:06:04 -0700 Subject: [PATCH 3/4] reordered function for consistency --- trace/main.py | 86 +++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/trace/main.py b/trace/main.py index 2ae9579..bb086a3 100644 --- a/trace/main.py +++ b/trace/main.py @@ -240,49 +240,6 @@ def build_toolbar(self, parent: QWidget) -> QWidget: return toolbar_widget - def parse_time_input(self) -> None: - """ - Parse user entered time input. Allows user to add 'm' 'h', 'd', 'w', or 'M' - to the end of a float timescale to select minutes, hours, days, weeks, or months. - Timescale multiplier is set accordingly, and if the remaining entry can be - converted to a float, the timescale is changed accordingly. - - Parameters - ---------- - None - Gets time setting from user entered text on GUI - - Returns - ------- - None - Calls set_auto_scroll_span with float arg timescale - - """ - - MULTIPLIERS = {"m": 60, "h": 3600, "d": 86400, "w": 604800, "M": 2628300} - - time_str = self.timespan_lineEdit.text() - - if time_str == "": - return - - if time_str[0] == "-": - time_str = time_str[1:] - - final_char = time_str[-1] - if final_char not in MULTIPLIERS: - return - - try: - time = float(time_str[:-1]) - except ValueError: - return - - multiplier = MULTIPLIERS.get(final_char) - - time_sec = time * multiplier - self.set_auto_scroll_span(time_sec) - def build_timespan_buttons(self, parent: QWidget) -> QWidget: """Build the timespan buttons for the toolbar. This includes buttons for users to set enable autoscrolling for various timespans. @@ -383,6 +340,49 @@ def build_footer(self, parent: QWidget) -> QWidget: return footer_widget + def parse_time_input(self) -> None: + """ + Parse user entered time input. Allows user to add 'm' 'h', 'd', 'w', or 'M' + to the end of a float timescale to select minutes, hours, days, weeks, or months. + Timescale multiplier is set accordingly, and if the remaining entry can be + converted to a float, the timescale is changed accordingly. + + Parameters + ---------- + None + Gets time setting from user entered text on GUI + + Returns + ------- + None + Calls set_auto_scroll_span with float arg timescale + + """ + + MULTIPLIERS = {"m": 60, "h": 3600, "d": 86400, "w": 604800, "M": 2628300} + + time_str = self.timespan_lineEdit.text() + + if time_str == "": + return + + if time_str[0] == "-": + time_str = time_str[1:] + + final_char = time_str[-1] + if final_char not in MULTIPLIERS: + return + + try: + time = float(time_str[:-1]) + except ValueError: + return + + multiplier = MULTIPLIERS.get(final_char) + + time_sec = time * multiplier + self.set_auto_scroll_span(time_sec) + @Slot(Path) def set_file_indicator(self, file_path: Path) -> None: """Set the file indicator label to the given file path. From 577f1366d0ff239e59eec4dbe34a78ae768a7d50 Mon Sep 17 00:00:00 2001 From: michaellans Date: Wed, 29 Oct 2025 18:08:17 -0700 Subject: [PATCH 4/4] documentation --- docs/overview/plot_section.md | 4 +++- trace/main.py | 11 ----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/overview/plot_section.md b/docs/overview/plot_section.md index 115570e..4c47f39 100644 --- a/docs/overview/plot_section.md +++ b/docs/overview/plot_section.md @@ -30,7 +30,9 @@ For instance, toggling the 1h button will result in the last hour of data being ## Time Span LineEdit -Next to the time span buttons is a LineEdit where the user can enter any timescale as an int or float, with the last character specified as 'm', 'h', 'd', 'w', or 'M' to specify minutes, hours, days, weeks, or months. Entering a timescale here and hitting the return key will result in the specified timescale being displayed on the plot. For example, entering '1h' will display the last hour of data, '2w' will display the last two weeks. +Next to the time span buttons is a LineEdit where the user can enter any timescale as an int or float, with the last character specified as +'m', 'h', 'd', 'w', or 'M' to specify minutes, hours, days, weeks, or months. Entering a timescale here and hitting the return key will +result in the specified timescale being displayed on the plot. For example, entering '1h' will display the last hour of data, '2w' will display the last two weeks. ## Plot Settings diff --git a/trace/main.py b/trace/main.py index bb086a3..9423089 100644 --- a/trace/main.py +++ b/trace/main.py @@ -346,17 +346,6 @@ def parse_time_input(self) -> None: to the end of a float timescale to select minutes, hours, days, weeks, or months. Timescale multiplier is set accordingly, and if the remaining entry can be converted to a float, the timescale is changed accordingly. - - Parameters - ---------- - None - Gets time setting from user entered text on GUI - - Returns - ------- - None - Calls set_auto_scroll_span with float arg timescale - """ MULTIPLIERS = {"m": 60, "h": 3600, "d": 86400, "w": 604800, "M": 2628300}