1
0
mirror of https://github.com/thp/pyotherside.git synced 2025-02-05 08:08:23 +08:00
pyotherside/tests/test_wrapped/test_wrapped.qml
Thomas Perl cc7bc11595 Converter: Only use PyObjectRef, add tests
The converter shouldn't need to deal with PyObject * itself, but use
only PyObjectRef, which takes care of reference already.

Make the GIL state management easier to read.

Add a small test that shows how to pass Python objects to/from QML.
2014-10-08 12:51:37 +02:00

29 lines
687 B
QML

import QtQuick 2.0
import io.thp.pyotherside 1.0
Rectangle {
id: page
width: 300
height: 300
Python {
Component.onCompleted: {
addImportPath(Qt.resolvedUrl('.'));
importModule('test_wrapped', function () {
console.log('"test_wrapped" imported successfully');
var foo = call_sync('test_wrapped.get_foo', []);
console.log('got foo: ' + foo);
var result = call_sync('test_wrapped.set_foo', [foo]);
console.log('got result: ' + result);
});
}
onError: {
console.log('Received error: ' + traceback);
}
}
}