小编liu*_*xin的帖子

如何将画布内容转换为图像?

from Tkinter import *
root = Tk()
cv = Canvas(root)
cv.create_rectangle(10,10,50,50)
cv.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)

我想将画布内容转换为位图或其他图像,然后执行其他操作,例如旋转或缩放图像,或更改其坐标.

位图可以提高效率,以显示我是否不再绘图.

我该怎么办?

python tkinter bitmap

19
推荐指数
4
解决办法
4万
查看次数

反应原生html postMessage无法访问WebView

我使用React Native webview来显示index.html,HTML将在应用程序中发布消息.然后,应用程序将接收消息并将其写入控制台.问题是app无法接收消息,何时postMessage立即在头上运行.我认为它可能与HTML没有完成加载有关.然后setTimeout,我使用了延迟,并且它有效.

现在我想知道:

  • 有没有更好的方法来解决这个问题?
  • 为什么延迟100毫秒不起作用,但延迟200毫秒呢?

我使用的是React Native版本0.39.0和Node版本7.2.0.

这是我到目前为止的代码:

的index.html

<head>
<title>Index</title>
<script type="text/javascript" src="index.js"></script>
<script type="text/javascript">
    // can not be received
    postMessage('send to react native from index inline, no delay', '*');

    // can not be received
    setTimeout(function(){
        postMessage('send to react native from index inline, delay 0 milliscond', '*')
    }, 0);

    // can received
    setTimeout(function(){
        postMessage('send to react native from index inline, delay 100 milliscond', '*')
    }, 100);

    onload = function() {
        // can …
Run Code Online (Sandbox Code Playgroud)

html javascript postmessage webview react-native

9
推荐指数
1
解决办法
2394
查看次数