(Redirected from Dynamic Menus in PySymbian)

Archived:Dynamic Menus 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}}.

The article is believed to be still valid for the original topic scope.

This code snippet shows how to change menus dynamically in PySymbian.

Article Metadata
Tested with
Devices(s): Nokia N95, Nokia E90
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition
Platform Security
Capabilities: )
Keywords: UI
Created: hurenkam (25 Aug 2008)
Last edited: hamishwillee (31 May 2013)

Code Snippet

Class Application:
def UpdateMenu(self):
def HasWaypoints():
return len(self.waypoints) > 0
def HasTracks():
return len(self.tracks) > 0
def HasOpenTracks():
return len(self.opentracks) > 0
def HasMaps():
return len(self.maps) > 0
def CreateMenu(items):
menu = []
for i in items:
if i[0]():
if len(menu) > 0:
return tuple(menu)
return None
items = [
( HasMaps, u'Open Map', self.OpenMap ),
( HasWaypoints, u'Monitor Waypoint', self.MonitorWaypoint ),
( HasTracks, u'Open Track', self.OpenTrack ),
( HasOpenTracks, u'Close Track', self.CloseTrack ),
menu = [
(u'About', self.About),
) ]
dyn_menu = CreateMenu(items)
if dyn_menu != None:
menu.append( (u'GPS', dyn_menu) )
appuifw.app.menu = menu
def CloseOpenTracks():
self.opentracks = []


Now whenever the precondition changes in the application, you can call UpdateMenu, and the menu is changed accordingly, as is demonstrated in the CloseOpenTracks method.

This page was last modified on 31 May 2013, at 04:03.
53 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.