diff --git a/march_rqt_input_device/resource/input_device.ui b/march_rqt_input_device/resource/input_device.ui index 494b60a..3b5f9a7 100644 --- a/march_rqt_input_device/resource/input_device.ui +++ b/march_rqt_input_device/resource/input_device.ui @@ -52,16 +52,6 @@ - - - - <html><head/><body><p>Refreshes the buttons with possible gaits</p></body></html> - - - Refresh - - - diff --git a/march_rqt_input_device/src/march_rqt_input_device/input_device_view.py b/march_rqt_input_device/src/march_rqt_input_device/input_device_view.py index b9125c8..9f456d4 100644 --- a/march_rqt_input_device/src/march_rqt_input_device/input_device_view.py +++ b/march_rqt_input_device/src/march_rqt_input_device/input_device_view.py @@ -1,7 +1,7 @@ import os from python_qt_binding import loadUi -from python_qt_binding.QtCore import QSize +from python_qt_binding.QtCore import QMutex, QSize, QTimer from python_qt_binding.QtWidgets import QGridLayout from python_qt_binding.QtWidgets import QPushButton from python_qt_binding.QtWidgets import QWidget @@ -32,7 +32,8 @@ def __init__(self, ui_file, controller): # Extend the widget with all attributes and children from UI file loadUi(ui_file, self) - self.refresh_button.clicked.connect(self._update_possible_gaits) + self._update_gaits_mutex = QMutex() + self._start_possible_gaits_refresh_timer() self._create_buttons() self._update_possible_gaits() @@ -325,7 +326,13 @@ def _rejected_cb(self): def _current_gait_cb(self, gait_name): self.gait_label.setText(gait_name) + def _start_possible_gaits_refresh_timer(self): + self._gaits_timer = QTimer(self) + self._gaits_timer.timeout.connect(self._update_possible_gaits) + self._gaits_timer.start(500) + def _update_possible_gaits(self): + self._update_gaits_mutex.lock() self.frame.setEnabled(False) self.frame.verticalScrollBar().setEnabled(False) possible_gaits = self._controller.get_possible_gaits() @@ -343,6 +350,7 @@ def _update_possible_gaits(self): button.setEnabled(False) self.frame.setEnabled(True) self.frame.verticalScrollBar().setEnabled(True) + self._update_gaits_mutex.unlock() def create_button(self, name, callback=None, image_path=None, size=(128, 160), always_enabled=False): """Create a push button which the mock input device can register.