Jump to content


Photo

Button() and Label(), PLi opinion.


  • Please log in to reply
465 replies to this topic

#1 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 13 January 2018 - 13:36

Button() and Label()...

 

People seem to use these interchangeably and it is a skinner's nightmare. Shouldn't Button() be used for buttons, and Label() used for labels? For example in setup.py the buttons use Label(). Why is this allowed? Or is it just down to crap inherited code?

 

Is there somehow the two could be combined so the same skin code could be used for both, rather than the current situation with all the duplication in the skin.


Edited by Huevos, 13 January 2018 - 13:39.


Re: Button() and Label(), PLi opinion. #2 twol

  • Senior Member
  • 151 posts

+2
Neutral

Posted 13 January 2018 - 14:55

Couldn`t agree more - especially for us „dabblers“
I can take a piece of code that uses labels in one image, & find it only works if it I change it to buttons in another image ... totally confusing!!

Re: Button() and Label(), PLi opinion. #3 IanSav

  • Senior Member
  • 264 posts

+15
Neutral

Posted 14 January 2018 - 06:03

Hi,

 

There is also code that implements buttons as "StaticText" objects.  More complication in all the mess.

 

Regards,

Ian.



Re: Button() and Label(), PLi opinion. #4 IanSav

  • Senior Member
  • 264 posts

+15
Neutral

Posted 14 January 2018 - 06:58

Hi,

 

In the OverlayHD skin I have taken to trying to support all type of button definitions by using something like:

<widget name="key_red" position="172,670" size="225,35" backgroundColor="ButtonRed" font="ButtonFont;20" conditional="key_red" foregroundColor="ButtonText" halign="center" transparent="1" valign="center" zPosition="+1" />
<widget source="key_red" render="Label" position="172,670" size="225,35" backgroundColor="ButtonRed" conditional="key_red" font="ButtonFont;20" foregroundColor="ButtonText" halign="center" transparent="1" valign="center" zPosition="+1" />

This works relatively well but breaks down when conflicting programmatic changes are made to a button's text.  When this happens the text from the two change mechanisms overlaps.  :(

 

On the Beyonwiz build one of my fellow developers wrote some code to synchronise the "Button", "Label" and "StaticText" objects to eliminate the problem.  This code change was considered a hack and not implemented in OpenViX where I tried to offer the work-around.

 

After subsequent discussions with some OpenViX people it was suggested I bring the discussions here to see if we can all agree on a solution and a way forward.

 

Regards,

Ian.



Re: Button() and Label(), PLi opinion. #5 IanSav

  • Senior Member
  • 264 posts

+15
Neutral

Posted 14 January 2018 - 07:06

Hi,

 

I should also add on the Beyonwiz build and in my OverlayHD skin in particular I combined ALL the colour buttons into what is effectively a single panel.  All four colours are represented but each colour is made conditional on the definition of that colour text in the code.  You will see this in the XML code fragment above.

 

In OverlayHD this means that ALL screens share a single colour button panel.  This seriously reduces the size and complication of the skin.

 

If you want to check out what I have done in OverlayHD then have a look at https://bitbucket.org/IanSav/overlayhd.

 

What do people here think about this situation.

 

Regards,

Ian.



Re: Button() and Label(), PLi opinion. #6 IanSav

  • Senior Member
  • 264 posts

+15
Neutral

Posted 14 January 2018 - 07:23

Hi,

 

In my previous post I should have mentioned that I use the "conditional=" attribute to control if the button defined in the skin is actually displayed on the screen based on the presence or absence definition of the button "key_xxx" value in the code.

 

Regards,

Ian.


Edited by IanSav, 14 January 2018 - 07:24.


Re: Button() and Label(), PLi opinion. #7 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 12:50

Has no one from the OpenPLi team got any comment/opinion as to why this should be like this?

 

Here are my findings:

 

Label():

  1. displays from name
  2. displays from source
  3. updates from name
  4. does not update from source

Button():

  1. displays from name
  2. displays from source
  3. updates from name
  4. does not update from source

StaticText():

  1. does not display from name
  2. displays from source
  3. does not update from name
  4. updates from source
     


Re: Button() and Label(), PLi opinion. #8 littlesat

  • PLi® Core member
  • 44,616 posts

+451
Excellent

Posted 15 January 2018 - 12:59

See here:

 

Label... and what it can do... https://github.com/O...onents/Label.py

Button... and what it can do... https://github.com/O...nents/Button.py

 

Sounds like historically Buttons and Labels are mixed....

 

root@vuultimo4k:/usr/lib/enigma2/python/Screens# grep '\"key_red\"] =' *.py
About.py:               self["key_red"] = Button(_("Latest Commits"))
About.py:               self["key_red"] = Button(_("Cancel"))
About.py:               self["key_red"] = Button(_("Cancel"))
About.py:               self["key_red"] = Label(_("Cancel"))
About.py:               self["key_red"] = Button()
AudioSelection.py:              self["key_red"] = Boolean(False)
AutoDiseqc.py:          self["key_red"] = StaticText(_("Abort"))
ChannelSelection.py:            self["key_red"] = Button(_("All"))
Ci.py:          self["key_red"] = StaticText(_("Cancel"))
EpgSelection.py:                self["key_red"] = Button("")
EpgSelection.py:                        self["key_red"] = Button()
EventView.py:           self["key_red"] = Button("")
FlashImage.py:          self["key_red"] = Button(_("Cancel"))
FlashImage.py:          self["key_red"] = Button(_("Cancel"))
Hotkey.py:              self["key_red"] = Button(_("Exit"))
Hotkey.py:              self["key_red"] = Button(_("Cancel"))
InputDeviceSetup.py:            self["key_red"] = StaticText(_("Close"))
InputDeviceSetup.py:            self["key_red"] = StaticText(_("Cancel"))
InputDeviceSetup.py:            self["key_red"] = StaticText(_("Cancel"))
LocationBox.py:         self["key_red"] = Button(_("Cancel"))
Menu.py:                self["key_red"] = Label(_("Exit"))
MovieSelection.py:              self["key_red"] = Button(_("Cancel"))
MovieSelection.py:              self["key_red"] = Button("")
NetworkSetup.py:                self["key_red"] = StaticText(_("Close"))
NetworkSetup.py:                self["key_red"] = StaticText(_("Cancel"))
NetworkSetup.py:                self["key_red"] = StaticText(_("Cancel"))
NetworkSetup.py:                self["key_red"] = StaticText(_("Close"))
NetworkSetup.py:                self["key_red"] = StaticText(_("Close"))
ParentalControlSetup.py:                self["key_red"] = StaticText(_("Cancel"))
PluginBrowser.py:               self["key_red"] = self["red"] = Label(_("Remove plugins"))
RecordPaths.py:         self["key_red"] = StaticText(_("Cancel"))
Satconfig.py:           self["key_red"] = Label(_("Cancel"))
Satconfig.py:           self["key_red"] = Button(_("Cancel"))
ScanSetup.py:           self["key_red"] = StaticText(_("Close"))
ScanSetup.py:           self["key_red"] = StaticText(_("Close"))
ServiceInfo.py:         self["key_red"] = self["red"] = Label(_("Exit"))
ServiceScan.py:         self["key_red"] = Label(_("Cancel"))
Setup.py:               self["key_red"] = StaticText(_("Cancel"))
SleepTimerEdit.py:              self["key_red"] = StaticText(_("Cancel"))
SoftcamSetup.py:                self["key_red"] = Label(_("Cancel"))
StreamingClientsInfo.py:                self["key_red"] = Button(_("Close"))
TimerEdit.py:           self["key_red"] = Button(" ")
TimerEdit.py:           self["key_red"] = Button(_("Cancel"))
TimerEntry.py:          self["key_red"] = Button(_("Delete entry"))

Edited by littlesat, 15 January 2018 - 13:04.

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W Thanks to Henksat

Re: Button() and Label(), PLi opinion. #9 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 13:18

Thanks Littlesat,

 

The purpose of this thread is to discover the logic behind why Label/Button() update "name" but do not update "source" when pushing updatable text to the screen from the python file.



Re: Button() and Label(), PLi opinion. #10 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 13:22

Or is this a bug?

 

And even if not a bug, it is a nightmare for anyone that is new to skinning/coding enigma2.


Edited by Huevos, 15 January 2018 - 13:25.


Re: Button() and Label(), PLi opinion. #11 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 13:31

E.g.

 

This updates the screen when text is push from the python file with SetText().

<widget name="description" position="50,385" size="500,80" font="Regular;18" halign="center" valign="top" transparent="0" zPosition="1"/>

And this does not update the screen when text is push from the python file with SetText().

<widget source="description" render="label" position="50,385" size="500,80" font="Regular;18" halign="center" valign="top" transparent="0" zPosition="1"/>


Re: Button() and Label(), PLi opinion. #12 littlesat

  • PLi® Core member
  • 44,616 posts

+451
Excellent

Posted 15 January 2018 - 13:32

The button has an interesting option... you can add a function when the button is clicked... I don't know if this was ever used...?


Edited by littlesat, 15 January 2018 - 13:33.

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W Thanks to Henksat

Re: Button() and Label(), PLi opinion. #13 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 14:03

Thanks for the input but you are going off the point.

 

A text is displayed on the screen. Python wants to update that text. So it does this:

self["key_blue"].setText(_("New text"))

Now that text will only arrive at the display if we use this:

<widget name="description" position="50,385" size="500,80" font="Regular;18" halign="center" valign="top" transparent="0" zPosition="1"/>

Why does it not arrive at the display if we use this?

<widget source="description" render="label" position="50,385" size="500,80" font="Regular;18" halign="center" valign="top" transparent="0" zPosition="1"/>

Is this a bug? If this is not a bug, why is it like this?

 

And if we use StaticText() and source="description", the text does arrive at the display. Why the inconsistency?


Edited by Huevos, 15 January 2018 - 14:06.


Re: Button() and Label(), PLi opinion. #14 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 14:13

Also if these can be used interchangeably we need consistency in behaviour.

 

E.g. Why does StaticText() not arrive at the display if we do this? Not even the initial text is displayed:

<widget name="description" position="50,385" size="500,80" font="Regular;18" halign="center" valign="top" transparent="0" zPosition="1"/>

Edited by Huevos, 15 January 2018 - 14:14.


Re: Button() and Label(), PLi opinion. #15 WanWizard

  • Forum Moderator
    PLi® Core member
  • 40,820 posts

+642
Excellent

Posted 15 January 2018 - 15:23

I.e. the quesion is: why is the behaviour of these similar functions not the same?


Many answers to your question can be found in our new and improved wiki.

Currently in active use: HD2400 (4xS2)VU+Duo2 (3xS2)VU+Zero, Edision OS mini+, ET10000 (4xS2)

For testing purposes: XP1000Formuler F1 (2xS2)Miraclebox Premium Micro (S2+C/T),  ET7500 (S2)ET8500 (S2), Zgemma H2.H (S2+C)Zgemma H5.2TC (S2+C/T), SAB TripleAlpha (S2+C/T), Galaxy 4K (FBC), VU Zero 4K, Edision OS nino 


Re: Button() and Label(), PLi opinion. #16 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 16:51

I.e. the quesion is: why is the behaviour of these similar functions not the same?

Yes. 

 

These inconsistencies force us to skin each screen on a screen by screen basis, and stop the possibility of panels being shared among multiple screens.


Edited by Huevos, 15 January 2018 - 16:52.


Re: Button() and Label(), PLi opinion. #17 MiLo

  • PLi® Core member
  • 13,782 posts

+289
Excellent

Posted 15 January 2018 - 17:34

Looks like the only real difference is in the HTML they produce. Is that feature actually being used, or is that html output just dead code?

I'd suggest they can all share the same code base, apart from those few lines, so they all have the max amount of features (and get rid of duplicate code).
Real musicians never die - they just decompose

Re: Button() and Label(), PLi opinion. #18 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 18:14

Looks like the only real difference is in the HTML they produce. Is that feature actually being used, or is that html output just dead code?

I'd suggest they can all share the same code base, apart from those few lines, so they all have the max amount of features (and get rid of duplicate code).

Not quite as simple as that. When they are combined, both "name" and "source" need to force output to the screen. That way the whole thing will be backwards compatible.



Re: Button() and Label(), PLi opinion. #19 Huevos

  • Senior Member
  • 1,804 posts

+99
Good

Posted 15 January 2018 - 18:36

@Milo,

 

produceHTML exists in the following python files:


enigma2/lib/python/Components/Button.py
enigma2/lib/python/Components/Clock.py
enigma2/lib/python/Components/HTMLComponent.py
enigma2/lib/python/Components/HTMLSkin.py
enigma2/lib/python/Components/Label.py
enigma2/lib/python/Components/ScrollLabel.py

Must be dead code. Nothing uses that code anywhere in enigma or plugins.



Re: Button() and Label(), PLi opinion. #20 littlesat

  • PLi® Core member
  • 44,616 posts

+451
Excellent

Posted 15 January 2018 - 19:07

Maybe a never ontworked thing from the dmm Guys?
WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W Thanks to Henksat




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users