Hello, I would ask You DMM team how in enigma 2 Can we do a new eLabel element?
In Enigma 1:
ASSIGN(lsnr_text, eLabel, "snr_text");
lsnr_text->setText("SNR:");
How We can do new element in enigma 2?
Hello, I would ask You DMM team how in enigma 2 Can we do a new eLabel element?
In Enigma 1:
ASSIGN(lsnr_text, eLabel, "snr_text");
lsnr_text->setText("SNR:");
How We can do new element in enigma 2?
I was trying do this
class InfoBarServiceName:
def __init__(self):
self["CurrentService"] = CurrentService(self.session.nav)
self["Test"] = ("TEXT ON INFOBAR")
Hi!
Well, it's quite easy!
Let's take a little Example
skin = """
<screen position="185,238" size="350,180" title="Wireless Network Tools" >
<widget name="menu" position="10,10" size="330,80" scrollbarMode="showOnDemand" />
<widget name="myowntext" position="10,100" size="330,80" scrollbarMode="showOnDemand" />
</screen>
"""
def __init__(self, session, iface):
list = []
list.append(_("Point 1"))
list.append(_("Point 2"))
list.append(_("Point 3"))
self["menu"] = MenuList(list)
self["myowntext"] = Label(_('MyOwnText!'))
Alles anzeigen
Explanation:
You define "widgets" inside your skin (it doesn't matter if your skin is defined directly inside the code (you have to do that when coding plugins) or inside the skin.xml oder skin_default.xml)!
Then you can fill a widget with content, e.g:
To add additional Elements to your Infobar you need to extend the Infobar (with the widgets you need) in the skin.xml or skin_default.xml file which you can find in /usr/share/enigma2/nameofyourskin .
The important thing is: You cannot simply write text on a widget or fill it with a list/tuple/dict, instead you have to define the widget als "Label", or as MenuList, or whatever you need!
You may ask youself what this _() around the text in "Label(_('MyOwnText!'))" is for, it's there for making strings translatable.
So using "Label('MyOwnText!')" will work, but not be translatable.
You can also see an example of how to create a custom menulist in the code, i think it's pretty self-explaining.
If you got any further questions, feel free to ask!
Thank you so much!
That is it !
enigma Crash Log
------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/enigma2/python/mytest.py", line 560, in ?
runScreenTest()
File "/usr/lib/enigma2/python/mytest.py", line 490, in runScreenTest
runNextScreen(session, screensToRun)
File "/usr/lib/enigma2/python/mytest.py", line 486, in runNextScreen
session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
File "/usr/lib/enigma2/python/mytest.py", line 267, in openWithCallback
dlg = self.open(screen, *arguments, **kwargs)
File "/usr/lib/enigma2/python/mytest.py", line 277, in open
dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
File "/usr/lib/enigma2/python/mytest.py", line 200, in instantiateDialog
return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
File "/usr/lib/enigma2/python/mytest.py", line 225, in doInstantiateDialog
readSkin(dlg, None, dlg.skinName, desktop)
File "/usr/lib/enigma2/python/skin.py", line 329, in readSkin
raise SkinError("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
SkinError: component with name 'myowntext' was not found in skin of screen 'InfoBar'!
------------------------------------------------------------
Alles anzeigen
in In my skin.xml
<widget name="myowntext" render="Label" position="345,86" zPosition="2" size="290,20" font="Regular;18" valign="top" halign="right" transparent="1" foregroundColor="LabelForegroundText_1"/>
Source:
And inside my simple code
class MySkin(Screen):
skin = """
<screen position="180,100" size="300,410" title="Tracer Menu" >
<widget name="menu" position="10,10" size="490,390" scrollbarMode="showOnDemand" />
</screen>"""
def __init__(self, session, args = 0):
self.skin = MySkin.skin
self.session = session
Screen.__init__(self, session)
self.menu = args
list = []
list.append((_("1st menu"), "0_1"))
self["actions"] = ActionMap(["WizardActions", "DirectionActions"],{"ok": self.go,"back": self.close,}, -1)
self["myowntext"] = Label(_('MyOwnText!'))
def go(self):
returnValue = self["menu"].l.getCurrentSelection()[1]
if returnValue is not None:
if returnValue is "o_1":
self.session.open(1)
Alles anzeigen
For example
my "wdiget" it will be name of somethink from file
myfile = os.path.exists('/tmp/text.info'
if myfile:
myfile = file('/tmp/text.info', 'r')
thisfile = myfile.read()
myfile.close()
self["myowntext"] = Label(thisfile)
else:
self["myowntext"] = Label(_('Sorry file does not exist!'))
And I can not this widgets shows in Infobar it should re-read file like eTimer in enigma 1
myfile = file('/tmp/text.info', 'r')
Thx for Help
The widget is inside the Infobar xml Segment in skin.xml???
yes it is
<screen name="InfoBar" position="0,0" size="720,576" flags="wfNoBorder" title="InfoBar">
<eLabel position="0,0" zPosition="-3" size="720,576" backgroundColor="transparent" />
....
<widget name="myowntext" render="Label" position="345,86" zPosition="2" size="290,20" font="Regular;18" valign="top" halign="right" transparent="1" foregroundColor="LabelForegroundText_1"/>
</screen>
Because it is eLabel only for infbar
Is it need modification on Infobar.py, Isn't it ?
Mayby my mistake is that skin.xml from
/usr/share/enigma2/skin.xml
I changed it - i put inside Nemesis Blue, to have it as default, but all files are right.
you have to use the skin.xml file of the skin you want to change!!
Yes, I know
I have just checked it with Nemesis.Blue.Extended
That same problem
"myowntext not found in InfoBar"
So,
Label in infobar shouldn't be declared in Infobar.py ?
Ok I
added
Infobar.py
and
MY_Infobar.py
from enigma import *
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
from Components.FileList import FileEntryComponent, FileList
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Components.ActionMap import NumberActionMap
from Components.Header import Header
from Components.Button import Button
from Components.Label import Label
from Components.config import config, ConfigSubsection, ConfigSelection, ConfigSubList, getConfigListEntry, KEY_LEFT, KEY_RIGHT, KEY_OK
from Components.ConfigList import ConfigList
from Components.Pixmap import Pixmap
import os
class MYInfoBarMYName(Screen):
def __init__(self, session):
Screen.__init__(self, session)
self["myowntext"] = Label(_('MyOwnText!'))
Alles anzeigen
but nothink image no boot...
The strangest is this that enigma didn't create CrashLog on /hdd after this...
sure, you can do your changes directyl in infobar.py
Yes,
but as you see somewhere i bug i think, image no boot anymore
class MYInfoBarMYName(Screen):
def __init__(self, session):
Screen.__init__(self, session)
self["myowntext"] = Label(_('MyOwnText!'))
no log of crash... can u give onemore example with eLabel in infobar Skin Section?
keep your stuff inside the infobar...
It is inside infobar section in Nemesis.extended.../skin.xml
<screen name="InfoBar" position="0,0" size="720,576" flags="wfNoBorder" title="InfoBar">
<eLabel position="0,0" zPosition="-3" size="720,576" backgroundColor="transparent" />
....
<widget name="myowntext" render="Label" position="345,86" zPosition="2" size="290,20" font="Regular;18" valign="top" halign="right" transparent="1" foregroundColor="LabelForegroundText_1"/>
Alles anzeigen
Please can u give one more example with use eLabel in InfoBar Skin Section ?
insde the Infobar.py!!!
First try to geht things working without inherting other classes and THEN think about inheriting...
Ok I get it worked in that Same class!
Now try to put inside another class...
EDIT
Ok DONE in another Classs also!!
thx m8