Reply
Thread Tools
Posts: 1,269 | Thanked: 3,961 times | Joined on May 2011 @ Brazil
#21
Originally Posted by xerxes2 View Post
Hey thanks for the heads up man. I just built the current snapshot of pyqt5 and it seems to work just fine with qtquick2. So for all you python coders out there it's just to start port to qt5/sailfish. Btw, anyone knows if Sailfish is still using python2?
Have you built PyQt5 for Mer/Sailfish ? I am very interested to have it available in some Mer repository.

Yeah, Sailfish uses Python 2.7.3, see :
http://talk.maemo.org/showthread.php?t=89294
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
Sailfish : Sony Xperia X, Gemini, Jolla, Jolla C, Jolla Tablet, Nexus 4. Nokia N9, N900, N810.
 

The Following 3 Users Say Thank You to rcolistete For This Useful Post:
xerxes2's Avatar
Posts: 513 | Thanked: 651 times | Joined on Feb 2011 @ Sweden
#22
No I've only built it for my own x86 box with python2 under X. I'm only using raw qml so now I only have to figure out what Sailfish's top window is called and wrap it in that. But yes as far as I can tell the pyqt-5.1 snapshot works just fine with qt-5.1 and qtquick2 so the Sailfish package maintainer for pyqt might as well update it.

Edit: Sailfish's top level window is called ApplicationWindow.
__________________
But the WM7 "horse" has a blood lineage tracing back to donkeys such as WM6.5, 6.1, 6.0, 5.1 that was fully neglected for too many years and Microsoft did sweet F all to maintain it (still running on Pocket IE4/6!!).

Last edited by xerxes2; 2013-09-29 at 11:57.
 

The Following 4 Users Say Thank You to xerxes2 For This Useful Post:
Posts: 1,269 | Thanked: 3,961 times | Joined on May 2011 @ Brazil
#23
thp posted about PyOtherSide in SailfishOS Devel mailing list :
https://lists.sailfishos.org/piperma...er/000782.html

Hi,

On Sep 30, 2013, at 1:08 PM, Matt Austin <mail at mattaustin.me.uk> wrote:
> It looks like we might now have a couple of possible options with Python apps on Sailfish with Qt5:
>
> 1) PyOtherSide: http://thp.io/2011/pyotherside/
>
> 2) PyQt 5.0.1: http://www.riverbankcomputing.com/news/pyqt-501
>
> I've been playing around today, and unfortunately was unable to get either installed nicely on the Sailfish VM. PyOtherSide requires Python 3 (which as far as I can tell is not available in the Sailfish VM), and I thought I managed to get PyQt to make/install, but then I just got symbol errors when I tried to import the modules.
>
> Obviously I'm not very good at compilation/linking/dependencies/flags/headers etc. (I am a python user after all :P ). So I was wondering if there are any plans to add either PyOtherSide or PyQt5 to the sailfish repos?


I can't say too much about PyQt, as I haven't used it myself. For PyQt, you might have to package it yourself, but be aware of PyQt's licensing: http://www.riverbankcomputing.com/software/pyqt/license

The rest of this mail deals with PyOtherSide:

It's available in the mer-python3 repository:
https://build.merproject.org/project...ct=mer-python3

In the sb2 target and on a device, you can add that repo using:
zypper ar http://repo.merproject.org/obs/mer-p...r-python3.repo

In the Emulator, you can add that repo using:
zypper ar http://repo.merproject.org/obs/mer-p...r-python3.repo

After that (and a possible "zypper ref"), you can install the QML Plugin in the emulator using:
zypper in pyotherside-qml-plugin-python3-qt5

If you are packaging an application, you should also add this to the RPM .spec file (as QML dependencies are not auto-detected):
Requires: pyotherside-qml-plugin-python3-qt5

Be aware that this is a run-time dependency, so you don't really need to install the QML plugin in your SDK target (it doesn't need to be available at build-time), only on the emulator and on the device where you actually run the application.

The sources are available here:
https://github.com/mer-python3/

The API documentation is here:
http://thp.io/2011/pyotherside/doc/classQPython.html

Some basic usage examples are here:
https://github.com/thp/pyotherside/tree/master/examples

If you're coming from PySide on Harmattan, it's a totally different setup -- instead of launching a Python interpreter that then loads the PySide bindings, which then resolve all Qt symbols that have bindings (takes a long time), you start out with a normal QML application (startup speed = same as C++ QML application) and then import the PyOtherSide QML plugin there (only loads libpython), and once the UI is up (i.e. the user can see your application window), you can then start loading Python modules, etc..

Also, try to avoid the synchronous functions, and use the asynchronous API instead (see PyOtherSide's documentation for examples). Think of your Python code as the "data backend implementation" for your QML UI, and think of your QML code as your main application. Or in other words, "QML uses the services of Python for its backend", instead of "Python uses the services of QML for its frontend".

Also, it's Python >= 3.3 only at this point. See http://www.python.org/dev/peps/pep-0404/ and https://github.com/thp/python2sucks to figure out why this is a very good idea and why you want to have that.

Protip: If you want to have a Python 3 interpreter to play with on the command line, install "python3-base" from that repository.

HTH
Thomas
__________________
Python, C/C++, Qt and CAS developer. For Maemo/MeeGo/Sailfish :
Integral, Derivative, Limit - calculating mathematical integrals, derivatives and limits. SymPy - Computer Algebra System.
MatPlotLib - 2D & 3D plots in Python. IPython - Python interactive shell.
-- My blog about mobile & scientific computing ---
Sailfish : Sony Xperia X, Gemini, Jolla, Jolla C, Jolla Tablet, Nexus 4. Nokia N9, N900, N810.
 

The Following 4 Users Say Thank You to rcolistete For This Useful Post:
xerxes2's Avatar
Posts: 513 | Thanked: 651 times | Joined on Feb 2011 @ Sweden
#24
Pyqt-5.1 was released today.
http://riverbankcomputing.co.uk/news/pyqt-51d

Seems to work just fine so far. Had some rendering problems earlier but that turned out to be a gpu driver problem but I upgraded my graphics stack, and now it runs smooth as silk. Qml2 runs in opengl, on linux at least, so your drivers must support that.

Outside of namespace changes the only problem I've run into so far has been that you have to use super() with multiple inheritance in pyqt5. And I can't for my life get my friggin imageprovider to work. The requestPixmap method somehow takes one parameter less than it should and then qml just spits out "TypeError: invalid result type from ImageProvider.requestPixmap()". I've tried anything I can possibly think of in my own code ... could be a bug in qt or pyqt. Other than that it seems to work just fine. Hopefully it works good on arm/wayland too on Sailfish.
__________________
But the WM7 "horse" has a blood lineage tracing back to donkeys such as WM6.5, 6.1, 6.0, 5.1 that was fully neglected for too many years and Microsoft did sweet F all to maintain it (still running on Pocket IE4/6!!).
 

The Following 3 Users Say Thank You to xerxes2 For This Useful Post:
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#25
PyOtherSide side now supports Python image providers !
About three days ago, THP added support for Python image providers, based on my initial proposal.

It is now possible to register an image provider in the Python part of the code that handles the standard "image://" image URIs used in QtQuick.

Once a URI in the form of "image://python/*" is used, the Python provider is called and Python code can provide image data for the given URL.
The data might among others:
  • come from a file a file loaded by Python
  • come from a file like object extracted from an archive (zipfile, tarfile, etc.)
  • come from a blob stored in a sqlite database
  • be manipulated by some library before being passed to QtQuick
  • or be outright generated on the spot by Python

As QtQuick without a C++ backend can only load images from files, QtResource files or from Network, this adds quite some flexibility to PyOtherSide applications.

The Python-side image provider
Taken from a source code comment, the Python image provider might look like this:
Code:
#Image provider implementation in Python:

import pyotherside

def image_provider(image_id, requested_size):
    if requested_size == (-1, -1):
        requested_size = 100, 200 # some sane default size
        width, height = requested_size
        pixels = ... # get the image data from somewhere
        format = pyotherside.format_argb32 # or some other format
    return (bytearray(pixels), (width, height), format)
    
    pyotherside.set_image_provider(image_provider)
The QtQuick side might then look like this (for clarity not showing the QML code needed to load the needed Python code):
Code:
import QtQuick 2.0

Image {
    id: image
    width: 300
    height: 300
    source : "image://python/foo"
}
Examples
For more detailed source code examples, check the various THPs image provider examples:
image_loader
imageprovider
imageprovider_data
mandelbrot

The mandelbrot fractal example is actually very clever.



The fractal image in the qmlscene window can be both panned and zoomed in and is fully generated by Python code, based on coordinates passed as part of the image:// URI.
__________________
modRana: a flexible GPS navigation system
Mieru: a flexible manga and comic book reader
Universal Components - a solution for native looking yet component set independent QML appliactions (QtQuick Controls 2 & Silica supported as backends)

Last edited by MartinK; 2013-10-08 at 19:35.
 

The Following 7 Users Say Thank You to MartinK For This Useful Post:
Posts: 1,548 | Thanked: 7,510 times | Joined on Apr 2010 @ Czech Republic
#26
You can use PyOtherSide and PDB !

I kinda wondered how to debug the Python part of a PyOtherSide application - I expected it would be difficult as the Python "backend" is loaded and started from Qt.

Then I got an idea - what about PDB ?

I though: "No way it would work out of the box, the input/output will probably end in /dev/null or worse."

But, well, it works just fine !

Just create a file named, say, pdb.qml:

Code:
import QtQuick 2.0
import io.thp.pyotherside 1.0

Rectangle {
    color : "green"
    width : 640
    height : 480
    Text {
        text : "hello PDB!"
    }

    Python {
        id : python
        Component.onCompleted: {
            importModule('pdb', function() {
            call('pdb.set_trace()')
            })
            }
        onError: {
            // when an exception is raised, this error handler will be called
            console.log('python error: ' + traceback);

        }
    }
}
And run it with qmlscene:
Code:
qmlscene pdb.qml
And voila, pdb will be started in the shell you just used to start qmlscene.
__________________
modRana: a flexible GPS navigation system
Mieru: a flexible manga and comic book reader
Universal Components - a solution for native looking yet component set independent QML appliactions (QtQuick Controls 2 & Silica supported as backends)

Last edited by MartinK; 2013-10-12 at 17:16.
 

The Following 4 Users Say Thank You to MartinK For This Useful Post:
Khertan's Avatar
Posts: 1,012 | Thanked: 817 times | Joined on Jul 2007 @ France
#27
And here a little pull request to import python module from Qt Resources :

https://github.com/thp/pyotherside/pull/4

 

The Following 3 Users Say Thank You to Khertan For This Useful Post:
xerxes2's Avatar
Posts: 513 | Thanked: 651 times | Joined on Feb 2011 @ Sweden
#28
Pyqt-5.1.1 was released yesterday. This is the first stable release that works with gcc-4.6.x but it doesn't build with Sailfish' sdk unless you update a few Qt packages from the qt devel repo. It seems to run just fine without upgrading in the emulator though. I made packages if you want to try it in the emulator:

Code:
zypper ar http://enlisy.org/~xerxes2/pkg/sailfish/i586/xerxes2-sailfish-i586.repo
zypper ref
zypper in pyqt
That should get you started. I may have missed a few deps though as there's a lot of them ... There's also python gstreamer bindings and a mp3 codec for gstreamer if you're developing audio apps.
__________________
But the WM7 "horse" has a blood lineage tracing back to donkeys such as WM6.5, 6.1, 6.0, 5.1 that was fully neglected for too many years and Microsoft did sweet F all to maintain it (still running on Pocket IE4/6!!).
 

The Following 5 Users Say Thank You to xerxes2 For This Useful Post:
xerxes2's Avatar
Posts: 513 | Thanked: 651 times | Joined on Feb 2011 @ Sweden
#29
I rebuilt pyqt with the new sdk update and now it builds without fuss at all. Just use the same repo as in the previous post. And if you rather want to use pyotherside you have this repo:
Code:
zypper ar http://repo.merproject.org/obs/mer-python3/latest_i586/mer-python3.repo
zypper ref
zypper in pyotherside-qml-plugin-python3-qt5
I think that pyotherside works with python2 also but it's highly recommended to stick with three!
__________________
But the WM7 "horse" has a blood lineage tracing back to donkeys such as WM6.5, 6.1, 6.0, 5.1 that was fully neglected for too many years and Microsoft did sweet F all to maintain it (still running on Pocket IE4/6!!).

Last edited by xerxes2; 2013-10-23 at 17:10.
 

The Following 3 Users Say Thank You to xerxes2 For This Useful Post:
Posts: 196 | Thanked: 141 times | Joined on Aug 2007
#30
Originally Posted by xerxes2 View Post
I think that pyotherside works with python2 also but it's highly recommended to stick with three!
Nope thp hates python2.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 15:02.