0

I try to use Python in QML and I think Brython is a convenient javascript library to enable Python on-the-fly. But as far as I know Brython uses web browser tools only. Is it possible to embed Brython in QML in order to use it like back-end?

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"
          }
    }
}
}

sample.js:

import "brython_stdlib.js"
def hello():
    return "hello world"
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
ercishli
  • 25
  • 1
  • 7
  • I think it's not possible, but if you want to use python from QML you could use the following project: https://github.com/thp/pyotherside – eyllanesc Dec 04 '18 at 06:53
  • I use QML for mobile projects. Pyotherside is convenient for desktop but it is very difficult to develop app for mobile using pyotherside. The difficulty is to compile Python for Android. I followed pyotherside for Android documentation on linux, but there is not Pyhon for Android repository , so I cannot compile it when trying the command: ' git clone --branch fixes https://github.com/thp/python3-android' – ercishli Dec 04 '18 at 14:49
  • Also I tested Gpodder app which was written in QML and pyotherside. It works good on Android for earlier version of 8.0, but it sometimes clashes on Android 8.0 maybe because it wasn't updated APK. I still look for a way to run Pyotherside for Android. – ercishli Dec 04 '18 at 14:56

0 Answers0