Problem with kivy/kivymd with adding items into list

Viewed 46

I want to read data from the file and put it into labels in ScrollView, and I found sth like this:

    for name in self.list_of_medicine_global_variable:
        screen.ids.widget_of_list.add_widget(
            MDLabel(
                text=name_theme,
                halign="center",
                theme_text_color=name_theme,
            )
        )

but I don't know what to put instead of "screen.ids...". I just know that, then should be "widget_of_list" cause this is the id

Here are important parts of my code:

class NewMedicineWindow(Screen):
    pass

class MainWindow(Screen):
    pass


class WindowManager(ScreenManager):
   pass


class UtdApp(MDApp):
    name = StringProperty("")
    date = StringProperty("")
    month = StringProperty("")
    year = StringProperty("20")
    used = True
    added_medicine = ""
    list_of_medicine_global_variable = ListProperty([])

    def build(self):
        self.theme_cls.theme_style = "Dark"
        self.theme_cls.primary_palette = "Orange"

I dont't know if it is important but I want to put taht first function in on_start function

And below important part of my kivy file:

<NewMedicineWindow>:
name:"nmw"

BoxLayout:

    orientation: "vertical"
    size: root.width, root.height

    MDToolbar:
        title: "Up To Date Medicine"
        right_action_items: [["plus", lambda x: app.new_medicine()]]

    ScrollView:

        MDList:
            id: widget_of_list

Does sb know how to transform that function to make it work in my code? Please I completely don't know what to do

0 Answers
Related