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. #161 IanSav

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 21 January 2018 - 14:46

Hi,
 
The other buttons displayed in the skins, like MENU, INFO etc can also be controlled in the skin by making those buttons conditional in a way like the colour buttons.
 
In any Python code that can use the MENU button simply include a line like:
self["key_menu"] = Label(_("MENU"));
or
self["key_menu"] = StaticText(_("MENU"));
Then in the skin use a button definition like:
<ePixmap pixmap="buttons/button_block_menu.png" position="50,670" size="50,35" alphatest="blend" conditional="key_menu" transparent="1" />
If the code handles the MENU button and it flags that the button is available then the skin will automatically display the button.

This same code also allows the skinner to define a text based MENU button by actually using the value of the Label() or StaticText() definition.
<widget name="key_menu" position="172,670" size="225,35" font="ButtonFont;20" foregroundColor="ButtonText" halign="center" objecttypes="Label" transparent="1" valign="center" zPosition="+1" />
or
<widget source="key_menu" render="Label" position="172,670" size="225,35" font="ButtonFont;20" foregroundColor="ButtonText" halign="center" objecttypes="StaticText" transparent="1" valign="center" zPosition="+1" />
Does this address the feature you want?

Regards,
Ian.

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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 21 January 2018 - 15:35

When the plug-ins etc have the correct consequent keys this is indeed possible...

Edited by littlesat, 21 January 2018 - 15:35.

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


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

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 21 January 2018 - 16:38

IMHO we shouldn't worry too much about plugins; let's concentrate on E2.

Plugins can use their own (embedded) screens.



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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 21 January 2018 - 22:10

The boolean property added in statictext and then conditionalshiwhide in the skin. Maybe this also might work with label and vitten when we add a boolean property to variabketext.py (sorry when I named py files slightly wrong). And that was exactly my purpose!

Please can you add the boolean to Label() and Button().



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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 21 January 2018 - 22:21

First I need to check if it works... as these classes are no source classes

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


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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 22 January 2018 - 02:26

Hi,

In my button example above I left out the "conditional=" attribute for the two text button examples. Sorry about that.

Regards,
Ian.

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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 22 January 2018 - 03:32

Hi,

Before the new "objecttypes" attribute becomes widely used may I request that the name be corrected to "objectTypes" to better match the existing skin attribute naming scheme.

Regards,
Ian.

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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 07:15

Why? and Why?


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


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

  • PLi® Contributor
  • 1,491 posts

+51
Good

Posted 22 January 2018 - 08:15

Hi Littlesat,

If you look at all the skin based XML attributes they all use Camel case. This new attribute should follow the existing style.  That is, "objecttypes" should become "objectTypes".  (Note that this also makes it easier to spot the double "t".)

Regards,
Ian.


Edited by IanSav, 22 January 2018 - 08:17.


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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 09:40

Now it is clear....,
Conditional is required to check for the key exists in a screen.

So when we want to autohide the keys on 'demand'' when the text is empty then we need to use source (e.g. TimerEdit, TimerList)... (of course it is still fine for label and button when they are shown persistently.... and some of them are not there via the conditional parameter).

 

It seems the labels red, green without key_ are only used for the temperature plugin or so... so we could consider to adjust these plugins and remove them all...


Edited by littlesat, 22 January 2018 - 11:30.

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


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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 11:03

Conditional show/hide for button and label is not possible (as far I can see now)... The source type is mandatory here....


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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 22 January 2018 - 11:13

Littlesat, I think the way this has been done is wrong. Conditional has taken on a new job. If there is a depends it should be added as a separate variable. Right now you are using conditional as a key where source and name are missing from the widget. In my opinion that is wrong. I will rewrite and test.



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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 22 January 2018 - 11:24

So I think something like the following would be a lot better. i.e. don't touch the conditional code at all. And don't forget conditional can contain multiple conditions. Your code fails to take this into account properly.

	def process_screen(widget, context):
		for w in widget.getchildren():
			conditional = w.attrib.get('conditional')
			if conditional and not [i for i in conditional.split(",") if i in screen.keys()]:
				continue
			objecttypes = w.attrib.get('objectTypes')
			if objecttypes:
				key = w.attrib.get('objectTypesDepends') or w.attrib.get('name') or w.attrib.get('source')
				if key and key in screen and not [i for i in objecttypes.split(",") if i == screen[key].__class__.__name__]:
				continue
			p = processors.get(w.tag, process_none)
			try:
				p(w, context)
			except SkinError, e:
				print "[Skin] Skin error in screen '%s' widget '%s':" % (name, w.tag), e

Edited by Huevos, 22 January 2018 - 11:26.


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 22 January 2018 - 11:30

Conditional show/hide for button and label is not possible (as far I can see now)... The source type is mandatory here....

Why? The text in self.message updates and displays for these objects.



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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 11:32

Because as I said postings ago... having a source as 'hookup point' is mandatory... The 'field' will not be updated.... I still hope someone invents a work-a-round on this one (and that is why I did not alter e.g. TimerEdit/List yet). When nobody finds a solution on this one we should replace it by StaticText on any screen where the buttons are shown/hidden on ''demand'.... (and happy to say that are not that many).

 

The next we can also research is check for key_0, menu, info....


Edited by littlesat, 22 January 2018 - 11:42.

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


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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 11:47

And something like this... seems also not to work.. then always somehow all four buttons are shown when screen uses source (staticText)

if conditional and not [i for i in conditional.split(",") if i in screen.keys()]:
  continue
objecttypes = w.attrib.get('objecttypes')
if objecttypes:
  key = w.attrib.get('name') or w.attrib.get('source')
  if key and key in screen and not [i for i in objecttypes.split(",") if i == screen[key].__class__.__name__]:
    continue

Edited by littlesat, 22 January 2018 - 11:48.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 22 January 2018 - 13:07

 

And something like this... seems also not to work.. then always somehow all four buttons are shown when screen uses source (staticText)

if conditional and not [i for i in conditional.split(",") if i in screen.keys()]:
  continue
objecttypes = w.attrib.get('objecttypes')
if objecttypes:
  key = w.attrib.get('name') or w.attrib.get('source')
  if key and key in screen and not [i for i in objecttypes.split(",") if i == screen[key].__class__.__name__]:
    continue

Yes, of course not because neither name nor source are in the widget. But that is no reason to break the conditional attribute.

 

See my code above for what would work properly.

 

Also why can't the boolean be added to Label/Button. "Source" works for both, it is just that the text doesn't get pushed to the display if the __init__ has completed. 

 

With this widget:

<widget source="XXX" render="Label"...

If you run the following the text arrives at the display:

class MyClass(Screen):
	def __init__(self, session, slotid, menu_path=""):
		Screen.__init__(self, session)
		screentitle = _("Title")
		
		self["key_yellow"] = Label()
		self["key_yellow"].setText(_("This displays in 'source'"))


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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 14:17

I’m afraid you miss the biggest part... when use name in skin and label/button in python ‘nothing’ is possible... you cannot add a different source to that key and then let it response on conditions... I tried....it also gives a None type gsod on startup on chanelselection.py... might be related to blueglasse’s patch a bit more than 5 years ago... I hope you can help here..
Your patch does the same... always ever 4 color buttons on statictext/source even when you need less...

Edited by littlesat, 22 January 2018 - 14:26.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 22 January 2018 - 14:56

Yes, but we can use "source" in the skin for the button png.

 

E.g.

<widget source="key_red" render="Pixmap"... 

 That should work fine for both Label()/Button() and staticText() objects. The only thing missing is the boolean in Label()/Button().



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

  • PLi® Core member
  • 57,122 posts

+698
Excellent

Posted 22 January 2018 - 15:01

As far I can see here it doesn’t... (at least the showhideconditional)

Edited by littlesat, 22 January 2018 - 15:01.

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



10 user(s) are reading this topic

0 members, 10 guests, 0 anonymous users