Python Forum
add svg to 2 thread program and display tabel in GUI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
add svg to 2 thread program and display tabel in GUI
#1
Hello,

at the moment my program show an GUI in a thread and in the other thread i get some data via BLE in an array. Now i want to display the data in my GUI. First i want to safe them into an svg, then display. Next step is to send it into influx DB oder mySQL. Can anyone help me to creat the svg and display them in my tkinter windows? I need first to creat the svg in my BLE thread and then writ into to svg above my print from the data? Right?

Here is my code:

import asyncio
import threading
from tkinter import *
from bleak import BleakClient
import numpy
import svgwrite



address = "CC:50:E3:9C:15:02"
MODEL_NBR_UUID = "beb5483e-36e1-4688-b7f5-ea07361b26a8"


class BLEThread(threading.Thread):
    def __init__(self, address):
        threading.Thread.__init__(self)
        self.address = address

    async def handle_uuid1_notify(self, sender, data):
        spo2_value = numpy.frombuffer(data, dtype=numpy.uint32)
        print("Red: {0}".format(spo2_value))

    async def handle_uuid2_notify(self, sender, data):
        ir_value = numpy.frombuffer(data, dtype=numpy.uint32)
        print("IR: {0}".format(ir_value))

    async def read_data(self):
        UUID1 = "beb5483e-36e1-4688-b7f5-ea07361b26a8"
        UUID2 = "beb5483e-36e1-4688-b7f5-ea07361b26a9"
        async with BleakClient(self.address) as client:
            await client.start_notify(UUID1, self.handle_uuid1_notify)
            await client.start_notify(UUID2, self.handle_uuid2_notify)
            while True:
                await asyncio.sleep(1)

    def run(self):
        asyncio.run(self.read_data())


class TkinterThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        tkFenster = Tk()
        tkFenster.title('BLE MAX30102')
        tkFenster.mainloop()


def start_threads():
    ble_thread = BLEThread(address)
    tkinter_thread = TkinterThread()

    ble_thread.start()
    tkinter_thread.start()


if __name__ == '__main__':
    start_threads()
Reply


Messages In This Thread
add svg to 2 thread program and display tabel in GUI - by Nietzsche - May-03-2023, 06:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 46,643 May-06-2023, 08:14 AM
Last Post: pramod08728
  Writing on an lcd display gives problems to the program Idontknowany 1 1,502 Nov-15-2021, 10:46 PM
Last Post: Larz60+
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,373 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,971 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020