×
Namespaces

Variants
Actions

Archived:How to use layout in PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

This article contains a simple example code of appuifw.app.layout in PySymbian.

Article Metadata
Tested with
Devices(s): N82,N95
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: appuifw, layout
Created: aaaaapo (27 Jan 2009)
Last edited: hamishwillee (28 Jun 2012)


Code

The main script is below.

appuift_app_layout_example.py

# Aapo Rista 2009 (public domain)
 
import appuifw
import e32
import TopWindow
import graphics
 
def show_layout_window(text, size, position, color):
"""Show a TopWindow instance in 'position'."""
topwin = TopWindow.TopWindow()
topwin.size = size
topwin.position = position
topwin.corner_type = 'square'
topwin.background_color = 0x0000ff
topwin.shadow = 0
img = graphics.Image.new(size)
img.clear(fill=color)
img.text((0, 15), text, font=(u"S60 Sans", 15), fill=0x000000)
topwin.add_image(img, (0,0))
topwin.show()
return topwin
 
def get_layout_ids():
"""Put all Esomething attributes found from appuifw to a list."""
layout_ids = []
for layout in dir(appuifw):
if layout.startswith("E"):
layout_ids.append(unicode(layout))
return layout_ids
 
def show_layout():
"""Show requested appuifw.Esomething on the screen."""
layout = layout_ids[layout_listbox.current()]
text = layout
try:
(size, position) = appuifw.app.layout(getattr(appuifw, layout))
topwin = show_layout_window(text, size, position, 0xffff00)
except:
topwin = show_layout_window("FAILED: " + text, (150, 50), (20, 100), 0xff0000)
e32.ao_sleep(0.5)
topwin.hide()
 
def exit_key_handler():
app_lock.signal()
 
layout_ids = get_layout_ids()
layout_listbox = appuifw.Listbox(layout_ids, show_layout)
appuifw.app.body = layout_listbox
app_lock = e32.Ao_lock()
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()

References

This page was last modified on 28 June 2012, at 09:17.
55 page views in the last 30 days.
×