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. #101 Huevos

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 16:40

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

Nope, wrong again.

Attached Files



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 17:04

There is nothing wrong in the first place... ;) I struggled with the same thing years and years ago,....

 

I have no permission to open the attached file....  Mayby put it here between... So i see the trick you invented.... (and probably I see... oh yes!!!)

and

?

 

And still we end op with 3 types of making those buttons.... :( Which is actually the onlything that is wrong in the first place....


Edited by littlesat, 18 January 2018 - 17:08.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 17:28

T[...]..

 

I [...] And still we end op with 3 types of making those buttons.... :( Which is actually the onlything that is wrong in the first place....

Yes 3 object that do the same job using different processes.

 

Somehow we need a backwards compatible solution that moves forward from today and doesn't include hacks or self control.

 

My suggestion is write a new function in CPP and link all 3 of these python objects to it. So they all update on name and source.



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 17:36

Sorry I can’t download your file can you please copy and past it?

As far I can see button is not really required... I think it can be the same object as label as far I can see. StaticText is something different... but maybe this can be linked to label... but still as far I understand you need source for updating elements...

Edited by littlesat, 18 January 2018 - 17:40.

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


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

  • Senior Member
  • 7,766 posts

+184
Excellent

Posted 18 January 2018 - 17:41

Try this one: Attached File  ButtonTexts.zip   2.26KB   4 downloads



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

  • PLi® Contributor
  • 2,496 posts

+64
Good

Posted 18 January 2018 - 17:42

here are the py files.

 

These are to just show the problem.

from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Components.ActionMap import ActionMap
from Components.Button import Button
from Components.Label import Label
from Components.Sources.StaticText import StaticText

class ButtonTextsScreen(Screen):
    skin = """
        <screen position="340,170" size="600,400">
            <widget source="key_red" render="Label" position="0,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            <widget source="key_green" render="Label" position="150,0" size="140,40" valign="center" halign="center" zPosition="4" foregroundColor="white" backgroundColor="#1f771f" font="Regular;18" transparent="1"/>
            <ePixmap name="red" position="0,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on"/>
            <ePixmap name="green" position="150,0" zPosition="2" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on"/>
            <eLabel text="Button()" position="150, 80" size="140,50" font="Regular;20" transparent="0" valign="center" halign="center" />
            <eLabel text="Label()" position="300, 80" size="140,50" font="Regular;20" transparent="0" valign="center" halign="center" />
            <eLabel text="StaticText()" position="450, 80" size="140,50" font="Regular;20" transparent="0" valign="center" halign="center" />
            <eLabel text="Name" position="0, 150" size="140,50" font="Regular;20" transparent="0" valign="center" halign="center" />
            <eLabel text="Source" position="0, 220" size="140,50" font="Regular;20" transparent="0" valign="center" halign="center" />
            <widget name="button_text" position="150,150" size="140,50" valign="center" halign="center" zPosition="4" foregroundColor="yellow" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            <widget source="button_text" render="Label" position="150,220" size="140,50" valign="center" halign="center" zPosition="4" foregroundColor="yellow" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            <widget name="label_text" position="300,150" size="140,50" valign="center" halign="center" zPosition="4" foregroundColor="yellow" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            <widget source="label_text" render="Label" position="300,220" size="140,50" valign="center" halign="center" zPosition="4" foregroundColor="yellow" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            <widget name="static_text" position="450,150" size="140,50" valign="center" halign="center" zPosition="4" foregroundColor="yellow" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            <widget source="static_text" render="Label" position="450,220" size="140,50" valign="center" halign="center" zPosition="4" foregroundColor="yellow" backgroundColor="#9f1313" font="Regular;18" transparent="1"/>
            
        </screen>"""

    def __init__(self, session):
        Screen.__init__(self, session)
        self["actions2"] = ActionMap(["SetupActions", "ColorActions", "MenuActions"],
        {
            "cancel": self.keyCancel,
            "menu": self.keyCancel,
            "red": self.keyCancel,
            "green": self.keyGo,
        }, -2)

        self["key_red"] = StaticText(_("Exit"))
        self["key_green"] = StaticText(_("Send SetText"))
        
        creation_text = _("Initial text")
        self["button_text"] = Button(creation_text)
        self["label_text"] = Label(creation_text)
        self["static_text"] = StaticText(creation_text)

        Screen.setTitle(self, _("Button texts"))
        
        self.update = 1

    def keyGo(self):
        update_text = _("Update %d") % self.update
        self.update += 1
        self["button_text"].setText(update_text)
        self["label_text"].setText(update_text)
        self["static_text"].setText(update_text)

    def keyCancel(self):
        self.close(False)

def ButtonTextsStart(menuid, **kwargs):
    if menuid == "scan":
        return [(_("Button Texts"), ButtonTextsMain, "ButtonTextsScreen", 80)]
    return []

def ButtonTextsMain(session, **kwargs):
    session.open(ButtonTextsScreen)

def Plugins(**kwargs):
    pList = []
#    pList.append( PluginDescriptor(name=_("ButtonTexts"), description= _("For testing buttons objects"), where = PluginDescriptor.WHERE_MENU, fnc=ButtonTextsStart, needsRestart=False) )
    pList.append( PluginDescriptor(name = "ButtonTexts", description = _("For testing button objects"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=ButtonTextsMain))
    return pList

Attached Files


Edited by Abu Baniaz, 18 January 2018 - 17:43.


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 17:56

I understand the ‘problem’ but I do not see a fix!

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


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

  • PLi® Contributor
  • 2,496 posts

+64
Good

Posted 18 January 2018 - 18:04

Can we add extra debug to trace where this problem is being caused?


Edited by Abu Baniaz, 18 January 2018 - 18:04.


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 19:19

Actually it is the name being updated and the source not

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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 21:11

So you’re saying label and button is updated en statictxt
Not?

Edited by littlesat, 18 January 2018 - 21:14.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 21:15

Run my plugin. Shows everything.

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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 21:18

No box time now... I only can read-in. But if this is the fact I was in the incorrect frequency...

Edited by littlesat, 18 January 2018 - 21:19.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 21:19

I described earlier in the thread. Name and button write to name and source. But only update source.

StaticText writes to source only. Not to name.

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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 21:26

Label
Display in name
display in source
updates name
does not update source.

button does same as label

staticText
name is always empty
writes to source
updates source

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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 21:58

So indeed only source updates with staticText...
. what I was always telling... + we do not have a fix yet...+ I tried to explain only with source you can update... source creates also new element linked to the ‘master’ element. that is why we could have two text over eachother...

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

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 18 January 2018 - 22:38

You cant have 2 superimposed texts because...

 

Label writes to both and updates name. That means when label/button updates the 2 texts will be different.

 

This is nothing to do with staticText.



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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 18 January 2018 - 23:34

I understand the symptom... and the complete mechanism... that is why ‘name’ shoudln’t be used when you want to alter text... Or do you already have a fix in mind?
With statictext it serms to work as ‘name’ does not really exist and you have only ‘source’... with label and button() you got double tekst because the ‘name’ does not change and the ‘source’ can change...

Edited by littlesat, 18 January 2018 - 23:36.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 19 January 2018 - 07:46

I [...] with label and button() you got double tekst because the ‘name’ does not change and the ‘source’ can change...

Why do you persist with this? You are wrong. It is 'name' that changes. Not 'source'.


Edited by Huevos, 19 January 2018 - 07:50.


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

  • PLi® Core member
  • 57,121 posts

+698
Excellent

Posted 19 January 2018 - 07:53

Statictext uodates source, label/button updates name.... and can’t update source... and source does not show in name... that’s what it should donas it is made that way...
When you have name you should not have source...

Edited by littlesat, 19 January 2018 - 07:55.

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


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

  • PLi® Contributor
  • 4,644 posts

+161
Excellent

Posted 19 January 2018 - 09:04

S [...] and source does not show in name... that’s what it should donas it is made that way...
When you have name you should not have source...

What does that mean? Source was deliberately added to Label and Button 5 years ago. That is why the fake source methods exist. The only problem is that it is non updating. So when source was added only half the job was done. And now 5 years later we are left with a backwards compatibility problem because of that thoughtless change.


Edited by Huevos, 19 January 2018 - 09:04.



20 user(s) are reading this topic

0 members, 20 guests, 0 anonymous users