1
1
import os
2
2
3
3
from python_qt_binding import loadUi
4
- from python_qt_binding .QtCore import QSize
4
+ from python_qt_binding .QtCore import QSize , QTimer , QMutex
5
5
from python_qt_binding .QtWidgets import QGridLayout
6
6
from python_qt_binding .QtWidgets import QPushButton
7
7
from python_qt_binding .QtWidgets import QWidget
@@ -32,7 +32,8 @@ def __init__(self, ui_file, controller):
32
32
# Extend the widget with all attributes and children from UI file
33
33
loadUi (ui_file , self )
34
34
35
- self .refresh_button .clicked .connect (self ._update_possible_gaits )
35
+ self ._update_gaits_mutex = QMutex ()
36
+ self ._start_possible_gaits_refresh_timer ()
36
37
37
38
self ._create_buttons ()
38
39
self ._update_possible_gaits ()
@@ -325,7 +326,13 @@ def _rejected_cb(self):
325
326
def _current_gait_cb (self , gait_name ):
326
327
self .gait_label .setText (gait_name )
327
328
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
+
328
334
def _update_possible_gaits (self ):
335
+ self ._update_gaits_mutex .lock ()
329
336
self .frame .setEnabled (False )
330
337
self .frame .verticalScrollBar ().setEnabled (False )
331
338
possible_gaits = self ._controller .get_possible_gaits ()
@@ -343,6 +350,7 @@ def _update_possible_gaits(self):
343
350
button .setEnabled (False )
344
351
self .frame .setEnabled (True )
345
352
self .frame .verticalScrollBar ().setEnabled (True )
353
+ self ._update_gaits_mutex .unlock ()
346
354
347
355
def create_button (self , name , callback = None , image_path = None , size = (128 , 160 ), always_enabled = False ):
348
356
"""Create a push button which the mock input device can register.
0 commit comments