Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Commit 57503bd

Browse files
committed
Replace the 'Refresh' button with a Timer
1 parent 7db9482 commit 57503bd

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

march_rqt_input_device/resource/input_device.ui

-10
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@
5252
</property>
5353
</widget>
5454
</item>
55-
<item>
56-
<widget class="QPushButton" name="refresh_button">
57-
<property name="toolTip">
58-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Refreshes the buttons with possible gaits&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
59-
</property>
60-
<property name="text">
61-
<string>Refresh</string>
62-
</property>
63-
</widget>
64-
</item>
6555
</layout>
6656
</item>
6757
<item>

march_rqt_input_device/src/march_rqt_input_device/input_device_view.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
from python_qt_binding import loadUi
4-
from python_qt_binding.QtCore import QSize
4+
from python_qt_binding.QtCore import QSize, QTimer, QMutex
55
from python_qt_binding.QtWidgets import QGridLayout
66
from python_qt_binding.QtWidgets import QPushButton
77
from python_qt_binding.QtWidgets import QWidget
@@ -32,7 +32,8 @@ def __init__(self, ui_file, controller):
3232
# Extend the widget with all attributes and children from UI file
3333
loadUi(ui_file, self)
3434

35-
self.refresh_button.clicked.connect(self._update_possible_gaits)
35+
self._update_gaits_mutex = QMutex()
36+
self._start_possible_gaits_refresh_timer()
3637

3738
self._create_buttons()
3839
self._update_possible_gaits()
@@ -325,7 +326,13 @@ def _rejected_cb(self):
325326
def _current_gait_cb(self, gait_name):
326327
self.gait_label.setText(gait_name)
327328

329+
def _start_possible_gaits_refresh_timer(self):
330+
self._gaits_timer = QTimer(self)
331+
self._gaits_timer.timeout.connect(self._update_possible_gaits)
332+
self._gaits_timer.start(500)
333+
328334
def _update_possible_gaits(self):
335+
self._update_gaits_mutex.lock()
329336
self.frame.setEnabled(False)
330337
self.frame.verticalScrollBar().setEnabled(False)
331338
possible_gaits = self._controller.get_possible_gaits()
@@ -343,6 +350,7 @@ def _update_possible_gaits(self):
343350
button.setEnabled(False)
344351
self.frame.setEnabled(True)
345352
self.frame.verticalScrollBar().setEnabled(True)
353+
self._update_gaits_mutex.unlock()
346354

347355
def create_button(self, name, callback=None, image_path=None, size=(128, 160), always_enabled=False):
348356
"""Create a push button which the mock input device can register.

0 commit comments

Comments
 (0)