From c4162041b24120245292eed5a2527797bc7dc421 Mon Sep 17 00:00:00 2001
From: esarrey <eliott.sarrey@gmail.com>
Date: Fri, 9 Jun 2023 14:49:13 +0200
Subject: [PATCH] Test asynch

---
 test.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 test.py

diff --git a/test.py b/test.py
new file mode 100644
index 0000000..12a8cbd
--- /dev/null
+++ b/test.py
@@ -0,0 +1,49 @@
+import sys
+import time
+import random
+from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget
+from PyQt5.QtCore import QThread, pyqtSignal
+
+
+class SensorThread(QThread):
+    sensor_data_signal = pyqtSignal(float)
+
+    def __init__(self):
+        super().__init__()
+
+    def run(self):
+        while True:
+            time.sleep(0.1)
+            # Here, replace this with actual sensor data
+            sensor_data = random.uniform(0, 100)  # Simulating sensor data with random values
+            self.sensor_data_signal.emit(sensor_data)
+
+
+class SensorWidget(QWidget):
+    def __init__(self):
+        super().__init__()
+
+        self.sensor_value_label = QLabel('Waiting for sensor data...', self)
+
+        self.layout = QVBoxLayout(self)
+        self.layout.addWidget(self.sensor_value_label)
+
+        self.sensor_thread = SensorThread()
+        self.sensor_thread.sensor_data_signal.connect(self.update_sensor_value)
+        self.sensor_thread.start()
+
+    def update_sensor_value(self, sensor_value):
+        self.sensor_value_label.setText(f'Sensor value: {sensor_value:.2f}')
+
+
+def main():
+    app = QApplication(sys.argv)
+
+    sensor_widget = SensorWidget()
+    sensor_widget.show()
+
+    sys.exit(app.exec_())
+
+
+if __name__ == '__main__':
+    main()
-- 
GitLab