Hello everybody,
I'm, writing my first Python Plugin
where is the standard directory to create a configuration file?
Is it possible to get Documentation in english?
Basic information on writing python plugins
-
-
The most plugins have their configs in /etc/enigma2/settings using Components.config. Some others have own config-files... the most of them in /etc.
Here is a little docu: http://dreamboxupdate.com/cgi-…igma2/doc/PLUGINS?rev=1.6
-
Thanks for your answer.
I've started yesterday from that example and I'm trying something more complicated.Do you have an example on how it's the simplest way to write a config file?
Suppose I have on the screen a single line, with the left/right remote control button I choose between some fixed values.
Once decided the right values, I would like to write the entry into a config file.I'm trying some reverse engineering on WebInterface Plugin, but it's really complicated, I can't see any file opening or wathever, it looks like all embedded into something I can't recognize...
Somehow it looks like the configuration is managed by this "ConfigList.py" module. but how? and how to communicate with this module?At least It would be wonderfull to get a real Complete Documentation
-
A small example can be found in my mosaic plugin:
CLICKconfig_limits = (3, 30)
config.plugins.Mosaic = ConfigSubsection()
config.plugins.Mosaic.countdown = ConfigInteger(default=5, limits=config_limits)
...
config.plugins.Mosaic.countdown.value = 5
config.plugins.Mosaic.countdown.save()Other example can be found here in my RS-Downloader plugin:
CLICK...or in many many other plugins you can find here:
CLICK -
Ok, let's talk about the mosaic plugin
config_limits = (3, 30)
this is a variable, I think 3 and 30 are 2 values of this config_limits(some kind of an array large 2) are they representing a range value?config.plugins.Mosaic = ConfigSubsection()
what's this? some kind of a structural call? config.plugins.Mosaic is the name you have choose to identify your configurations? ConfigSubsection() is an Enigma2 function...?config.plugins.Mosaic.countdown = ConfigInteger(default=5, limits=config_limits)
This is an integer, default value is 5, the range is specified by config_limits, OK?config.plugins.Mosaic.countdown.save()
This is the statement to save the countdown value, OK?MANY THANKS!!!
-
>>config_limits = (3, 30)
>this is a variable, I think 3 and 30 are 2 values of this config_limits(some kind of an array large 2) are they representing a range value?
You have the option to use limits in ConfigInteger. 3 is the minimal value and 30 the maximum one.>>config.plugins.Mosaic = ConfigSubsection()
>what's this? some kind of a structural call? config.plugins.Mosaic is the name you have choose to identify your configurations? ConfigSubsection() is an Enigma2 function...?
ConfigSubsection is a class in Components.config. It stores your config-items and the config-values.>>config.plugins.Mosaic.countdown = ConfigInteger(default=5, limits=config_limits)
>This is an integer, default value is 5, the range is specified by config_limits, OK?
Yepp.>>config.plugins.Mosaic.countdown.save()
>This is the statement to save the countdown value, OK?
Yepp.enigma2 provides you a lot of config-stuff. Just have a look at the config.py file in /usr/lib/enigma2/python/Components. It is not soooo complicated
-
OK!!!100% understood!!! I'm able to go ahead...
-
I really have trouble now,
I'm trying to follow your RSS plugin.
I have created a second py to launch the configuration screen, but I can't figure out this step:
class RSConfig(ConfigListScreen, TitleScreen):"
why 2 parameters? why the second one?
could you also please explain the meaning of the statementTitleScreen.__init__(self, session)
or
ConfigListScreen.__init__(self, list)
anyway, if you can point me to a documentation it would be wonderfull
-
This is the error I get:
Screen Plugins.Extensions.StayUP.StayUPConfigModule.StayUPConfigFunction((), {}): <type 'exceptions.AttributeError'>
Traceback (most recent call last):
File "/usr/lib/enigma2/python/mytest.py", line 222, in create
return screen(self, *arguments, **kwargs)
File "/usr/lib/enigma2/python/Plugins/Extensions/StayUP/StayUPConfigModule.py", line 27, in __init__
ConfigListScreen.__init__(self, session)
File "/usr/lib/enigma2/python/Components/ConfigList.py", line 129, in __init__
}, -1) # to prevent left/right overriding the listbox
AttributeError: StayUPConfigFunction instance has no attribute '__setitem__'
open /dev/dbox/fp0 for wakeup timer clear failed!(No such file or directory)
Traceback (most recent call last):
File "/usr/lib/enigma2/python/Components/ActionMap.py", line 46, in action
res = self.actions[action]()
File "/usr/lib/enigma2/python/Plugins/Extensions/StayUP/plugin.py", line 65, in go
self.session.open(StayUPConfigFunction)
File "/usr/lib/enigma2/python/mytest.py", line 296, in open
dlg.isTmp = True
AttributeError: 'NoneType' object has no attribute 'isTmp'
(PyObject_CallObject(<bound method ActionMap.action of <Components.ActionMap.ActionMap instance at 0x2f1b4b98>>,('WizardActions', 'ok')) failed) -
main py
<cut>
from StayUPConfigModule import StayUPConfigFunction
<cut>
list.append((_("Configure"), "config"))
<cut>
if returnValue is "config":
self.session.open(StayUPConfigFunction)
<cut>root@dm800:/usr/lib/enigma2/python/Plugins/Extensions/StayUP# more StayUPConfigModule.py
#
from Components.ActionMap import ActionMap
from Components.config import config, ConfigText, ConfigYesNo, ConfigClock, ConfigSubsection, getConfigListEntry
from Components.ConfigList import ConfigListScreen
from Components.Label import Label
from time import time##############################################################################
config.plugins.StayUP = ConfigSubsection()
config.plugins.StayUP.onoff = ConfigYesNo(default=True)##############################################################################
class StayUPConfigFunction(ConfigListScreen):
skin = """
<screen position="80,170" size="560,270" title="RS Downloader">
<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent=1" />
<widget name="config" position="0,45" size="560,220" scrollbarMode="showOnDemand" />
</screen>"""def __init__(self, session):
self.skin = StayUPConfigFunction.skin
self.session = session
ConfigListScreen.__init__(self, session)self["key_green"] = Label(_("Save"))
list = []
list.append(getConfigListEntry(_("Enable Plugin:"), config.plugins.StayUP.onoff))
ConfigListScreen.__init__(self, list)self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "cancel": self.exit}, -1)
def save(self):
for x in self["config"].list:
x[1].save()
self.close()def exit(self):
for x in self["config"].list:
x[1].cancel()
self.close()root@dm800:/usr/lib/enigma2/python/Plugins/Extensions/StayUP#
-
Try this one.
You had an error in the skin part, and you need the Screen class as well, because you wanna show something on screen.
Good luck
-
Thanks!!!
I have two questions.
1)StayUPConfigFunction(ConfigListScreen, Screen)
those two arguments means:
ConfigListScreen - this is the way we fill the screen
Screen - the screen itself2)May I go back to "WHERE_PLUGINMENU"? or there is a specific reason you choosed the Extension Menu?
p.s.: I've also asked for documentation in the DM8000 VIP CLUB without success , right now you're my only resource.
(http://www.dm8000-vip.de/forum…age=Thread&threadID=2414&) -
ConfigListScreen handles your config-screen... actions and so on. As you can see, there is no function for left/right buttons and so on. Everything is handled in this class.
And Screen is there to show your plugin on the screen.I choosed the Extension-menu only to be able to start your plugin to see if everything is fine. You can of course choose an other place for that There are a lot of options in the PluginDescriptor.
-
Ok,
- I was able to transform the multi entry into an array using the list[]
- I was able to use the ConfigSelection to change yes/no into a list of custom valuesfor the ConfigSelection, I've a question:
config.plugins.StayUP.PiconType = ConfigSelection(
[("1ST Argument value", 1ST Argument text"),
("2ND Argument value", "2ND Argument text")
], "1ST Argument value")What's the first and the second arguments means? Is Value and Text as I've in my example? The last 1ST Argument value is the default value?
I've another important question, how can I register a TIMER entry to run a particular function in the plugin?
I see in your RS plugin that you use the "ConfigClock(default=time())" function. But, how to you control what's has to be run in that particular time()? -
I've added the blue button to "Execute" something, I'm trying to get the current value related to the position in the menu:
I would like only to print the selected item value:
def execute(self):
selected = self["config"].getCurrent()
self.session.open(MessageBox, (_("Blue Key Pressed %s") % selected), MessageBox.TYPE_INFO)it give me an error:
Traceback (most recent call last):
File "/usr/lib/enigma2/python/Components/ActionMap.py", line 46, in action
res = self.actions[action]()
File "/usr/lib/enigma2/python/Plugins/Extensions/StayUP/plugin.py", line 48, in execute
self.session.open(MessageBox, (_("Blue Key Pressed %s") % selected), MessageBox.TYPE_INFO)
TypeError: not all arguments converted during string formatting
(PyObject_CallObject(<bound method ActionMap.action of <Components.ActionMap.ActionMap instance at 0x2f18c738>>,('ColorActions', 'blue')) failed) -
I'm not an expert but you can try it like this:
self.session.open(MessageBox, (_("Blue Key Pressed %s") % str(selected)), MessageBox.TYPE_INFO)
-
it worked
-
config.plugins.StayUP.PiconType = ConfigSelection(
[("1ST Argument value", 1ST Argument text"),
("2ND Argument value", "2ND Argument text")
], "1ST Argument value")What's the first and the second arguments means? Is Value and Text as I've in my example? The last 1ST Argument value is the default value?
From my test this quoted text is OK
-
so...I do I menage the Timer Entry? May I add in the Timer some Class to Run?