Road to make SFOS apps with python

Hi guys,

I love to hear some opinions about how to learn creating mobile apps for SFOS.

This year I have started to learn python. The main reason was that I am interested in how that stuff (coding / creating software) works. Another important reason is that I want to create apps for SFOS - well I want to start with one app first :sweat_smile:

By now I have a simple quiz app written in python. I thought before I implement more and more features like players, game modes, etcā€¦ I could start a gui and develop the python and gui part together.
Considering that I want to create an app for SFOS, I tried to start with Qt/qml. But to be honest I didnā€™t get that far. I have watched several tutorials about the model-view-controller concept and Qt/qml but I never got something working with my python app.

I do understand the basics (variables , loops, functions, lists etcā€¦) of python. Nevertheless I am questioning if I am doing it right. Does it make sense to think about creating a mobile app / qt-gui that early or should I go on with python and when I have a well feature python then I move to tkinter first? After that I try again the mvc and after that I learn qt/qml.

Does anyone have an idea how a good roadmap (for me) could be?
For those who learned coding by theselves - how did you do it?
Do you have recommendations for good tutorials/websides to learn?

Learning the basics of python wasnā€™t that hard. I bought a book, which is well structured. The GUI part, because of the lack of structured information, is much harder - at least for me

7 Likes

Happy to hear you want to get started with app development on SFOS! The initial hurdles (on most platforms as a dev from my experience) sometimes seem to be high, but things clear up once you got the trick. :wink:
I can encourage you to check out the Python App Example from here. It is quit a good starting point to understand the mechanics to exchange data in one direction.
Once you got that, you can check out my very small write up on how to send data towards the Python part here in the ā€˜Sailfish, Python and PyOtherSideā€™ section.

I would suggest you to check out the example and modify things until you got an Idea about most of the mechanisms used there. When you got that, you know how the QML and the Python part could work together. Knowing that you get an idea how to further structure your game to have these two working together well.

8 Likes

Donā€™t forget that you can make an app just in QML + Javascript. It would be the simplest way.

You donā€™t need C++, QT, or Python unless your app needs something (libraries etc) they have.

5 Likes

Iā€™ve also started to learn Python this year. And I would also like to code an app for Sailfish OS. I donā€™t know the route to get there, but so far Iā€™m thinking that I want to begin the process by learning the basics in Python, as soon as possible continue with Tkinter (so that I see that itā€™s working and that I can make apps with a GUI), get somewhat familiar with OOP and finally move on and hopefully create an app for SFOS (preferably something with SQLite). Iā€™m still a beginner, slowly making my way towards intermediate, I think. Itā€™s hard to tell :slight_smile: There are many good resources on the web, I love Andrei Neagoieā€™s videos on Youtube, and this text on OOP. David Love - TKinter GUI programming by example seems to be a good resource on Tkinter.

2 Likes

I know. It gets easier from time to time. Nevertheless you have surmount it the first time. :slight_smile:

I have looked at it already, but the docs are for devs. In my opinion its not very good to learn

I didnā€™t know that you can use Javascript as well but I have already started with python. I acually do like it.

Yes, maybe it makes more sense to use Tkinter first. I think I will go this way, too.
What do you learn at the moment?

Iā€™m trying to wrap my head around OOP: modules, classes, inheritance, etc. I havenā€™t got it working quiet yet, but Iā€™ll keep trying until I figure it out. Iā€™ve finally understood the ā€˜if name == ā€œmainā€:ā€™-thing at the end of OOP-files and what it does. I take one step at the time, doing a lot of errors along the way (I learn little from just doing right) and above all having a lot of fun :slight_smile:

Not really.
SFOS uses QML to make the UI. You have to use QML (or qt, but qml is easier) to make a sailfish native app.

The demo QML UI app (name eludes me, and donā€™t have it on this machine) is a good one to get going, as it has all the UI elements in it, and you can see how to make them.
QML takes a bit of getting your head around, but it is quite an easy way to make a UI.

For simple apps, just use javascript functions inside the QML as QML is/uses a slightly old version JS. (i.e. you will find a few things missing from todayā€™s javascript)

Although they are large, a nice thing about a couple of apps I maintain is that they show a use of python as scripting tied to QML and also using native C transparently. Iā€™m thinking specificially of Imageworks. Itā€™s all just straight functions (no oop, per say) and simple bindings but I think it performs really well. And the QML interfaces are clean. The original work was all done by toby (planetos) Iā€™m just filing the edges: https://github.com/poetaster/harbour-simplecrop

1 Like

And you can combine JS, python, c++ and QML :slight_smile: I have a couple of cases where all the languages come into play.

I know what you mean. For beginners with no coding experience - I think - its not that easy to understand. But weā€™ll get to this point. :grinning:

Thank you for your tipp. Thats acutally good to know. I also have written only functions so far. I donā€™t know when I will start with oop in python.

This is acually a questions, which I have asked myself quite a few times. When do I use just functions and wenn do I have to code in oop?

The principle reasons to-do oop (outside of just wanting to implement Design Patterns) is encapsulating and re-use. But even those goals can be achieved without using the languages oop features. I donā€™t really like python or javascripts object features, but I have 10+ years experience doing system design in java. I also donā€™t really enjoy the ā€˜java wayā€™ anymore, but it was a good approach for the scope at the time. I was the designer for an application server where strong oop design pattern principles worked well. That had to do, I believe, with the very formal constraints on the system.

For app development in this context, especially for prototyping, I think javascript and python are of great benefit. As long as one considers code reuse (also concepts like inheritance) you can still hack things together to get a feeling for what something should look like. If you need 3D, you probably want to look at c++ :wink: And c++ object features are something Iā€™m just re-learning now. Thatā€™s a challenge!

1 Like