Hi,
I'm new in this and I've been working on a small plugin, I'm facing a problem with opening a screen with message box. Enigma2 is carshing and I get the following on the error log:
Code
Traceback (most recent call last):
File "/home/tux/dm7025/dm7025_07/build/tmp/work/gemini2-3.8.0+cvs20081009-r22/image/usr/lib/enigma2/python/Components/ActionMap.py", line 46, in action
File "/usr/lib/enigma2/python/Plugins/Extensions/NTPUpdateManager/plugin.py", line 54, in selCountry
self.session.open(MessageBox, _("NTP Update Manager:\nNTP server %s is activated" % ((ntpServer))), MessageBox.TYPE_INFO, timeout = 5)
File "/usr/lib/enigma2/python/mytest.py", line 281, in open
dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
File "/usr/lib/enigma2/python/mytest.py", line 216, in instantiateDialog
return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
File "/usr/lib/enigma2/python/mytest.py", line 247, in doInstantiateDialog
dlg.applySkin()
File "/home/tux/dm7025/dm7025_07/build/tmp/work/gemini2-3.8.0+cvs20081009-r22/image/usr/lib/enigma2/python/Components/GUISkin.py", line 90, in applySkin
File "/home/tux/dm7025/dm7025_07/build/tmp/work/gemini2-3.8.0+cvs20081009-r22/image/usr/lib/enigma2/python/Components/GUISkin.py", line 26, in createGUIScreen
File "/home/tux/dm7025/dm7025_07/build/tmp/work/gemini2-3.8.0+cvs20081009-r22/image/usr/lib/enigma2/python/Components/GUIComponent.py", line 108, in GUIcreate
File "/home/tux/dm7025/dm7025_07/build/tmp/work/gemini2-3.8.0+cvs20081009-r22/image/usr/lib/enigma2/python/Components/VariableText.py", line 24, in postWidgetCreate
TypeError: in method 'eLabel_setText', argument 2 of type 'std::string const &'
(PyObject_CallObject(<bound method ActionMap.action of <Components.ActionMap.ActionMap instance at 0x2f4a2fd0>>,('SetupActions', 'ok')) failed)
Alles anzeigen
Here is the code, note that the message box is on line 54: (I tried to replace it with session.open and move the call back function under but that did not help)
Python
from Screens.Screen import Screen
from Plugins.Plugin import PluginDescriptor
from Components.ActionMap import ActionMap
from Components.MenuList import MenuList
import xml.dom.minidom
import os
from Screens.MessageBox import MessageBox
class SelectCountry(Screen):
skin = """
<screen position="90,95" size="560,430" title="NTP Update Manager" >
<widget name="menu" position="10,0" size="550,420" scrollbarMode="showOnDemand" />
</screen>
"""
def __init__(self, session, xmlparse, selection):
self.skin = SelectCountry.skin
Screen.__init__(self,session)
self.xmlparse = xmlparse
self.selection = selection
list = []
for contenant in self.xmlparse.getElementsByTagName("contenant"):
if contenant.getAttribute("cont").encode("utf8") == self.selection:
for country in contenant.getElementsByTagName("country"):
list.append(country.getAttribute("name").encode("utf8"))
self["menu"] = MenuList(list)
self["actions"] = ActionMap(["SetupActions"],
{
"ok" : self.selCountry,
"cancel" : self.close_session,
}, -2)
def selCountry(self):
if os.path.isfile("/etc/init.d/ntpupdate.sh"):
selection_country = self["menu"].getCurrent()
for contenant in self.xmlparse.getElementsByTagName("contenant"):
if contenant.getAttribute("cont").encode("utf8") == self.selection:
for country in contenant.getElementsByTagName("country"):
if country.getAttribute("name").encode("utf8") == selection_country:
ntpServer = country.getElementsByTagName("ntp")[0].childNodes[0].data
print "ntp server name is: ", ntpServer
cmd = "echo " + ntpServer + " >/etc/ntpserver"
os.system(cmd)
cmd = '/etc/init.d/ntpupdate.sh start'
os.system(cmd)
else:
self.close_session
self.session.openWithCallback(self.close_session, MessageBox, _("NTP Update Manager:\nNTP server %s is activated" % ((ntpServer))), MessageBox.TYPE_INFO, timeout = 5)
def close_session(self):
self.close()
class NTPManager(Screen):
skin = """
<screen position="90,95" size="560,430" title="NTP Update Manager" >
<widget name="menu" position="10,0" size="550,420" scrollbarMode="showOnDemand" />
</screen>
"""
def __init__(self, session):
self.skin = NTPManager.skin
Screen.__init__(self,session)
list = []
xmlfile = "/usr/lib/enigma2/python/Plugins/Extensions/NTPUpdateManager/ntpurls.xml"
if os.path.isfile(xmlfile):
xmlparse = xml.dom.minidom.parse(xmlfile)
for contenant in xmlparse.getElementsByTagName("contenant"):
list.append(contenant.getAttribute("cont").encode("utf8"))
self.xmlparse = xmlparse
self["menu"] = MenuList(list)
self["actions"] = ActionMap(["SetupActions"],
{
"ok" : self.selContenant,
"cancel" : self.close,
}, -2)
else:
self.close
def selContenant(self):
selection = self["menu"].getCurrent()
self.session.open(SelectCountry, self.xmlparse, selection)
def main(session, **kwargs):
session.open(NTPManager)
def Plugins(**kwargs):
return PluginDescriptor(
name="NTP Update Manager",
description=_("Select the NTP server and start NTPupdate"),
where = [ PluginDescriptor.WHERE_EXTENSIONSMENU, PluginDescriptor.WHERE_PLUGINMENU ],
icon = "plugin.png", fnc = main)
Alles anzeigen
Anyone could tell me why is it failing to open the screen?