Skip to content

Commit f49ed0c

Browse files
authored
Merge pull request #64 from zdomke/dev_minor_fixes
FIX: Fix Listening to XRange Changes
2 parents 6d1b089 + 420e8a9 commit f49ed0c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

trace/main.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ def __init__(self, parent=None, args=None, macros=None, ui_filename=__file__.rep
4141
self.ui.month_scale_btn: 2628300,
4242
self.ui.cursor_scale_btn: -1,
4343
}
44-
self.ui.timespan_btns.buttonClicked.connect(self.set_plot_timerange)
44+
self.ui.timespan_btns.buttonToggled.connect(self.set_plot_timerange)
4545

46-
# Click "Cursor" button on plot-mouse interaction
47-
plot_viewbox = self.ui.main_plot.plotItem.vb
48-
plot_viewbox.sigRangeChangedManually.connect(self.ui.cursor_scale_btn.click)
46+
# Toggle "Cursor" button on plot-mouse interaction
47+
multi_axis_plot = self.ui.main_plot.plotItem
48+
multi_axis_plot.vb.menu = None
49+
multi_axis_plot.sigXRangeChangedManually.connect(self.ui.cursor_scale_btn.toggle)
4950

5051
# Parse macros & arguments, then include them in startup
5152
input_file, startup_pvs = self.parse_macros_and_args(macros, args)
@@ -180,8 +181,8 @@ def resetPlot(self) -> None:
180181
self.axis_table_model.set_model_axes()
181182
self.curves_model.set_model_curves()
182183

183-
@Slot(QAbstractButton)
184-
def set_plot_timerange(self, button: QAbstractButton) -> None:
184+
@Slot(QAbstractButton, bool)
185+
def set_plot_timerange(self, button: QAbstractButton, toggled: bool) -> None:
185186
"""Slot to be called when a timespan setting button is pressed.
186187
This will enable autoscrolling along the x-axis and disable mouse
187188
controls. If the "Cursor" button is pressed, then autoscrolling is
@@ -192,7 +193,12 @@ def set_plot_timerange(self, button: QAbstractButton) -> None:
192193
button : QAbstractButton
193194
The timespan setting button pressed. Determines which timespan
194195
to set.
196+
toggled : bool
197+
Whether or not the associated button is toggled or not.
195198
"""
199+
if not toggled:
200+
return
201+
196202
logger.debug("Setting plot timerange")
197203
if button not in self.button_spans:
198204
logger.error(f"{button} is not a valid timespan button")

0 commit comments

Comments
 (0)