1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
import QtQuick 2.0
import io.thp.pyotherside 1.0
Rectangle {
width: 300
height: 200
TextInput {
id: ti
anchors.fill: parent
onTextChanged: {
py.call('notes_example.notes.set_contents', [text], function() {
console.log('Changes sent to Python');
});
}
Python {
id: py
Component.onCompleted: {
// Add the directory of this .qml file to the search path
addImportPath(Qt.resolvedUrl('.'));
importModule('notes_example', function () {
console.log('imported python module');
call('notes_example.notes.get_contents', [], function(result) {
console.log('got contents from Python: ' + result);
ti.text = result;
});
});
}
}
}
}
|