I can't get pyotherside right [answered]
I can't get even the simpliest application to work with Sailfish and PyOtherSide. What i'm doing wrong? Is it with addImportPath? Here is the code:
pressbutton.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
import io.thp.pyotherside 1.0
ApplicationWindow
{
initialPage: Page {
id: page
Button {
id: mybtn
text: "press"
anchors.centerIn: page
onClicked: {
py.call('pressbutton.pressme', function() {});
}
}
Python {
id: py
Component.onCompleted: {
addImportPath(Qt.resolvedUrl('/usr/share/pressbutton/qml'));
importModule('pressbutton', function() {});
}
}
}
cover: Qt.resolvedUrl("cover/CoverPage.qml")
}
and pressbutton.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pyotherside
def pressme():
f = open("/home/nemo/Documents/file.txt","a")
f.write("this is example text")
f.close()
What does the QtCreator / SDK say when you try to build / deploy that?
foss4ever ( 2014-02-09 10:48:53 +0200 )editI deploy that with "mb2 -t SailfishOS-armv7hl rpm" and it doesn't give any error. The App works (there's button in the middle of screen) but when pressed it doesn't create new file to the Documents-folder.
triztan79 ( 2014-02-09 12:40:05 +0200 )editYou should improve your example code with onError callback and return a value from your pythons module method that can be printed out with console() QML function. Do also remember that you call your python code async. For a synchronous test use call_sync(). HTH.
Nekron ( 2014-02-09 16:31:36 +0200 )edit