Editing Python/Harmattan/Getting started with Harmattan Python

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 37: Line 37:
==== Installing other Python-related packages ====
==== Installing other Python-related packages ====
-
MeeGo 1.2 Harmattan platform uses [https://web.archive.org/web/20120929010040/http://library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/guide/html/Developer_Library_Application_development_framework_ebcf.html QtQuick] as its preferred method to develop interfaces. The [http://www.pyside.org PySide] project provides Python bindings for Qt allowing Python developers to develop their interfaces. [https://web.archive.org/web/20120929010040/http://developer.qt.nokia.com/wiki/PySideDocumentation/ Here] you can find useful information on how to develop using PySide/QtQuick/QML. If you plan to develop applications that use just Qt (without QML) they will not integrate (use and feel) with the native interface.
+
MeeGo 1.2 Harmattan platform uses [http://library.developer.nokia.com/topic/MeeGo_1.2_Harmattan_API/html/guide/html/Developer_Library_Application_development_framework_ebcf.html QtQuick] as its preferred method to develop interfaces. The [http://www.pyside.org PySide] project provides Python bindings for Qt allowing Python developers to develop their interfaces. [http://developer.qt.nokia.com/wiki/PySideDocumentation/ Here] you can find useful information on how to develop using PySide/QtQuick/QML. If you plan to develop applications that use just Qt (without QML) they will not integrate (use and feel) with the native interface.
To install these new packages you can continue from the same terminal opened in the last section. Again, use ''apt-get'' to install all the needed packages:
To install these new packages you can continue from the same terminal opened in the last section. Again, use ''apt-get'' to install all the needed packages:
Line 46: Line 46:
</nowiki>
</nowiki>
-
There are also [https://web.archive.org/web/20120929010040/http://qt-project.org/wiki/PySideDocumentation/#704d2ca247b8787c6738c5a47d3f98ec bindings] for [https://web.archive.org/web/20120929010040/http://doc.qt.nokia.com/qtmobility-1.2/index.html QtMobility]. To install them:
+
There are also [http://developer.qt.nokia.com/wiki/PySideDocumentation/#704d2ca247b8787c6738c5a47d3f98ec bindings] for [http://doc.qt.nokia.com/qtmobility-1.2/index.html QtMobility]. To install them:
  <nowiki>
  <nowiki>
Line 62: Line 62:
== Tasting PySide/QML ==
== Tasting PySide/QML ==
-
If you have skipped any of the previous sections and have PySide installed you can see here an [https://web.archive.org/web/20120929010040/http://developer.qt.nokia.com/wiki/Hello_World_in_PySide_and_QtQuick example] taken from PySide documentation website.  
+
If you have skipped any of the previous sections and have PySide installed you can see here an [http://developer.qt.nokia.com/wiki/Hello_World_in_PySide_and_QtQuick example] taken from PySide documentation website.  
-
[https://web.archive.org/web/20120929010040/http://doc.qt.nokia.com/4.7/qdeclarativeintroduction.html QML] is a declarative language designed to describe the user interface of a program: both what it looks like, and how it behaves. In QML, a user interface is specified as a tree of objects with properties. In this tutorial we will show how you can make a simple Hello World application with PySide and QML.
+
[http://doc.qt.nokia.com/4.7/qdeclarativeintroduction.html QML] is a declarative language designed to describe the user interface of a program: both what it looks like, and how it behaves. In QML, a user interface is specified as a tree of objects with properties. In this tutorial we will show how you can make a simple Hello World application with PySide and QML.
A PySide/QML application consists, at least, of two different files – a file with the QML description of the user interface, and a python file which loads the qml file. To avoid problems for now, don’t forget to save both files in the same folder.
A PySide/QML application consists, at least, of two different files – a file with the QML description of the user interface, and a python file which loads the qml file. To avoid problems for now, don’t forget to save both files in the same folder.
Line 122: Line 122:
If you are already familiar with PySide and have followed our tutorials, much of this code is already familiar. The only novelties is that you must import QDeclarativeView and set the source of the QDeclarativeView object to the URL of your QML file. Then, as any Qt widget, you call ''QDeclarativeView.show()''.
If you are already familiar with PySide and have followed our tutorials, much of this code is already familiar. The only novelties is that you must import QDeclarativeView and set the source of the QDeclarativeView object to the URL of your QML file. Then, as any Qt widget, you call ''QDeclarativeView.show()''.
-
Take your time exploring this example. You can try to do basic things as changing the colors, the text, or set other properties to each element, setting a radius on the rectangle color. Check the elements and their properties in [https://web.archive.org/web/20120929010040/http://doc.qt.nokia.com/4.7/qdeclarativeelements.html QML Elements].
+
Take your time exploring this example. You can try to do basic things as changing the colors, the text, or set other properties to each element, setting a radius on the rectangle color. Check the elements and their properties in [http://doc.qt.nokia.com/4.7/qdeclarativeelements.html QML Elements].
== Security framework for Python scripts ==
== Security framework for Python scripts ==
Line 128: Line 128:
To run applications (binaries and scripts) it is necessary to follow some security guidelines. Information about the implications of the security framework for applications in general can be found [https://projects.maemo.org/mediawiki/index.php/Developer_Library/Developing_for_Harmattan/Harmattan_security here].
To run applications (binaries and scripts) it is necessary to follow some security guidelines. Information about the implications of the security framework for applications in general can be found [https://projects.maemo.org/mediawiki/index.php/Developer_Library/Developing_for_Harmattan/Harmattan_security here].
-
If your ''dosomething.py'' python script is marked as executable (as the result of ''chmod +x dosomething.py''), it is somewhere in the PATH (for example ''/usr/local/bin/''), it starts with the line
+
Without a proper package it will not be possible to run executable Python scripts without pre-pending ''python''. The following call would fail:
-
<nowiki>
+
<nowiki>
-
#!/usr/bin/env python
+
$ ./dosomething.py
 +
-sh: ./dosomething.py: Permission denied
</nowiki>
</nowiki>
-
then you can invoke it from the command line, just as any other program.  This however is not exactly what you would call "end-user friendly". 
+
However, using the Python interpreter for calling the script works as expected:
-
Proper packaging of your python software will allow you hand it over to your friends, who will be able to use it as any other Maemo program.
+
<nowiki>
 +
$ python ./dosomething.py
 +
</nowiki>
The next section shows how to package your Python application.
The next section shows how to package your Python application.

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)