0

我尝试在 QML 中使用 Python,我认为 Brython 是一个方便的 JavaScript 库,可以即时启用 Python。但据我所知,Brython 只使用网络浏览器工具。是否可以在 QML 中嵌入 Brython 以便像后端一样使用它?

main.qml:

import QtQuick 2.0
import QtQuick.Window 2.2
import "sample.js" as Util
Window {
    width:300 ; height:300
    visible:true
    Column{
          TextEdit{
             id:inputText
             width:200
             height:50
             onAccepted{
               result.text = Util.hello()
            }
          }
          Text{
             id:result
             color:"blue"
          }
    }
}
}

示例.js:

import "brython_stdlib.js"
def hello():
    return "hello world"
4

0 回答 0