AsteroidOS / asteroid

Build script for AsteroidOS, an open-source operating system for smartwatches
http://asteroidos.org
GNU General Public License v2.0
883 stars 64 forks source link

Write the app by Python #227

Open wannaphong opened 1 year ago

wannaphong commented 1 year ago

Hello! I try to use PyQt5 in AsteroidOS (@MagneFire build the package) and It's worked! I think It's possible to write app by python code + pyqt5.

package requirements

All packages needs to installed by opkg install --force-reinstall *

How to run use ceres user by su ceres and run python by QT_QPA_PLATFORM=wayland EGL_PLATFORM=wayland QT_WAYLAND_DISABLE_WINDOWDECORATION=1 python3 testqt.py

testqt.py

# Code by https://pythonbasics.org/pyqt-hello-world/
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot

def window():
   app = QApplication(sys.argv)
   widget = QWidget()

   textLabel = QLabel(widget)
   textLabel.setText("Hello World!")
   textLabel.move(110,85)

   widget.setGeometry(50,50,320,200)
   widget.setWindowTitle("PyQt5 Example")
   widget.show()
   sys.exit(app.exec_())

if __name__ == '__main__':
   window()

ima_0127b19

@Doomsdayrs think it should use AsteroidOS's QML components. https://github.com/AsteroidOS/qml-asteroid

It want to help someone to write the QML components wrapper for python.

wannaphong commented 1 year ago

I found https://forum.qt.io/topic/112887/pyside2-pyqt5-using-qpluginloader-to-import-a-qt-c-plugin/3. It's maybe use pyqt5 with AsteroidOS's QML components.