有没有通过javascript触发某消息函数的机制? #273
Replies: 2 comments 4 replies
-
使用底层的 from pywebio.output import *
from pywebio import session
from pywebio.io_ctrl import output_register_callback
def click_callback(val):
put_text(val)
callback_id = output_register_callback(click_callback)
session.run_js("WebIO.pushData('data', callback_id)", callback_id=callback_id)
|
Beta Was this translation helpful? Give feedback.
-
Hi Please can you give a little bit of example how this can be achieved using Coroutine-based session and start_server. In the above example the output_register_callback(click_callback) and session.runjs are both executed on the server side. How can one register the callback and pass the callback id to the client so it can be used in the client. I guess this can be done through the session. But can one use session when the server has not started? start_server will block until the window is closed, so I cannot place code after start_server |
Beta Was this translation helpful? Give feedback.
-
有没有通过javascript触发某消息函数的机制?
Beta Was this translation helpful? Give feedback.
All reactions