2013-08-07 21:47:24 +02:00
|
|
|
import QtQuick 2.0
|
|
|
|
import io.thp.pyotherside 1.0
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: 300
|
|
|
|
height: 200
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
id: ti
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onTextChanged: {
|
2014-02-06 21:31:24 +01:00
|
|
|
py.call('notes_example.notes.set_contents', [text], function() {
|
2013-08-07 21:47:24 +02:00
|
|
|
console.log('Changes sent to Python');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Python {
|
|
|
|
id: py
|
|
|
|
Component.onCompleted: {
|
2014-02-06 21:31:24 +01:00
|
|
|
// Add the directory of this .qml file to the search path
|
2014-02-06 21:56:24 +01:00
|
|
|
addImportPath(Qt.resolvedUrl('.'));
|
2014-02-06 21:31:24 +01:00
|
|
|
|
|
|
|
importModule('notes_example', function () {
|
2013-08-07 21:47:24 +02:00
|
|
|
console.log('imported python module');
|
2014-02-06 21:31:24 +01:00
|
|
|
call('notes_example.notes.get_contents', [], function(result) {
|
2013-08-07 21:47:24 +02:00
|
|
|
console.log('got contents from Python: ' + result);
|
|
|
|
ti.text = result;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|