Как сделать чтобы переменные присваивали значения и выводились на экраны в KV файле по нажатию кнопки на экране MainWindow?

main.py:

from kivymd.app import MDApp
from kivymd.theming import ThemeManager
from kivy.core.window import Window
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.screenmanager import Screen

from database_module import search_dishes1

Config.set('kivy', 'keyboard_mode', 'systemanddock')

Window.size = (380, 700)

class MainWindow(Screen):
    def scit(self):
        global dish
        if self.text_input.text.strip() != '':
            znach = self.text_input.text

        dish = search_dishes1(znach)
        print(dish)
        return dish
    dish = ''


class FirstScreen(Screen):
    def per(self):
        global found_dishes
        found_dishes = MainWindow().dish
        return found_dishes
    found_dishes = ""
    pass
class SecondWindow(Screen):
    pass

class WindowManager(ScreenManager):

    pass

class MyApp(MDApp):
    theme_cls = ThemeManager()
    title = 'Easy Recipes'



MyApp().run()

My.kv:

WindowManager:
    MainWindow:
    SecondWindow:
    FirstScreen:

<ItemLabel@MDLabel>:
    font_size: '35sp'
    valign:'middle'
    text_size: self.size

<MainWindow>:
    canvas.before:
        Color:
            rgba: (211/255, 71/255, 33/255,0.36)
        Rectangle:
            pos: self.pos
            size: self.size
    name: 'main_window'
    text_input:text_input
    GridLayout:

        rows: 20
        padding: [30, 150, 30, 10]

        MDTextField:
            id:text_input
            size_hint: 4, 2.4
            mode: "fill"

            multiline: True
            font_size: '45sp'
            input_type: 'text'
            hint_text: 'Введите основной продукт здесь:'
            helper_text: "Вводите продукты через пробел"
            hint_text_color_focus: "green"
            helper_text_mode: "persistent"
            helper_text_color_focus: "green"
            text_color_focus: "green"
            fill_color_normal: (211/255, 71/255, 33/255,0.16)
            fill_color_focus: (211/255, 71/255, 33/255,0.26)
        FloatLayout:
            MDLabel:

                text: 'Easy Recipes'
                halign: "center"
                font_size: '40sp'
                size_hint_y: 1
                pos_hint: {'center_x':0.5,'y': 3.5}
                color:'green'
            MDFillRoundFlatButton:
                size_hint: 0.6, 0.4
                pos_hint: {'center_x':0.5,'y': 0.3}
                text: 'Найти блюда'
                font_size: '25sp'
                md_bg_color: (0, 172/255, 0,0.72)


                on_release:
                    root.scit()
                    app.root.current = "main_window" if text_input.text == "" else "second_window"



<FirstScreen>:

    name:'first_screen'

    BoxLayout:
        orientation: 'vertical'
        ScrollView:
            StackLayout:


                cols:1

                spacing: 0.1
                padding:0.1
                size_hint_y: 1.5

                MDBoxLayout:
                    pos_hint: {'center_x':0.5,'y': 1}
                    MDBoxLayout:
                        pos_hint: {'center_x':0.5,'y': 0.5}
                        orientation: "vertical"
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 1
                        spacing: 1
                        size_hint:0.5, 0.4

                        Image:
                            source: "Icon3.jpg"
                            center_x: self.parent.center_x
                            center_y: self.parent.center_y

                        MDLabel:
                            text: root.per()
                            halign: "center"
                            font_size: '20sp'
                            size_hint_y: 0.1
                            pos_hint: {'center_x':0.5,'y': 0.5}
                        MDLabel:
                            text:'описание рецепта'
                            halign:'center'
                            size_hint_y: 0.5
                            pos_hint: {'center_x':0.5,'y': 0.7}
<SecondWindow>:
    name: 'second_window'
    BoxLayout:
        orientation: 'vertical'
        #spacing:30
        #padding:3


        ScrollView:
            GridLayout:


                cols:2
                rows:6
                spacing: 10
                padding:5
                size_hint_y: 1.2
                MDLabel:

                    text:'Выберите блюдо'
                    halign: "center"
                    size_hint_y: '0.1sp'
                    pos_hint: {'bottom': 1}
                MDLabel:
                    text:' '
                    halign: "center"
                    size_hint_y: '0.1sp'
                    pos_hint: {'center_x':0.5,'center_y': 0.5}
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='first_screen'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'
                BoxLayout:
                    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
                    MDBoxLayout:
                        orientation: "vertical"
                        size_hint_y: '0.5sp'
                        radius: [20, 20, 20, 20]
                        md_bg_color: app.theme_cls.bg_darkest
                        padding: 5
                        spacing: 5
                        size_hint:0.5, 0.8
                        Button:

                            size_hint: 0.58,0.22
                            pos_hint: {'center_x': 0.5, 'center_y': 0.4}
                            background_color: 1,2,0.5,1
                            on_release:
                                app.root.current='1'
                                root.manager.transition.direction='left'
                            Image:


                                source: "Icon3.jpg"
                                center_x: self.parent.center_x
                                center_y: self.parent.center_y



                        MDLabel:
                            text: "Dish Name"
                            halign: "center"
                            size_hint_y: '0.1sp'

database_module.py:

def search_dishes1(query):
    arrayOfFoundDishes = []
    prod = query.split(',')
    global search_dishes
    for i in range(len(search_dishes)):
        for j in range(len(prod)):

            if prod[j] in search_dishes[i]:
                if search_dishes[i] not in arrayOfFoundDishes:

                    arrayOfFoundDishes.append(search_dishes[i])
    return arrayOfFoundDishes



search_dishes = ['Венский Гуляш: Говядина, Лук репчатый, Паста томатная, Паприка, Масло растительное, Вода, Соль, Перец черный молотый']

Ответы (1 шт):

Автор решения: Serega89s

znach = self.ids.text_input.text

→ Ссылка