Developing in QML + python for Ubuntu Touch

Yes, I like Python so much!

And I was thinking it would complicate/impossible to create an application for Ubuntu Phone using Python, but not, it's easy :)

Dan Chapman helped me adapting Python for uNav (Thanks mate!). 

You have to know how to create a QML + javascript application first. After that you can use Python in your application. Let's see it!

A so basic example is here.


Download it and from the shell (maybe you'll need system depedences as pyotherside package) in Ubuntu 16.04+ run these commands:
$ git clone https://github.com/costales/tutorial_apps_UT.git
$ cd tutorial_apps_UT/python/
$ qmlscene qml/Main.qml


And voalá!


The trick is in the /lib directory, we'll include a Python library and we'll import it from the QML. Then we can call Python functions from the javascript inside the QML.

I think the example in the directory qml/Main.qml is so simple for understanding the concept, but if you have any doubt, please, leave a comment :)

No comments:

Post a Comment