Namespaces
Variants
Actions
(Redirected from Dynamic Menus in PySymbian)

Archived:Dynamic Menus in PySymbian

Jump to: navigation, search
Archived.png
Archived: 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

Compatibility
Platform(s): S60 1st Edition, S60 2nd Edition, S60 3rd Edition

Platform Security
Capabilities: )

Article
Keywords: UI
Created: hurenkam (25 Aug 2008)
Last edited: hamishwillee (08 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]():
menu.append((i[1],i[2]))
if len(menu) > 0:
return tuple(menu)
else:
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 = []
self.UpdateMenu()

Note

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 8 May 2013, at 08:16.
282 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved