Кивый макет.Как заполнить все пространство? - PullRequest
0 голосов
/ 06 марта 2019

Что я должен изменить в приведенном ниже коде, чтобы метки RecycleView заполняли все пространство между кнопками Add и Done? Я пробовал с size_hint_x: None и многими другими. Как устроены макеты, так сложно понять ...

from kivy.config import Config
Config.set('graphics', 'multisamples', '0')
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.recycleboxlayout import RecycleBoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.behaviors import FocusBehavior
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
from kivy.properties import ObjectProperty
kv = """
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
ScreenManager:
    transition: FadeTransition()
    Requests:


<Main>

    materialType:     request_material.text
    materialLength:   materials_type_length_spinner.text
    materialsQuantity: materials_type_quantity_spinner.text

    BoxLayout:

        size_hint_y: None
        height: 25

        GridLayout:
            cols: 4
            #size_hint_x: None
            Spinner:
                id: request_material
                width: 60
                size_hint_x: None
                text: 'SC/SC'
                values: ['SC/SC','SC/LC', 'LC/LC', 'RJ45', 'ODF']
            Spinner:
                id: materials_type_length_spinner
                size_hint_x: None
                width: 25
                text: 'L'
                values: ['1','2','3','4','5','6','7','8','9','10','11','12']
            Spinner:
                id: materials_type_quantity_spinner
                size_hint_x: None
                width: 25
                text: 'Q'
                values: ['1','2','3','4','5','6','7','8','9','10','11','12']
            Button:
                size_hint_x: None
                width: 40
                text: "Add"
                on_press: root.add_materials()
        RecycleView:
            id: materials_recycle_view
            viewclass: 'Label'            
            SelectableRecycleBoxLayout:
                spacing: 15
                default_size: 100, dp(25)
                default_size_hint: None, None
                size_hint_y: None
                height: self.minimum_height
                orientation: 'horizontal'
        Button:
            size_hint_x: None
            width: 42
            text: "Done"


<Requests>
    Main:

"""
class SelectableRecycleBoxLayout(FocusBehavior, LayoutSelectionBehavior,
                                 RecycleBoxLayout):
    pass

class Main(BoxLayout):

    materialType =     ObjectProperty()
    materialLength=    ObjectProperty()
    materialsQuantity= ObjectProperty()

    materialsTab = []

    def add_materials(self):

        material = self.materialType + " " + self.materialLength + "m " + self.materialsQuantity + "pcs"

        dict = {}
        dict.update({'text': material})

        self.materialsTab.append(dict)
        print(self.materialsTab)
        self.ids.materials_recycle_view.data = self.materialsTab
        print(self.materialsTab)

class Requests(Screen):
    pass

class ScreenManagement(ScreenManager):
    pass

sm = Builder.load_string(kv)

class TestApp(App):
    def build(self):
        return sm

if __name__ == '__main__':
    TestApp().run()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...