Browse Source

Added try/except to fix "Thread is configured for Windows GUI but callbacks are not working." error on windows

OP-idk 7 months ago
parent
commit
d4c6fc9264
2 changed files with 13 additions and 1 deletions
  1. 0 0
      BellDrawing.png
  2. 13 1
      GUI.py

+ 0 - 0
Bell Drawing.png → BellDrawing.png


+ 13 - 1
GUI.py

@@ -6,6 +6,17 @@ import time
 import asyncio
 import asyncio
 from dobluetooth import connect, getData
 from dobluetooth import connect, getData
 
 
+# This could probably go in dobluetooth.py
+try:
+    from bleak.backends.winrt.util import allow_sta
+    # tell Bleak we are using a graphical user interface that has been properly
+    # configured to work with asyncio
+    allow_sta()
+except ImportError:
+    # other OSes and older versions of Bleak will raise ImportError which we
+    # can safely ignore
+    pass
+
 """
 """
 parse esp32 data string and make each axis and accell data its own varible
 parse esp32 data string and make each axis and accell data its own varible
 then do math on all those varibles to give us ONE NUMBER from all six numbers
 then do math on all those varibles to give us ONE NUMBER from all six numbers
@@ -64,8 +75,9 @@ def placeLeaderboard():
     nameEntryButton = ctk.CTkButton(width=50,height=50,text="ENTER",fg_color="green",font=("Arial",20),text_color="gray99", master=app)
     nameEntryButton = ctk.CTkButton(width=50,height=50,text="ENTER",fg_color="green",font=("Arial",20),text_color="gray99", master=app)
     nameEntryButton.place(x=670,y=205)
     nameEntryButton.place(x=670,y=205)
 
 
-    image = Image.open("./Bell Drawing.png")
+    image = Image.open("./BellDrawing.png")
     photo = ImageTk.PhotoImage(image)
     photo = ImageTk.PhotoImage(image)
+    #ctkphoto = ctk.CTkImage(image)
 
 
     image_label = ctk.CTkLabel(image=photo,text="",width=10, master=app)
     image_label = ctk.CTkLabel(image=photo,text="",width=10, master=app)
     image_label.place(x=800,y=0)
     image_label.place(x=800,y=0)