1

I am new to Kivy and I am trying to understand the for loops between the two when introducting a variable I pull in from another file in my program. I got this to work without using a kv file but everything I see says using kv files makes life easier so I am trying to learn that path, also in my code of not using a kv file I have a hard time auto sizing everything and it seems easier using the kv file as I really will be making 3 column wide data sets up to 150 rows or more, what I also do not understand is how to dynamically update my var that I pull into the kv file for text within the labels. Here is my current code, when I run it it only gives me one set of labels that is in the kv file but it does not loop through my lists.

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder
from GRABBING_TEAM_DATA_FROM_SCHEDULE import test_points
from GRABBING_TEAM_DATA_FROM_SCHEDULE import test_home_team_over
from GRABBING_TEAM_DATA_FROM_SCHEDULE import test_away_team_over
from ADJUSTING_PROJECTED_SCORES_MORE import total_point_list
from kivy.properties import StringProperty

test_points = [i.tolist() for i in test_points]
test_total_points = [i.tolist() for i in total_point_list]

testing = list()

class MyLabel(Widget):
    pass

class MyApp(App):
    pyh = StringProperty('')
    ppt = StringProperty('')
    ppu = StringProperty('')
    yahoo = 0
    lee = len(test_total_points)
    print(lee)
    legn = test_total_points
    def build(self):
        self.yahoo = 0
        self.legn = test_total_points
        lee = test_total_points
        for i in range (len(lee)):
            self.yahoo += 1
            self.pyh = str(test_total_points[self.yahoo])
            self.ppt = str(test_home_team_over[self.yahoo])
            self.ppu = str(test_away_team_over[self.yahoo])

        return FloatLayout()
if __name__ == "__main__":
    MyApp().run()

kv file

<FloatLayout>:

    BoxLayout:
        orientation: 'vertical'

        GridLayout:
            cols: 3
            rows: app.lee
            Label:
                text: "HOME:"
                size: self.texture_size
            Label:
                text: "AWAY:"
                size: self.texture_size

            Label:
                text: "SCORE"
                size: self.texture_size

            HomeTeamLabel:
                text: app.ppt


            AwayTeamLabel:
                text: app.ppu



            ScoreLabel:
                text: app.pyh








<HomeTeamLabel@Label>:
    text: "HOME"
    size: self.texture_size

<AwayTeamLabel@Label>:
    text: "AWAY"
    size: self.texture_size

<ScoreLabel@Label>:
    text: "YEYEAYAYAY"
    size: self.texture_size

enter image description here

It gives me my first set of labels, but the length of that list is 38 so I really want to stamp this layout 38 more times while iterating through my lists. Appreciate any help.

Josh
  • 353
  • 3
  • 13

1 Answers1

1

I am also new to Kivy, but I think you are looking for this. (How to put multiple columns into a kivy RecycleView?)!

check it out. it's the basic format, with some edits you can also have more layouts in the same window.

Alex
  • 72
  • 1
  • 11
  • Thanks! @Image, this looks like what I need, was consumed by another part of my code all night so far, plan on trying this tomorrow! Will report back. – Josh Jan 08 '21 at 04:18