Here is the latest code with the lambda change:

**** code begin ****

import os
import sys
import menu
import config

from gui import ConfirmBox
from item import Item
from plugin import MainMenuPlugin

class HomeAutomationItem(Item):
def __init__(self, parent):
Item.__init__(self,parent)
self.name = _( 'Home Automation' )
def config(self):
return [('HA_ITEMS',
[ ("Living Room", "Corner Light","On,Off,Dim"),
("Bedroom", "Ceiling Lights","On,Off,Dim") ],
"Home automation items")]
def actions(self):
items = [(self.createMenu, _('Home Automation'))]
return items
def createMenu(self, arg=None, menuw=None):
ha_menu_items=[]
for room in config.HA_ITEMS:
ha_menu_items+=[menu.MenuItem(room[0])]
for device in room[1]:
ha_menu_items+=[menu.MenuItem(device[0])]
for control in device[1]:
ha_menu_items+=[menu.MenuItem(control[0],lambda arg=None, menuw=None: os.system(control[1]))]
ha_menu=menu.Menu("Home Automation", ha_menu_items)
menuw.pushmenu(ha_menu)
menuw.refresh()
class PluginInterface(MainMenuPlugin):
def items(self, parent):
return [ HomeAutomationItem(parent) ]





------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Freevo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-users

Reply via email to