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. #81 littlesat

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 07:28

Again staticText a source (see subdir source) and label and button are ‘direct widgets’... therefore for label and button setText does not work as sources are updated after the screen is renedered the first time and direct widgets not. And that is also not bad and requires a fix as you always could use statictext when you need to change the text in a screen. My meaning is this is not a bug at all.
When you call a label or button from a source they also can be updated as the label is given in the source as render.

Edited by littlesat, 18 January 2018 - 07:32.

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


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 09:44

In Label() and Button() the source methods are faked... avoiding an update being possible....?

 

However I could not find the connectDown/Up stream functions are used anyway...

# fake Source methods:
def connectDownstream(self, downstream):
pass
 
def checkSuspend(self):
pass
 
def disconnectDownstream(self, downstream):
pass

Edited by littlesat, 18 January 2018 - 10:01.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 10:59

 

In Label() and Button() the source methods are faked... avoiding an update being possible....?

 

However I could not find the connectDown/Up stream functions are used anyway...

# fake Source methods:
def connectDownstream(self, downstream):
pass
 
def checkSuspend(self):
pass
 
def disconnectDownstream(self, downstream):
pass

Well they are used because if you comment them out everything goes wrong.



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 11:16

Where is your fix suggestion?

We can autohide the png's via ConditionalShowHide when we arrange that StaticText can return a boolean property based on having contents in the text or having an empty string.

Then I see we have 4 types of buttons in the string...

 

1. without source (direct label), named key_color

2. with source, named key_color

3. without source (direct label) named color

4. with source, named color

 

Also 'history' stuff you cannot get easily rid of due to the hsitory and plugins

 


Well they are used because if you comment them out everything goes wrong.

And that is why you cannot change these values in the code....


Edited by littlesat, 18 January 2018 - 11:26.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 11:26

Littlesat, why are you confusing this with coloured buttons. The problem is when you send setText it does not arrive at "source". That is the bug.

 

If you don't think that is a bug it must then be a feature. If it is a feature please explain why you would send setText and not want it to arrive at the display.



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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 11:40

Those functions are used in Element.py.



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 11:53

Yep and they are overruled as they cannot work... which mean the text cannot be updated... 

<screen name="ButtonRed">
<widget conditional="key_red" source="key_red" render="ePixmap" pixmap="PLi-FullNightHD/buttons/red.png" position="192,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
<widget conditional="red" source="red" render="ePixmap" pixmap="PLi-FullNightHD/buttons/red.png" position="192,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget> 
</screen>
 
<screen name="ButtonGreen">
<widget conditional="key_green" source="key_green" render="ePixmap" pixmap="PLi-FullNightHD/buttons/green.png" position="628,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
<widget conditional="green" source="green" render="ePixmap" pixmap="PLi-FullNightHD/buttons/green.png" position="628,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
</screen>
 
<screen name="ButtonYellow">
<widget conditional="key_yellow" source="key_yellow" render="ePixmap" pixmap="PLi-FullNightHD/buttons/yellow.png" position="1064,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
<widget conditional="yellow" source="yellow" render="ePixmap" pixmap="PLi-FullNightHD/buttons/yellow.png" position="1064,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
</screen>
 
<screen name="ButtonBlue">
<widget conditional="key_blue" source="key_blue" render="ePixmap" pixmap="PLi-FullNightHD/buttons/blue.png" position="1500,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
<widget conditional="blue" source="blue" render="ePixmap" pixmap="PLi-FullNightHD/buttons/blue.png" position="1500,1032" size="34,34" alphatest="blend">
<convert type="ConditionalShowHide"/>
</widget>
</screen>
 
<screen name="ButtonTemplate">
<panel name="ButtonRed"/>
<widget conditional="key_red" name="key_red" position="242,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="key_red" source="key_red" render="Label" position="242,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
<widget conditional="red" name="red" position="242,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="red" source="red" render="Label" position="242,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
 
<panel name="ButtonGreen"/>
<widget conditional="key_green" name="key_green" position="678,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="key_green" source="key_green" render="Label" position="678,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
<widget conditional="green" name="green" position="678,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="green" source="green" render="Label" position="678,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
 
<panel name="ButtonYellow"/>
<widget conditional="key_yellow" name="key_yellow" position="1114,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="key_yellow" source="key_yellow" render="Label" position="1114,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
<widget conditional="yellow" name="yellow" position="1114,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="yellow" source="yellow" render="Label" position="1114,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
 
<panel name="ButtonBlue"/>
<widget conditional="key_blue" name="key_blue" position="1550,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="key_blue" source="key_blue" render="Label" position="1550,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
<widget conditional="blue" name="blue" position="1550,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="blue" source="blue" render="Label" position="1550,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
</screen>

Edited by littlesat, 18 January 2018 - 11:54.

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


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 11:56

                self.timer.stop()
 
        def calcVisibility(self):
-               b = self.source.boolean
-               if b is None:
-                       b = False
-               b ^= self.invert
-               return b
+               try:
+                       return bool(self.source.boolean) ^ self.invert
+               except:
+                       return True
 
        def changed(self, what):
                vis = self.calcVisibility()
diff --git a/lib/python/Components/Sources/StaticText.py b/lib/python/Components/Sources/StaticText.py
index 8e6f824ef..c5c22df72 100644
--- a/lib/python/Components/Sources/StaticText.py
+++ b/lib/python/Components/Sources/StaticText.py
@@ -22,3 +22,9 @@ class StaticText(Source):
                self.changed((self.CHANGED_ALL,))
 
        text = property(getText, setText)
+
+       @cached
+       def getBoolean(self):
+               return bool(self.__text)
+
+       boolean = property(getBoolean)


Edited by littlesat, 18 January 2018 - 12:04.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 12:12

 

Yep and they are overruled as they cannot work... which mean the text cannot be updated... 


What do you mean can't? Why not? You can write what you want into code. Never known something yet that cant be coded. And this is just a simple text being pushed to a display. That is the first thing a coder learns. "HELLO WORLD!"


Edited by Huevos, 18 January 2018 - 12:14.


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 12:14

Then come with an example/solution.... maybe then we are on the same 'frequency and modulation'


Edited by littlesat, 18 January 2018 - 12:15.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 13:04

I haven't found a solution, which is why I asked for help from the knowledgeable people here.

 

What about StaticText() could that be updated somehow so it can also setText to the name widget?



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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 13:14

                self.timer.stop()
 
        def calcVisibility(self):
-               b = self.source.boolean
-               if b is None:
-                       b = False
-               b ^= self.invert
-               return b
+               try:
+                       return bool(self.source.boolean) ^ self.invert
+               except:
+                       return True
 
        def changed(self, what):
                vis = self.calcVisibility()
diff --git a/lib/python/Components/Sources/StaticText.py b/lib/python/Components/Sources/StaticText.py
index 8e6f824ef..c5c22df72 100644
--- a/lib/python/Components/Sources/StaticText.py
+++ b/lib/python/Components/Sources/StaticText.py
@@ -22,3 +22,9 @@ class StaticText(Source):
                self.changed((self.CHANGED_ALL,))
 
        text = property(getText, setText)
+
+       @cached
+       def getBoolean(self):
+               return bool(self.__text)
+
+       boolean = property(getBoolean)

But this idea requires all buttons texts to be staticText(). That is not backwards compatible. Most of your screens are not compatible. And is it going to break conditional that is using Label/Button?



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 13:41

This is not the only thing that needs to be changed... Where you talking about I do not have a solution.... And as far I can see it can't be done.

The try/except should here accomplished that for label and button the png is always shown when defined.


Edited by littlesat, 18 January 2018 - 13:42.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 13:53

This is not the only thing that needs to be changed... Where you talking about I do not have a solution.... And as far I can see it can't be done.

The try/except should here accomplished that for label and button the png is always shown when defined.

It already is shown when defined in the current code without this change. So pointless change.

Also, you posted this above:

<widget conditional="key_green" name="key_green" position="678,1030" size="370,38" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>
<widget conditional="key_green" source="key_green" render="Label" position="678,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>

That is no good and part of the reason I started this thread in the first place. Look at the YELLOW button in the attached screengrab.

 

Attached File  cron.png   120.03KB   3 downloads



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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 14:03

So, as you can see from the above, superimposing one widget on top of another is not a bright idea.

 

Much better to fix the python object that is broken than doing a hack like that.



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 15:26

It is much better to use staticText -or- button -or- label in the python code whichever button you want to present... I see that as ONLY correct solution... however this seems to be an utopie (for E2 it is doable... but think about al those plugins).

 

The 'overlay' in the taskmanager is caused because one source that will be updated is created and probably one label that is not being updated when the text changes...

 

It might be some 'small' changes on some screens might be required..... But also I need a big investigation and asking should we 'spend' time on it... I think it would be nice if we can more easily hide the png buttons in case the color key does not exists in the screen's dictionary and when the text is empty...

The screenshot demonstrates possibly we need to make a fix on the crond manager... or do you have more of such screens?


Edited by littlesat, 18 January 2018 - 15:30.

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


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 15:41


Much better to fix the python object that is broken than doing a hack like that.

 

[repeat mode]Do you already have the idea how to 'fix' this?[/repeat mode]

Because I could not find a good method...


Edited by littlesat, 18 January 2018 - 15:41.

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


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 15:47

The crond manager demonstrates it might work when we make a fake/dummy thing...

 

It seems the source take it over... I even just remove the whole line?

 

Actually the biggest mistake in phython here is the mixt usage of Label, Button and staticText

<screen name="ButtonTemplate">
<panel name="ButtonRed"/>
<widget conditional="key_red" name="key_red" position="242,1030" size="0,0" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/> #dummy as size is 0,0
<widget conditional="key_red" source="key_red" render="Label" position="242,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
<widget conditional="red" name="red" position="242,1030" size="0,0" backgroundColor="black" zPosition="1" transparent="1" font="Regular;34" halign="left"/>  #dummy as size is 0,0
<widget conditional="red" source="red" render="Label" position="242,1030" size="370,38" backgroundColor="darkgrey" zPosition="2" transparent="1" foregroundColor="grey" font="Regular;34" halign="left"/>
 
...

Edited by littlesat, 18 January 2018 - 15:48.

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


Re: Button() and Label(), PLi opinion. #99 Abu Baniaz

  • PLi® Contributor
  • 2,496 posts

+64
Good

Posted 18 January 2018 - 16:23

To me it seems there appears to be confusion about the problem. To help clarify it, can I make up two terms?

 

"button_graphic"

"button_text"

 

The problem is "button_text" not updating. Talking about "button_graphic" distracts from acknowledging/dealing with the problem about "button_text".

 

IMO, we could code it so that "button_text" automatically displays "button_text". By definition, if you want "button_text", it will be next to a "button_graphic". Lets keep that for the future for time being and focus on getting "button_text" to work properly.

 

We can have freestanding labels/text so that is probably where the button/label/text confusion is happening.

 

To further explain the problem, please find attached a screenshot. I have two "button_text" on top of each other. "Satellites" and "Extended".

Attached Files


Edited by Abu Baniaz, 18 January 2018 - 16:24.


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 16:33

Again... As far I understand when you want to update texts after the screen is 'made' it is mandatory to use a 

<widget source="key_red" render="Label"... structure in the skin....

 

-unless-

 

Someone finds a trick to do it without it....

 

With the python code change I gave above I suggest it should be possible to hide the button_graphic when the text is an empty string or None.


Edited by littlesat, 18 January 2018 - 16:34.

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



23 user(s) are reading this topic

0 members, 23 guests, 0 anonymous users