Pywebio output.put_html是否支持HTML页面中包含的侦听click event的Java Script? #665
Unanswered
smilingsand
asked this question in
Q&A
Replies: 2 comments 1 reply
-
require(["plotly"], function(Plotly) {
....
}); 其实通过查看pywebio 应用在浏览器的控制台输出,应该也能得到有用的debug信息 |
Beta Was this translation helpful? Give feedback.
1 reply
-
这里有个在pywebio中怼plotly中的事件进行监听的完整例子: import pywebio
import plotly.express as px
def main():
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
post_script = """
plot = document.getElementById('{plot_id}')
plot.on('plotly_click', function(data){
console.log('click', data);
});
"""
html = fig.to_html(full_html=False, include_plotlyjs='require', post_script=post_script)
pywebio.output.put_html(html)
pywebio.start_server(main, port=8080, cdn=False) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
程序流程见以下代码:
现象:
保存在本地的html文件可以被浏览器打开,在浏览器中展示初始图形,并可以对鼠标点击事件进行预期的响应。这说明html页面及JS code本身是没有问题的。但是通过output.put_html调用的html,只能在浏览器中展示初始图形,对于鼠标点击事件却不能产生响应。
问题:
pywebio的output.put_html是否支持HTML页面中包含的Java Script,用以侦听事件并处理? 如果这种方法不行,pywebio建议应该怎么处理图形上的事件?
Beta Was this translation helpful? Give feedback.
All reactions