Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (27 sloc) 1.1 KB
// Importing libraries
import QtQuick 2.0
import Ubuntu.Components 1.1
import io.thp.pyotherside 1.4 // This will allow us to use python. We need the library in ../lib/arm-linux-gnueabihf
MainView {
width: units.gu(50) // Size app window
height: units.gu(40)
Python { // Starts the python magic!
id: py
Component.onCompleted: { // Set python environment
addImportPath(Qt.resolvedUrl("./py"));
importModule("fsutils", function() {});
}
function ls() { // This is a javascript function, called when user clicks the button
py.call("fsutils.ls", [], function () {}); // This is the real call to the python function
}
}
Button { // Just a button
text: "Hello World"
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
onClicked: { // When user clicks on button...
console.log('Click on btn. Calling python...');
py.ls(); // Call the javascript function "ls" in line 20
}
}
}