2

I can send data to Arduino from my pc through HM-10. But how can I use the Bleak library with the Tkinter library?

async def run(address):
    
    async with BleakClient(address) as client:
        async def ehyyy():
            await client.write_gatt_char(MODEL_NBR_UUID,b"hello")

   
    main = Tk()
    main.title("app")
    main.geometry("700x500")
    main.resizable("false","false")
    main.configure(background='#595959')


    Nsonglogo = PhotoImage(file="logos/dot.png")
    

    buttonNsong = Button(main, border=0, command=ehyyy, bg="#595959", image =Nsonglogo, activebackground="#595959")
    buttonNsong.pack()
    buttonNsong.place(x=402,y=380)

    main.mainloop()
    
loop = asyncio.get_event_loop()

loop.run_until_complete(run(address))

When I click the button, I receive this error:

coroutine 'run.<locals>.ehyyy' was never awaited

    self.tk.mainloop(n)

RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Wouter
  • 534
  • 3
  • 14
  • 22
  • Unfortunately, the asyncio event loop and the Tkinter event loop are not the same. There are plenty of discussions about the trade-offs between different solutions. For example: https://stackoverflow.com/q/47895765/7721752 – ukBaz Aug 01 '21 at 19:30

0 Answers0