I have a little problem... In fact I am coding with asynchronous methods in classes and I also use Tkinter and the fact is that when I try to press on a button to call a object method it doesn't work beaxause of the async that create an istance of the methods....
I tried many things like using the lambda in the button command attribute but without any results...
May you have an idea ?
I'll be really grateful.
Here is a portion of my code :
class App(customtkinter.CTk, JeuDeLaVie):
# Some code like __init__() and other boring methods
self.startButton = customtkinter.CTkButton(self, text = 'Start', fg_color = '#0D8A66', hover_color = '#0B7657', command = """My command that is supposed to call self.startGame() right below""")
self.startButton.place(relx = .40, rely = .930)
async def startGame(self):
"""
Permet de lancer le jeu avec differentes conditions comme le temps entre chaque tour, la duree maximale, le nombre de tour maximum.
:param nombreDeTours -> int [default value: 100 turns]
:param delai -> int [default value: 1]
:param maxTime -> int [default value: 5 min]
:param model -> str [default value: Manuel]
"""
print(0)
self.startButton.destroy() # Detruit le bouton start
while self.isGameStarted:
await asyncio.create_task(self.run())
#
And that's it....