Python
From Openmoko
(link mokomenu) |
|||
(11 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Languages}} | ||
'''Python''' is a programming language which is applicable to scripting phone functionalities and graphical user interfaces. Currently, at least [[SettingsGUI]], [[SMSTool]] and [http://pavelmachek.livejournal.com/42672.html MokoMenu] use it. There is also [[Python ncurses]] for character user interfaces. [[Manually using Bluetooth]] is partially based on using Python. | '''Python''' is a programming language which is applicable to scripting phone functionalities and graphical user interfaces. Currently, at least [[SettingsGUI]], [[SMSTool]] and [http://pavelmachek.livejournal.com/42672.html MokoMenu] use it. There is also [[Python ncurses]] for character user interfaces. [[Manually using Bluetooth]] is partially based on using Python. | ||
Line 9: | Line 10: | ||
python-core python-misc python-lang python-subprocess python-threading etc. | python-core python-misc python-lang python-subprocess python-threading etc. | ||
− | + | ETK/EFL applications need the following binary packages too: | |
+ | python-etk python-efl | ||
+ | |||
+ | GTK applications need the following binary packages too: | ||
python-pygtk python-pycairo python-pygobject | python-pygtk python-pycairo python-pygobject | ||
− | {{note|These packages take up a considerable | + | {{note|These packages take up a considerable amount of space (several megabytes). Make sure that you have enough free space or install the packages to the media card as explained in [[package management]].}} |
=== Missing === | === Missing === | ||
− | Parts of the | + | Parts of the Openmoko platform are not available in python yet, including gconf and evolution data server. python-openmoko is in the works for [[gsmd]] access etc. A recipe for PyWebKitGtk |
is at [http://bugs.openembedded.org/show_bug.cgi?id=3028 OpenEmbedded bug #3028]. | is at [http://bugs.openembedded.org/show_bug.cgi?id=3028 OpenEmbedded bug #3028]. | ||
Line 23: | Line 27: | ||
* [[Application Development Crash Course#Adding Python scripts as applications]] | * [[Application Development Crash Course#Adding Python scripts as applications]] | ||
* [[Wishlist:BuiltInScriptingLanguage]] | * [[Wishlist:BuiltInScriptingLanguage]] | ||
+ | * [[Pexpect]] a pure Python module for spawning child applications | ||
+ | == Simple Example Scripts == | ||
+ | === Minimal ETK gui === | ||
+ | See also [[EFL_Documentation]] for more links and examples. | ||
+ | <pre> | ||
+ | import etk | ||
+ | |||
+ | #create a button (not yet on any window) | ||
+ | b = etk.Button(label="Hello") | ||
+ | |||
+ | #create a (nonvisible) window and put the button on the window | ||
+ | w = etk.Window(title="Hello", child=b) | ||
+ | |||
+ | #create a silly callback function | ||
+ | def hello(target): | ||
+ | print 'Hello World' | ||
+ | etk.main_quit() | ||
+ | |||
+ | #make the button call the callback when pressed | ||
+ | b.on_clicked(hello) | ||
+ | |||
+ | #make the window display | ||
+ | w.show_all() | ||
+ | |||
+ | #start processing screen events | ||
+ | etk.main() | ||
+ | </pre> | ||
+ | |||
+ | === Minimal GTK gui === | ||
+ | import gtk | ||
+ | |||
+ | #create a (nonvisible) window | ||
+ | w = gtk.Window() | ||
+ | |||
+ | #create a button (not yet on any window) | ||
+ | b = gtk.Button('Hello') | ||
+ | |||
+ | #put the button on the window | ||
+ | w.add(b) | ||
+ | |||
+ | #create a silly callback function | ||
+ | def hello(target): | ||
+ | print 'Hello world' | ||
+ | exit() | ||
+ | |||
+ | #make the button call the callback when pressed | ||
+ | b.connect('clicked', hello) | ||
+ | |||
+ | #make the window display | ||
+ | w.show_all() | ||
+ | |||
+ | #start processing screen events | ||
+ | gtk.main() | ||
− | [[Category:Developer]] | + | [[Category:Application Developer]] |
Latest revision as of 12:58, 29 November 2009
Languages: |
English • العربية • Български • Česky • Dansk • Deutsch • Esperanto • Eesti • Español • فارسی • Suomi • Français • עברית • Magyar • Italiano • 한국어 • Nederlands • Norsk (bokmål) • Polski • Português • Română • Русский • Svenska • Slovenčina • Українська • 中文(中国大陆) • 中文(台灣) • Euskara • Català |
Python is a programming language which is applicable to scripting phone functionalities and graphical user interfaces. Currently, at least SettingsGUI, SMSTool and MokoMenu use it. There is also Python ncurses for character user interfaces. Manually using Bluetooth is partially based on using Python.
Contents |
[edit] Environment
Source packages for Python contained in OpenEmbedded include:
python python-pygtk python-pycairo python-pygobject python-dbus
Binary packages for Python are not officially built yet but at least ScaredyCat's repositories provide them:
python-core python-misc python-lang python-subprocess python-threading etc.
ETK/EFL applications need the following binary packages too:
python-etk python-efl
GTK applications need the following binary packages too:
python-pygtk python-pycairo python-pygobject
NOTE: These packages take up a considerable amount of space (several megabytes). Make sure that you have enough free space or install the packages to the media card as explained in package management. |
[edit] Missing
Parts of the Openmoko platform are not available in python yet, including gconf and evolution data server. python-openmoko is in the works for gsmd access etc. A recipe for PyWebKitGtk is at OpenEmbedded bug #3028.
[edit] See also
- Application Development Crash Course#Adding Python scripts as applications
- Wishlist:BuiltInScriptingLanguage
- Pexpect a pure Python module for spawning child applications
[edit] Simple Example Scripts
[edit] Minimal ETK gui
See also EFL_Documentation for more links and examples.
import etk #create a button (not yet on any window) b = etk.Button(label="Hello") #create a (nonvisible) window and put the button on the window w = etk.Window(title="Hello", child=b) #create a silly callback function def hello(target): print 'Hello World' etk.main_quit() #make the button call the callback when pressed b.on_clicked(hello) #make the window display w.show_all() #start processing screen events etk.main()
[edit] Minimal GTK gui
import gtk #create a (nonvisible) window w = gtk.Window() #create a button (not yet on any window) b = gtk.Button('Hello') #put the button on the window w.add(b) #create a silly callback function def hello(target): print 'Hello world' exit() #make the button call the callback when pressed b.connect('clicked', hello) #make the window display w.show_all() #start processing screen events gtk.main()