thp / pyotherside

Python Bindings for Qt 5 and Qt 6. Allows you to access a CPython 3 interpreter directly from your Qt QML user interface code.
https://thp.io/2011/pyotherside/
Other
364 stars 49 forks source link

How to make executables with pyotherside? #89

Open jozo opened 6 years ago

jozo commented 6 years ago

Hi guys,

when working with PyQt we can use pyinstaller or similar apps to freeze python scripts and make one executable from them. How is it possible to create a executable for project that use pyotherside? Is there some tutorial? Goal is to create and distribute packages for different platforms (mac, linux, windows).

toby20130333 commented 5 years ago

meet to

alex-eri commented 4 years ago

Create C++ / QML project from template.

Add new python file to qml.qrc like backend/resources.py

Add some functions like def request(a): return 123+a

In main.qml add

import io.thp.pyotherside 1.5

and inside component

    Python {
        id: py
        Component.onCompleted: {
            addImportPath(Qt.resolvedUrl('qrc:/backend/'));
            importModule('resources',  function() {})
        }
    }

Then in interface

Button {
        onClicked: {
            py.call('resources.request', [234], function (result) {
                console.log(result)
            })
       }

}

Compile and run.