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
#3
So no more tkinter? If you want to write a spreadsheet I would use pandas. First verify that you are getting values.
import asyncio
import threading
from tkinter import *
from bleak import BleakClient
import numpy as np
import pandas as pd

 
class BLEThread(threading.Thread):
    def __init__(self, address):
        threading.Thread.__init__(self)
        self.address = address
        self.table = pd.DataFrame()
 
    async def update_table(self, column, data):
        print(f"update_table({column})")
        self.table[column] = np.frombuffer(data, dtype=np.uint32)
        print(self.table)

    async def read_data(self):
        async with BleakClient(self.address) as client:
            client.start_notify(
                "beb5483e-36e1-4688-b7f5-ea07361b26a8",
                lambda uuid, data: self.update_table("Wert 1", data)
            )
            client.start_notify(
                "beb5483e-36e1-4688-b7f5-ea07361b26a9",
                lambda uuid, data: self.update_table("Wert 2", data)
            )
            while True:
                await asyncio.sleep(1)
 
    def run(self):
        asyncio.run(self.read_data())
 
 
def start_threads(address):
    ble_thread = BLEThread(address)
    ble_thread.start()
 
if __name__ == '__main__':
    start_threads("CC:50:E3:9C:15:02")
Nietzsche likes this post
Reply


Messages In This Thread
RE: add svg to 2 thread program and display tabel in GUI - by deanhystad - May-03-2023, 03:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 46,222 May-06-2023, 08:14 AM
Last Post: pramod08728
  Writing on an lcd display gives problems to the program Idontknowany 1 1,453 Nov-15-2021, 10:46 PM
Last Post: Larz60+
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,293 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,732 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