I am using Pyrogram and Tkinter:
from tkinter import *
from pyrogram import Client
root = Tk()
app = Client("my_account")
First, I register a handler with Pyrogram:
@app.on_message()
def message(client, message):
print("Message!")
Second, I register a handler with Tkinter:
def button(event):
print("Button!")
root.bind('<Button>', button)
But how can I start the loops for Pyrogram and Tkinter? Obviously the following (or the reverse) does not work:
root.mainloop()
app.run()
Edit: Since one of the key feature of Pyrogram is that it is fully asynchronous (e.g., https://docs.pyrogram.org/start/updates#registering-a-handler), I would expect an answer based on Asyncio. Here is however my attempt with threading following comments by @SylvesterKruin.
t = Thread(target=app.run)
t.start()
root.mainloop()
Il fails with RuntimeError: There is no current event loop in thread 'Thread-1'
.