How to create new element in skin ?

  • 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")

    • Offizieller Beitrag

    Hi!


    Well, it's quite easy!
    Let's take a little Example



    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)!

    Code
    <widget name="myowntext" ..... >


    Then you can fill a widget with content, e.g:

    Code
    self["myowntext"] = Label(_('MyOwnText!'))


    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!

  • enigma Crash Log



    in In my skin.xml


    Code
    <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




    For example



    my "wdiget" it will be name of somethink from file



    Code
    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 :frowning_face: it should re-read file like eTimer in enigma 1


    myfile = file('/tmp/text.info', 'r')


    Thx for Help

    Einmal editiert, zuletzt von tracer ()

  • 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 :smiling_face:



    Is it need modification on Infobar.py, Isn't it ?

    Einmal editiert, zuletzt von tracer ()

  • 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.

  • Ok I


    added


    Infobar.py


    Python
    from MY.MY_infobar import MYInfoBarMYName


    Code
    class InfoBar(...............all orginal...  , MYInfoBarMYName ):


    Code
    for x in HelpableScreen, \
    ..... all orginal... , MYInfoBarMYName:



    and


    MY_Infobar.py






    but nothink :frowning_face: image no boot...

  • 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?

  • It is inside infobar section in Nemesis.extended.../skin.xml





    Please can u give one more example with use eLabel in InfoBar Skin Section ?