| 1 |
import QtQuick 2.0 |
| 2 |
import io.thp.pyotherside 1.0 |
| 3 |
|
| 4 |
Rectangle { |
| 5 |
width: 400 |
| 6 |
height: width |
| 7 |
|
| 8 |
Python { |
| 9 |
Component.onCompleted: { |
| 10 |
// Add the directory of this .qml file to the search path |
| 11 |
addImportPath(Qt.resolvedUrl('.')); |
| 12 |
|
| 13 |
setHandler('append', function (message, number) { |
| 14 |
output.text += '\n' + message + number; |
| 15 |
}); |
| 16 |
|
| 17 |
setHandler('color', function(color) { |
| 18 |
output.color = color; |
| 19 |
}); |
| 20 |
|
| 21 |
// Import the main module |
| 22 |
importModule('events_example', function () { |
| 23 |
console.log('Event example module is now imported'); |
| 24 |
}); |
| 25 |
} |
| 26 |
|
| 27 |
onReceived: console.log('Unhandled event: ' + data) |
| 28 |
} |
| 29 |
|
| 30 |
Text { |
| 31 |
id: output |
| 32 |
anchors.centerIn: parent |
| 33 |
} |
| 34 |
} |