Jump to content


Photo

Button() and Label(), PLi opinion.


  • Please log in to reply
465 replies to this topic

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

  • PLi® Core member
  • 70,396 posts

+1,807
Excellent

Posted 13 February 2018 - 22:51

The only way to handle that is to capture calls to deprecated functions and alert the developer.

 

It might be a bad idea to start doing these things in develop images (only)...


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

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


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

  • PLi® Core member
  • 57,120 posts

+698
Excellent

Posted 13 February 2018 - 22:54

ask IMS to adapt it...
I just tested the diff and I missed this one and indeed this was a Classic example...
I’m afraid IMS was not aware of it

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


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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 14 February 2018 - 01:16

Hi Nautilus7,

Nice Guide IanSav!

 

Regarding setText usage... Is 

setText()

 and 

setText("")

 exactly the same?

No, these are NOT the same. The first sets a null value while the second sets a blank string value.  While I suspect that this will work, it is not my intention.  The .setText() method should be dealing with strings so it should always be given a string as an argument.  This is an error in the document.  I have corrected the code sample to be .setText("") and this will be what I end up submitting to the doc directory in the repository.

 

Thank you for pointing out my error.

 

Regards,

Ian.

 



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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 14 February 2018 - 01:18

Hi Persian Prince,

 

Hi Persian Prince,

 

Hi Littlesat,

I’m still waiting for someone offering a patch for menu/info buttons ;)

I can't run OpenPLi firmware.  I only have Beyonwiz hardware that runs Beyonwiz or OpenViX firmware.  That said, if you nominate a screen that you would like adjusted to implement this proposal please let me know.  I will make the code adjustments to show you how this can be done.

 

Regards,

Ian.

What's your STB exactly? I can compile Open PLi 6.x (develop) so you can test more ...

 

I have a Beyonwiz T3 and a Beyonwiz T4.  The T4 is a production box so won't be running test firmware.  The T3 is my development platform.  Huevos can tell you what the hardware equates to in the OpenViX/OpenPLi world.

 

If Littlesat picks a common screen then it won't matter what build is used.  ;)

 

Regards,

Ian.

Here is a test image for "beyonwizt3": http://www.mediafire...onwizt3_usb.zip ;)

 

Thank you for this image.

 

Will this image be able to draw on going updates from the OpenPLi repositories?

 

Regards,

Ian.

 



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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 14 February 2018 - 01:56

Hi,
 
One of the Beyonwiz devs has suggested that I add the alternate syntax for setting the object values.  That is, as well as:

self["key_red"].setText(_("Close")

the following is equally acceptable:

self["key_red"].text = _("Close")

I have updates the documentation to reflect the additional syntax.

Proposal for Standardised and Uniform Buttons in Enigma2
--------------------------------------------------------
 
Written by IanSav - 12-Feb-2018
Updated by IanSav - 13-Feb-2018
 
INTRODUCTION:
=============
 
Enigma2 is a massive open source project that has many contributors and 
add-ons.  Over time a number of approaches to performing common tasks have 
evolved.  This document proposes to nominate some conventions that can be 
adopted by all developers, contributors and skin authors to ensure that 
everyone can work independently but still achieve results that work together 
interchangeably.
 
The purpose of this document is to propose some standard variable names 
together with code and skin coding conventions to make the task of creating 
code that works more universally with skins easier.
 
Button names should be drawn from the current button definitions in 
"keyids.py".  The names used should be the lower-case version of the button 
names in this file.  For example, if you wish to define a button for the RED 
button on the remote control then use a variable name of "key_red".  In 
Enigma2 the four colour buttons should be named "key_red", "key_green", 
"key_yellow" and "key_blue".
 
As an example, let us look at how the red button should be defined in the 
Python code and how it can be rendered in a skin.
 
COLOUR BUTTONS:
===============
 
In the Python code to define a RED button to be available in the skin simply 
add the following to your code:
 
from Components.Sources.StaticText import StaticText
 
self["key_red"] = StaticText(_("Cancel"))
 
The text should be language translated with the _("text") syntax.  The text 
itself should be as short as practical but clear enough to convey the 
meaning of the button.
 
During the execution of the code the meaning of the button can easily be 
changed by using the .setText() method.  For example:
 
self["key_red"].setText(_("Close")
or
self["key_red"].text = _("Close")
 
If you want to temporarily suppress the display of the button use the 
following syntax:
 
self["key_red"].setText("")
or
self["key_red"].text = ""
 
NOTE: Never translate an empty string, _(""), as this causes the translation 
system to output translation engine information and NOT a blank string as 
some may expect.
 
Now that the code is RED button enabled we need to code the skin to match.  
Here is a skin fragment that supports the code above:
 
<screen name="TemplateButtonRed">
<widget source="key_red" render="Pixmap" \
pixmap="buttons/button_red.png" position="10,10" \
size="200,30" alphatest="blend" conditional="key_red" \
transparent="1">
  <convert type="ConditionalShowHide" />
  </widget>
<widget source="key_red" render="Label" position="10,10" \
size="200,30" backgroundColor="ButtonRed" \
font="ButtonFont;20" foregroundColor="ButtonText" \
halign="center" conditional="key_red" transparent="1" \
valign="center" zPosition="+1" />
</screen>
 
The first widget checks if the variable "key_red" is defined in this screen 
via the "conditional" attribute.  If "key_red" is defined and not blank the 
image "buttons/button_red.png" is displayed on the screen.  The next widget 
also checks for the existence of "key_red" and then displays the button text 
over the image background.  Please note that a button image background is 
common but it is NOT required.  This is a design choice available to the 
skin author.
 
This sample would work well if all the code in Enigma2 was uniform and 
co-ordinated.  Unfortunately, we aren't there yet.  A more real-world example 
of how to define the button in a skin would be:
 
<screen name="TemplateButtonRed">
<ePixmap pixmap="buttons/button_red.png" position="10,10" \
size="200,30" alphatest="blend" \
objectTypes="key_red,Button,Label" transparent="1" />
<widget source="key_red" render="Pixmap" \
pixmap="buttons/button_red.png" position="10,10" \
size="200,30" alphatest="blend" \
objectTypes="key_red,StaticText" transparent="1">
  <convert type="ConditionalShowHide" />
  </widget>
<widget name="key_red" position="10,10" size="200,30" \
backgroundColor="ButtonRed" font="ButtonFont;20" \
foregroundColor="ButtonText" halign="center" \
objectTypes="key_red,Button,Label" transparent="1" \
valign="center" zPosition="+1" />
<widget source="key_red" render="Label" position="10,10" \
size="200,30" backgroundColor="ButtonRed" \
font="ButtonFont;20" foregroundColor="ButtonText" \
halign="center" objectTypes="key_red,StaticText" \
transparent="1" valign="center" zPosition="+1" />
</screen>
 
The difference here is that the button background image and the button 
text is defined twice.  This allows all legacy code that uses either 
Button(), Label() or StaticText() objects to define the code will still 
work in this proposed skin fragment.  The data from each of the object 
types is displayed overlapped on the screen.  To make this work without 
actually overlapping the data recent builds of OpenViX, OpenPLi and 
Beyonwiz firmware have added a new attribute to the skin parser.  This 
new attribute is "objectTypes".
 
The "objectTypes" attribute has a value consisting of a comma separated list 
of keywords.  Note that spaces around the comma(s) are NOT permitted.  The 
first value in the list must be the variable being checked, in this case 
"key_red".  This item is mandatory.  The following values are object type 
definitions of which this variable can be defined for this widget to be 
used.  The list can have zero or more object types listed.
 
The first value, the variable name, is processed in the same way as the 
conditional attribute.  If the variable is defined in the code then this 
screen widget is enabled and available for use.  If the variable is not 
defined in the code then this widget is ignored.
 
The following values arguments are a list of object types, like Button, 
Label or StaticText, the variable name's definition type is checked against 
the supplied list.  If the variable is not defined by one of the types in 
the list then that widget is ignored.  If there is a type match then the 
widget is enabled and available for use.  If no object types are listed then 
the "objectTypes" attribute works exactly the same as the "conditional" 
attribute.
 
IMPORTANT NOTE: The latter form of the skin XML code should be used to 
maintain backward compatibility with all existing Python code.  At some 
point in the future when all code is updated to support and comply with 
this proposal then the former, and simpler, version of the skin definition 
can be used as backward compatibility would no longer be an issue.
 
ACTION BUTTONS:
===============
 
Just like the colour buttons there are a number of standard action or 
functional buttons used.  For example, MENU, INFO, TEXT, HELP etc. 
Typically, these buttons are manually added / defined by skin writers 
in the various screens for which they are used.  This requirement places 
a heavy burden on skin writers who have to explore the Python code to 
determine when the various action buttons are defined and available for 
use.  If the buttons are defined then there should be definitions for those 
buttons in their skin.
 
As with the colour buttons it is quite easy to automate the inclusion of 
these standard action buttons in both the Python code and skin.
 
Let us use the example of the MENU button on the remote control let us look 
at how the red button should be defined in the Python code and how it can be 
rendered in a skin.
 
The Python code is exactly the same as that used by the colour button 
example above.  In the Python code to define a MENU button to be available 
in the skin simply add the following to your code:
 
from Components.Sources.StaticText import StaticText
 
self["key_menu"] = StaticText(_("MENU"))
 
The text for each action button should be language translated with the 
_("text") syntax.  The text itself should be as short as practical but clear 
enough to convey the meaning of the button.
 
If you want to temporarily suppress the display of the button use the 
following syntax:
 
self["key_menu"].setText("")
or
self["key_menu"].text = ""
 
NOTE: Never translate an empty string, _(""), as this causes the translation 
system to output translation engine information and NOT a blank string as 
some may expect.
 
Now that the code is MENU button enabled we need to code the skin to match.  
There are two ways a skin designer may choose to display the action buttons.  
They may wish to use a graphical image or they may choose to use a text 
based representation.
 
Here is a skin fragment that supports the code above to display a graphical 
MENU button:
 
<screen name="TemplateButtonMenu">
<widget source="key_menu" render="Pixmap" \
pixmap="buttons/button_menu.png" position="0,0" \
size="50,30" alphatest="blend" conditional="key_menu" \
transparent="1">
  <convert type="ConditionalShowHide" />
  </widget>
</screen>
 
In this example the widget checks if the variable "key_menu" is defined in 
this screen via the "conditional" attribute.  If "key_menu" is defined and 
not blank the image "buttons/button_menu.png" is displayed on the screen.
 
Here is a skin fragment that supports the code above to display a textural 
MENU button:
 
<screen name="TemplateButtonMenu">
<widget source="key_menu" render="Label" position="0,0" \
size="50,30" backgroundColor="ButtonBackground" \
font="ButtonFont;20" foregroundColor="ButtonText" \
halign="center" conditional="key_menu" transparent="1" \
valign="center" zPosition="+1" />
</screen>
 
This works the same way as the previous example except that instead of an 
image being displayed on the screen the translated text defined in the Python 
code is displayed on the screen.
 
CONCLUSION:
===========
 
For all the Enigma2 builds there is a significant legacy of code and skins 
that needs to be preserved and protected. The proposal outlined what I 
believe to be a conservative approach to making a significant but beneficial 
change in unifying and standardising the display of action and colour buttons 
across the Enigma2 UI.
 
---END---

 
Regards,
Ian.


Edited by IanSav, 14 February 2018 - 01:58.


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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 14 February 2018 - 02:07

Hi,

 

Apologies for the indentation errors in my last post.  The forum wouldn't allow me to save the corrections.  Needless to say, the documentation I submit to the repository will be correct.

 

Regards,

Ian.



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

  • PLi® Core member
  • 57,120 posts

+698
Excellent

Posted 14 February 2018 - 08:07


ask IMS to adapt it...
I just tested the diff and I missed this one and indeed this was a Classic example...
I’m afraid IMS was not aware of it 

I did some cleanups and as I added the green button does the same as menu I could keep Button() as elsewhere over there (so other skins stay compatible for this screen to reduce the 'impact')


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


Re: Button() and Label(), PLi opinion. #328 Rob van der Does

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 14 February 2018 - 08:45

This is a new class, so there won't be other skins having this screen (yet).



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

  • PLi® Core member
  • 57,120 posts

+698
Excellent

Posted 14 February 2018 - 09:41

Now I see...

https://github.com/l...59a211913505860

 

IMS needs to add a default_skin aswell... Or use an existing skinName...


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


Re: Button() and Label(), PLi opinion. #330 nautilus7

  • Senior Member
  • 229 posts

+6
Neutral

Posted 14 February 2018 - 10:41

I don't really get it...

 

Over 1 month of discussion about how it would be better to use StaticText for buttons...

A complete guide written by IanSan about how to properly code buttons in new classes a  few posts above...

Several changes in buttons in existing classes from button to StaticText or Label...

 

 

And now, there is a newly introduced class and the OpenPli developers code it the wrong way and refuse to fix it...



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

  • PLi® Core member
  • 57,120 posts

+698
Excellent

Posted 14 February 2018 - 11:16

As this was a new screen it could be changed of course... I saw later it was a new screen... But now all four buttons are also used...

Actually for the structure we need to replace for these buttons all Buttons() and Labels() to StaticText... I agree... but this is somehow also not practical... ;)


Edited by littlesat, 14 February 2018 - 11:19.

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


Re: Button() and Label(), PLi opinion. #332 Rob van der Does

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 14 February 2018 - 11:29

So the very first class that has been added since adapting the 'unified button structure' doesn't (have to) adhere to it because of......?



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

  • PLi® Core member
  • 57,120 posts

+698
Excellent

Posted 14 February 2018 - 11:59

When the community is ready for it... we can replace all the Buttons() and Labels()....


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


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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 14 February 2018 - 12:11

Hi Littlesat,

When the community is ready for it... we can replace all the Buttons() and Labels()....

With all due respect it is better and easier to implement new code the right way in the beginning.  It will be much harder to change it later when lots of people have already developed their skins for that code.  That is, once people write a skin for some code they will be very unhappy to have to change the skin later.

 

The faster we move to making all code easier to skin the better it will be for everyone.

 

Regards,

Ian.



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

  • PLi® Core member
  • 70,396 posts

+1,807
Excellent

Posted 14 February 2018 - 12:18

I tend to agree. You can't innovate without breaking things, you can't move forward if you don't want to innovate.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

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


Re: Button() and Label(), PLi opinion. #336 Rob van der Does

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 14 February 2018 - 12:19

When the community is ready for it... we can replace all the Buttons() and Labels()....

I don't get it: you already forced the new formats upon us from the very first moment you began to grasp the idea, making existing skins incompatible.

And now for a new screen, which nobody can have skinned yet, you await erm.... what exactly?



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

  • PLi® Core member
  • 57,120 posts

+698
Excellent

Posted 14 February 2018 - 12:24

I tried to create as less as possible 'issues' with the existing skin base to avoid a 'big hell' as soon 6.2 or 7.0 is going to the big public...

 

In this specific case we could consider to replace it by StaticText of course...

 

Please offer a merge request as I can probably not test it today,


Edited by littlesat, 14 February 2018 - 12:25.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 14 February 2018 - 13:37

BTW, guys you do realize certain functions are not available to StaticText()? Which is why the thread started with the question "is there a way to merge the functionality of all three of these class objects".



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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 14 February 2018 - 15:02

Hi Huevos,

BTW, guys you do realize certain functions are not available to StaticText()? Which is why the thread started with the question "is there a way to merge the functionality of all three of these class objects".

I gave it a try but was unsuccessful.  :(

 

Hopefully someone with more knowledge and understanding of how this all works can sort this out for us all.

 

Regards,

Ian.



Re: Button() and Label(), PLi opinion. #340 prl

  • Senior Member
  • 36 posts

+2
Neutral

Posted 23 February 2018 - 03:02

Hi, folks. For those of you who haven't encountered me before, I believe I'm the "fellow Beyonwiz developer" that IanSav mentioned in earlier posts.

 

Ian has approached me to implement his suggested changes to the Label/Button/StaticText mess. I'm also the author of the Beyonwiz fix (which was rejected upstream) that allows Button and Label objects that are skinned as both source= and name= widgets to correctly update the source side so that screen text is correctly updated when self[some_key].setText("New name") is called. That fixed most of the issues that the Beyonwiz code was having with templates that it uses for button definition.

 

My Python changes do not address issues with StaticText buttons that are skinned as both name= and source= widgets.

 

That double-skinning style is used in all the Beyonwiz skins - the pre-installed skins, easy-skin-aus-hd and Full-Metal-Wizard, as well as in IanSav's OverlayHD skin (which is a popular user-contributed skin that is not yet available on the standard Beyonwiz package feeds).

 

I would be interested in implementing Ian's suggestions, but I'm currently fairly deep down my development interrupt stack (which is one reason why those interested in my code for extracting CRIDs from the FTA EPG haven't seen anything for some time). I'm not sure when I'll have the time available to do it.

 

Peter




7 user(s) are reading this topic

0 members, 7 guests, 0 anonymous users