My kivy widgets are cramped together and I need them to have some distance

The following is a problem I have with the kivy module. When I created my first 3-4 widgets of the FirstScreen class – everything was fine, but after that the widgets started to occupy the same space that they used to, without expanding up. Maybe it’s a problem of the ScrollView. There is no kv file
the widgets are shown here

from functools import partial

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import Screen, ScreenManager, NoTransition
from kivy.uix.scrollview import ScrollView
from kivy.uix.textinput import TextInput

class YogaApp(App):
    def build(self):
        self.sm = ScreenManager(transition=NoTransition())
        self.sm.add_widget(FirstScreen(name='First'))
        self.sm.add_widget(SecondScreen(name='Second'))
        self.sm.add_widget(ThirdScreen(name='Third'))
        self.sm.add_widget(FourthScreen(name='Fourth'))
        self.sm.add_widget(FifthScreen(name='Fifth'))
        # self.sm.current = 'Second' # Для того чтобы тестировать шаблоны. УБРАТЬ ПОТОМ
        return self.sm
    def change_screen_manager(self, screen):
        self.sm.current = screen

class FirstScreen(Screen):
    """The first screen the user sees. It is the screen for creating a workout or a workout
    template. It also shows all of your created templates which you can click for the second
    screen to pop up
    """
    total_training_sessions = 0
    total_training_sessions_text = 'Всего тренировок: ' + str(total_training_sessions)
    # Это шаблоны тренировок
    templates = {}
    # А это все упражнения
    # exercises = []

    def __init__(self, **kwargs):
        """
        Creates all widgets and adds them on the first screen. Creates templates that
        are a button with the text of the name and the exercises of the template.
        It does so by extracting the template name and values from the dictionary 'templates'
        
        :param kwargs:
        """
        super(FirstScreen, self).__init__(**kwargs)
        self.layout_root = ScrollView(do_scroll_x=False, do_scroll_y=True, size_hint=(1, None))
        self.layout = BoxLayout(orientation='vertical', size_hint=(1, 1))
        self.lbl1 = Label(text=self.total_training_sessions_text)
        # Кнопка, при нажатии которой откроется второй экран
        self.btn_create = Button(text='Создать Шаблон', on_press=partial(app.change_screen_manager, 'Second')) #Don't mind this. The partial function doesn't work
        # self.btn_create.bind(on_press= изменить sm.current на второй экран)
        self.lbl2 = Label(text='Шаблоны:')  # , pos_hint={'x': -0.42}

        self.layout.add_widget(self.lbl1)
        self.layout.add_widget(self.btn_create)
        self.layout.add_widget(self.lbl2)

        import os
        for filename in os.listdir('templates'):
            with open(os.path.join('templates', filename), 'r', encoding='utf-8') as file:
                self.lbl_name = Label(text = str(filename.replace('.txt', '')))
                self.layout.add_widget(self.lbl_name)
                k=0 #Считает кол-во упражнений в шаблоне
                while True:
                    exercise_info = file.readlines(2)
                    k+=1
                    if not exercise_info:
                        break
                    num_of_exercise, exercise = exercise_info
                    num_of_exercise = str(num_of_exercise.replace("n", ""))
                    exercise = str(exercise.replace("n", ""))
                    text_1 = str(k) + " - " + exercise + " x" + num_of_exercise
                    self.template_lbl = Label(text = text_1)
                    self.layout.add_widget(self.template_lbl)
                self.template_btn = Button() # will actually make the button when the problem is fixed
                    




        self.layout_root.add_widget(self.layout)
        self.add_widget(self.layout_root)
    def create_widgets(self):
        for template in self.templates:
            pass



class SecondScreen(Screen):
    def __init__(self, **kwargs): # add template
        super(SecondScreen, self).__init__(**kwargs)
        self.create_widgets() #ТОЖЕ УБРАТЬ

    def create_widgets(self):#, template):

        # for x in template.keys():
        #    name = str(x)
        name = 't1'
        layout_root = ScrollView(do_scroll_x=False, do_scroll_y=True, size_hint=(1, None))
        layout = BoxLayout(orientation='vertical')
        lbl1 = Label(text=name)
        btn_rest = Button()
        btn_start = Button()
        # btn_cancel = CancelButton()
        # self.btn_cancel = Button(text='Отмена', on_press=app.sm.switch_to('First'))
        # self.ids['cancel'] = Button()
        # self.ids['layout'].add_widget(self.btn_start) НЕ РАБОТАЕТ
        # self.ids['layout'].add_widget(self.btn_rest)
        layout.add_widget(lbl1)
        layout.add_widget(btn_rest)
        layout.add_widget(btn_start)
        # layout.add_widget(btn_cancel)
        layout_root.add_widget(layout)
        self.add_widget(layout_root)




class ThirdScreen(Screen):
    def __init__(self, **kwargs):
        super(ThirdScreen, self).__init__(**kwargs)
        self.layout_root = ScrollView(do_scroll_x=False, do_scroll_y=True, size_hint=(1, None))
        self.layout = BoxLayout(orientation='vertical')
        self.name_input = TextInput(text='Название Шаблона', multiline=False, size_hint = (0.8, None), height='100dp')


class FourthScreen(Screen):
    def __init__(self, **kwargs):
        super(FourthScreen, self).__init__(**kwargs)


class FifthScreen(Screen):
    def __init__(self, **kwargs):
        super(FifthScreen, self).__init__(**kwargs)

if __name__ == '__main__':
    app = YogaApp()
    app.run()

I have tried giving pos_hint = {‘top’: 1} to the first widget. Didn’t work (probably should have expected that)
I thought that the BoxLayout doesn’t occupy all of the space of the ScrollView, so I have given the BoxLayout size_hint = (1,1), but it didn’t work

I have not tried anything else because I have no idea what’s wrong with it

New contributor

Alexey Axyonov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật