Debian Codegraph @

examples/notes_example.qml

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