Developing MeeGo apps with Python and QML

c#小王子 c#小王子 2021-04-01 1806 Python,编程,QML,MeeGo


Developing MeeGo apps with Python and QML



Introduction


This tutorial will guide you through how to set up a PySide environment on your MeeGo Netbook and then show you some basics through examples, and finally well create a QML UI for an existing application (gPodder) that can be used on MeeGo Netbook and MeeGo Handset.


Why should Iuse Python to develop MeeGo apps?


Low barrier to entry: Python is a very easy to learn language, so you can get quickly up to speed- independent of whether or not you are already familiar with other languages

Garbage collection:You don't have to manually manage the memory of the objects you create-the Python garbage collector takes care of removing no longer needed objects

No compiling: Python is an interpreted language, so you can run your application right after saving the source in an editor. No need to wait for code to compile. This is especiallyimportant on low-powered netbooks. Full access to the Qt libraries: PySide bindings allow access to all modules of Qt. And because it uses the native Qt libraries, library functions run at native (compiled) speed.

Shorter code: In my experience, C++ applications using Qt have about 3 times as much lines of code as the equivalent Python applications-using the same libraries and Qt classes!

Prototyping: Even if you plan on writing a C++ Qt application, Python and PySide are a great combination for quickly prototyping your ideas.This could be useful to prototype a C++ backend of your QML application. Later on, youjust exchange the Python backend with a C++ backend and can reuse the QML files from the Python app.

Development on the go: As Python is an interpreted language, the runtime already contains all the necessary tools to develop applications, so you don't have to install a compiler, development libraries and header files just to create apps-it's instant, and some people even develop Python GUl apps directly on handset devices like the N900.


Links


PySide Homepage: http://www.pyside.org/ MeeGo

Homepage: http://www.meego.com/

PySide Wiki: http/developer.qt.nokia.com/wiki/PySide

Tutorial homepage: http://thp.io/2010/meego-pythonl


Setting up the environment


First, make sure to have MeeGo Netbook installed-either directly on your netbook or in a virtual machine. How to do this is out of scope for this document, so please refer to the MeeGo Wiki.


As you probably want to start developing with PySide right now, and given the agile state of PySide at this moment (lots of bugfixes being integrated before the 1.0release), it's a good idea tobuild PySide from source. This will not be necessary in the future (when PySide packages are hopefully integrated into MeeGo), but you might nevertheless use an up-to-date version for development.


Getting the build scripts


I've created a set of build scripts that will automate the building of PySide from the Git repositories, including installing required build dependencies, so you can get up to speed quickly.


1. Click on the red"Applications" icon on MeeGo

2. Search for"Terminal" and start the application

3. Install Git via"sudo zypper install git"

4. Create a"pyside" folder in your $HOME with"mkdir pyside"

5. Change into the"pyside" folder: "cd pyside"

6. Check out the source:"git clone git://gitorious.org/pyside/buildscripts.git"

7. Change into the"buildscripts" folder:"cd buildscripts"

8. Fetch the sources:"git submodule init"and"git submodule update"

9.Fetching the sources will take a while-grab a coffee or a tea:)


After the buildscripts have been downloaded, you can use them to build PySide for MeeGo Netbook.


Building PySide and installing into $HOME


Now that you have gotten all the sources, you can build PySide for your netbook and install it into your home directory so that it does not conflict with any system-wide installations you might have in place. That's a safe way to install PySide from Git, as you can always just remove it from $HOME or reinstall it as often as you wish without cluttering up your system directories.


1. Open another Terminal (or use the one you still have open from the

previous step)

2. Go into the PySide buildscripts folder:"cd~/pyside/buildscripts"

3.Install the build dependencies:"sudo ./dependencies.meego.sh"

4.Before the next step, make sure to close down any other apps you might

have running-building PySide takes a lot of RAM. If you have problems building PySide, consider adding some RAM or adding a swapfile

5.(started 14;28) Build and install everything using"./build and install"

6.This will take about 2.5 hours (on an Atom single-core netbook)-yes,

that's a lot, but the upside of using Python for development on vour MeeGo netbook is that your applications do not have to be compiled, so instead of a develop-compile-run cycle, your have a develop-run cycle. This is especially nice on low-powered netbooks and saves you time and battery power on the go.


Setting up environment variables


Because we installed PySide into your $HOME, you have to set up some environment variables for that PySide version to become the active one for Python to use. Luckily, the"environment.sh" script in the PySide buildscripts takes care of that. You can either use.


source~/pyside/buildscripts/environment.sh


every time you want to do PySide development, or add this command to your~/.bashrc file, so it gets executed every time you open a shell or terminal window(that's the recommended way to doit, so you don't forget to source the"environment.sh" file when trying out the examples).


Testing the installations


Before we can start to write great PySide apps for MeeGo, let's see if

everything was installed correctly. Fire up another terminal window and enter"python"to start the interactive Python shell. Now, enter"from PySide import OtGui"to checkif the OtGui module was correctly installed. After that, try"from PySide import QtDeclarative"to check if the QtDeclarative module is working. We need the QtGui for basic UI classes (non-QML), and QtDeclarative for loading and displaying OML content.


Basic QML tutorial examples


This section should give you a short overview with code examples on how to do simple things with PySide and OML, More examples can be found on the homepage of this tutorial on http://thp.io/2010/meego-python/





【下载地址】

链接:https://pan.baidu.com/s/1Mi9gtmC7kwKIQZD5ZR2Snw

提取码:8om8





相关文章


Developing MeeGo apps with Python and QML

Developing MeeGo apps with Python and QML


文章热度: 166291
文章数量: 333
推荐阅读

FlashFXP绿色版网盘下载,附激活教程 1926

FlashFxp百度网盘下载链接:https://pan.baidu.com/s/1MBQ5gkZY1TCFY8A7fnZCfQ。FlashFxp是功能强大的FTP工具

Adobe Fireworks CS6 Ansifa绿色精简版网盘下载 1665

firework可以制作精美或是可以闪瞎眼的gif,这在广告领域是需要常用的,还有firework制作下logo,一些原创的图片还是很便捷的,而且fireworks用法简单,配合dw在做网站这一块往往会发挥出很强大的效果。百度网盘下载链接:https://pan.baidu.com/s/1fzIZszfy8VX6VzQBM_bdZQ

navicat for mysql中文绿色版网盘下载 1701

Navicat for Mysql是用于Mysql数据库管理的一款图形化管理软件,非常的便捷和好用,可以方便的增删改查数据库、数据表、字段、支持mysql命令,视图等等。百度网盘下载链接:https://pan.baidu.com/s/1T_tlgxzdQLtDr9TzptoWQw 提取码:y2yq

火车头采集器(旗舰版)绿色版网盘下载 1793

火车头采集器是站长常用的工具,相比于八爪鱼,简洁好用,易于配置。火车头能够轻松的抓取网页内容,并通过自带的工具对内容进行处理。站长圈想要做网站,火车头采集器是必不可少的。百度网盘链接:https://pan.baidu.com/s/1u8wUqS901HgOmucMBBOvEA

Photoshop(CS-2015-2023)绿色中文版软件下载 1916

安装文件清单(共46G)包含Window和Mac OS各个版本的安装包,从cs到cc,从绿色版到破解版,从安装文件激活工具,应有尽有,一次性打包。 Photoshop CC绿色精简版 Photoshop CS6 Mac版 Photoshop CC 2015 32位 Photoshop CC 2015 64位 Photoshop CC 2015 MAC版 Photoshop CC 2017 64位 Adobe Photoshop CC 2018 Adobe_Photoshop_CC_2018 Photoshop CC 2018 Win32 Photoshop CC 2018 Win64

知之

知之平台是全球领先的知识付费平台。提供各个领域的项目实战经验分享,提供优质的行业解决方案信息,来帮助您的工作和学习

使用指南 建议意见 用户协议 友情链接 隐私政策 Powered by NOOU ©2020 知之