Can anyone hint at a way to recall my iterated labels in kivy?

machinePerson

This is my first question here and i am not a programmer by trade, i build machines and sometimes use programming to do secondary adjustments. This is part of a modbus HMI project in python. I create switches and labels iteratively but after that i cant reach their properties. As i said this was written with kivy, but no important kv code was used, just positioning.

class InputGrid(GridLayout):
    def __init__(self,**kwargs):
        super().__init__(**kwargs)
        self.cols = 8
        self.indicators=mp.readInputs(qty=48)
        self.red = (1, 0, 0, 1)
        self.green = (0, 1, 0, 1)
        Clock.schedule_interval(self.updateLabels,1)
        for i in range(0,48):
            self.l = Label(text="input " + str(i+1))
            if self.indicators[i] == False:
                self.l.color=self.red
            elif self.indicators[i] == True:
                self.l.color = self.green
            self.add_widget(self.l,i) #When i put in the index number self.ljust changes position...

    def updateLabels(self,dt):
        self.indicators=mp.readInputs(qty=48)
        self.l.color = self.green #Here i want to be able to change all 48 label colors...
John Anderson

You can keep a list of the Labels. For example, use self.labels:

class InputGrid(GridLayout):
    def __init__(self,**kwargs):
        super().__init__(**kwargs)
        self.labels = []
        self.cols = 8
        self.indicators=mp.readInputs(qty=48)
        self.red = (1, 0, 0, 1)
        self.green = (0, 1, 0, 1)
        Clock.schedule_interval(self.updateLabels,1)
        for i in range(0,48):
            self.l = Label(text="input " + str(i+1))
            self.labels.append(self.l)
            if self.indicators[i] == False:
                self.l.color=self.red
            elif self.indicators[i] == True:
                self.l.color = self.green
            self.add_widget(self.l,i) #When i put in the index number self.ljust changes position...

    def updateLabels(self,dt):
        self.indicators=mp.readInputs(qty=48)
        for l in self.labels:
            l.color = self.green #Here i want to be able to change all 48 label colors...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

why is my code not giving the proper output?Can anyone provide a hint?

Can anyone tell me why my triggers are not working the way I intended them to?

SQL Can anyone find an error in my query?

Can anyone help me to optimize my query?

Can anyone tell why my algorithm is wrong?

Can anyone see the flaw in my code?

can anyone pinpoint the error in my recursive function?

Can anyone generate mongodb query for my scenario

anyone can find the syntax misstake in my php?

Can anyone help me with my currency shop?

Can anyone notice where the mistakes is in my code?

Is there a way to type hint that a tuple can be searched in a binary way?

Is there a way to hint the passed argument type to IDE (in my case Webstorm) in Javascript?

Printing trees - Is there a way to ensure text in Kivy labels is aligned perfectly?

Is there a way to hint that an attribute can't be None in certain circumstances?

Can anyone with physical access to my computer access my files?

What type hint can I use in Python if my type is a function?

Is there a way I can call a function for each html element when iterated using javascript loops

Ensure that an argument can be iterated twice

Can a MagicMock object be iterated over?

Regex performance issue - can anyone explain way this regex is slow

PHP too slow, can anyone see a way to make it faster?

Is there a way to create a process which can be killed by anyone in Linux?

Can anyone advise of a way to set a universal quit-application shortcut?

Can anyone tell me why my alert not working

CentOS 7 Share a file on my network so anyone can download it

Can anyone help me to create Dockerfile for my tomcat copy?

Can anyone tell me why my program is going in infinite Loop?

Can anyone explain why my program is not showing the correct alert?