2014-05-27, 10:23
I'm a bit confused by this, so would appreciate some comments from anyone who's experienced something similar.
I'm putting together a service that displays live football scores updates (hoping to get it finished before the World Cup!). As it's running as I service I want the user to be able to toggle whether or not to show goal notifications (e.g. if my wife is watching some American teen drama she won't be particularly interested to know that Costa Rica have taken a shock lead against England).
I've got a setting in the service that is used for this purpose. However, as I'd like to be able to be able to do this by pressing a button, there's a short script that toggles this setting without the need to go to the addon settings page. This works fine from anywhere except if I'm viewing the service's settings page, at which point the setting won't change.
Likewise, I have some methods to select/reset stored data (e.g. list of competitions that the user wants to follow). This needs to be called via an "action"-type setting method. However, the same issue applies here i.e. I can't store the setting if the user is in the settings screen, but I need to be there to call these methods (I don't want to bind everything to separate commands).
The script that tries to set these settings looks a bit like this:
The resetLeagues method is called from the settings page, toggleNotification is called via a parameter to a script. Neither works when user is in the settings page, both work if not in that page.
Does anyone know how I can get this to work?
I'm putting together a service that displays live football scores updates (hoping to get it finished before the World Cup!). As it's running as I service I want the user to be able to toggle whether or not to show goal notifications (e.g. if my wife is watching some American teen drama she won't be particularly interested to know that Costa Rica have taken a shock lead against England).
I've got a setting in the service that is used for this purpose. However, as I'd like to be able to be able to do this by pressing a button, there's a short script that toggles this setting without the need to go to the addon settings page. This works fine from anywhere except if I'm viewing the service's settings page, at which point the setting won't change.
Likewise, I have some methods to select/reset stored data (e.g. list of competitions that the user wants to follow). This needs to be called via an "action"-type setting method. However, the same issue applies here i.e. I can't store the setting if the user is in the settings screen, but I need to be there to call these methods (I don't want to bind everything to separate commands).
The script that tries to set these settings looks a bit like this:
Code:
_A_ = xbmcaddon.Addon("service.bbclivefootballscores")
_S_ = _A_.getSetting
def resetLeagues():
'''Clears all saved league IDs.
Useful if IDs change leading to duplicate menu entries.
'''
_A_.setSetting(id="watchedleagues",value="")
_A_.setSetting(id="masterlist",value="")
def toggleNotification():
'''Toggles score notifications on or off.'''
state = not (_S_("Alerts") == "true")
Notify("BBC Football Scores", "Alerts are now %s" % ("on" if state else "off"))
_A_.setSetting(id="Alerts", value=str(state).lower())
The resetLeagues method is called from the settings page, toggleNotification is called via a parameter to a script. Neither works when user is in the settings page, both work if not in that page.
Does anyone know how I can get this to work?