-#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
profiles = self.profileManager.getProfilesList()
for pr in profiles:
+ #pr is a profile path
+ receiver = self.activateProfileAction(pr)
pr = os.path.basename(pr)
menuItem_Profile = self.menuProfiles.addAction(pr)
-
#Using lambda function to pass additional arguments to the function, in this case the path of the profile
- receiver = lambda pr=pr: self.profileManager.activateProfile(pr)
self.connect(menuItem_Profile, SIGNAL('triggered()'), receiver)
#set menu item ToolTip
menuItem_Profile.setToolTip("Activate profile: "+pr)
self.menuProfiles.activateWindow()
self.menuProfiles.popup(QtGui.QCursor.pos())
+ def activateProfileAction(self, pr):
+ """ Returns a callable to be passed as an action for the switching profile mechanism
+ to self.connect(menuItem_Profile...
+ It compiles a function with a profile name as argument and also handle the displaying of errors."""
+
+ def f():
+ try:
+ self.profileManager.activateProfile(pr)
+ except AppError, e:
+ self.showError(str(e))
+ return f
+
def addProfile(self):
""" Gui frontend to add a new Profile, it requests the user a profile name
through a QInputDialog and creates a new profile with the help of the ProfHandler embedded in the Gui """