ahoj
i was looking into some cross platform languages, tried this or that and finally decided to go with python
i have implemented all my application logic plus persistance in python and it works nicely from cmdline
now i ve started to glue it with qml, but honestly, is that it ?
i have now basically an appcontroller in python that i did wanted to instantiate once and assign it to applicationWindow: done
now when i see the example code, it seems i would need a wrapper for each method ?
yes, i could have checked earlier, but the first sentence:
In addition to C++, Python is a fully supported language for developing Sailfish OS applications. It …
yes i will now did into pyotherside docs but if someone knows a nice example of something more then calling some fu’s
would save me a lot of time
thanks!
the problem is that they mainly execute a calculation, thus it is a method call with arguments.
but i have now an oo model
what i saw sofar in the documents and tried out:
you can have python intepreter multiple times. they share the context.
so i can create a global var and init it on start then access it per global variable.
while that would work, it means i would need to write a wrapper fu for each method …
You need callbacks. You can implement a generic callback method that takes variable arguements. Generally, one to one callbacks are quick and dirty. But building a qml/javascript generic object mapper is possible. I’d need to see your python to comment further.
You might look at Multimodal as it has some interesting methods and has both intelligent (python) use of hardware and SQL, among other things. But I can’t remember how he wired it. Just that I have some todos. EDIT: https://github.com/poetaster/harbour-multimodal is an sdk friendly version.
Actually, that’s not really true. I was being ‘square’. If you look at the cookbook, you will see a block on continuation style and the complementary callback style: PyOtherSide Developer Guide — PyOtherSide 1.6.2 documentation The snippet in question is ‘direct’:
idea was to have assetmanager to manage phydims, units etc and to use it in qml
now i did stumble over second python specific: i can not pass a reference.
so i can have a central assetmanager to instantiate and init all controllers, but i can not use assetmanager to store all at once, as the copies to contain the new data.
this is what i am changing now:
moving store into the controllers.
from what i saw sofar i can init all in importModule call
then i will need a wrapper for get and store at least
as i did implement all the checks in the controllers, i would need to write wrappers for those methods too
i guess it is a very nice structured and written app, but it only shows:
you have one object (in this case pythonhandler) that exposes a million of methods …
i mean i could have written one flat file with static functions in py and it would be easier to connect with qml then what i have done here.
what a waste of my time
and even that:
how would i wrap something like that into
assetMngr.getController(arg).getList()
Waste of time or learning experience, see it as you will.
I haven’t been able to find a better solution yet other than invoking each method individually.
Maybe building some kind of master method in python and passing keyword arguments could work but I didn’t think it through so this may be a dead end as well.
I was hinting at something like this when I began. On the python side you have a function which passes variable signal names and params and likewise on the javascript side. Somthing like:
i am in bed with covid, as soon as i am fit to work i will not have time left to finish it
so i did spent one day to reimplement all in python
now struggling the second day with pyotherside
no i do not consider it as learning something usefull…
the other fun fact:
if i return a list of strings, it arrives as json array
if i return a dict it will be object, so far to true
now if i return list(dict.values()) it should arrive as json array on qml side, only it does not
it arrives as vectormap and i need to convert it
I don’t understand. The Type mappings in both directions are flexible. A python dict is a JS object that can be used much like a dict. List, tuple and set are then JS arrays. If you’re call to getList() returns a dict you can do stuff like this (no callback):
i can load the basics now.
but can not store back
i did deploy all data files into /usr/share … - seems not writeable
can not find an rpm macro for that:
You’re overcomplicating things! But I understand. I’m just lazy enough to simply dump all the python stuff in either a subdir of ‘/qml’ or in ‘/usr/share/myapp/lib’ …
In an older version of Imageworks, which included python library stuff I did this in the .pro (so qmake, not rpm):