Scrollable Boxlayout

885 views
Skip to first unread message

Mihály Mirk

unread,
Jun 7, 2016, 8:30:05 AM6/7/16
to Kivy users support
Hi all,

I would like to ask your help.

The scrollable structure in the attachment is what I want to generate.

As the Scrollview accept only one element, I used a GridLayout. Somehow I cannot put any Boxlayout in the GridLayout.

Could you help me? Did I made a mistake? Should I use maybe an other Layout? if yes, which one?


Thank you,
Mihaly


Here is what I tried in the .kv file:



#:kivy 1.8.0

RootWidget:

    # import container
    container: container

    # fill container
    BoxLayout:
        id: container
orientation: 'vertical'
padding: 0
spacing: 3

ScrollView:
size_hint: 1, 1
pos_hint: {'center_x': .5, 'center_y': .5}

GridLayout:
cols: 2
padding: 0
spacing: 3
size_hint: 1, None
height: self.minimum_height
do_scroll_x: False


                       
        BoxLayout:
                                        height: 260
        orientation: 'horizontal'
                                 canvas.before:
                                    Color:
                                         rgb: 0.7, 0.7, 0.9
                                     Rectangle:
                                         size: self.size
                                         pos: self.pos


                        
         BoxLayout:
                                        height: 260
         orientation: 'horizontal'
                                 canvas.before:
                                    Color:
                                         rgb: 0.7, 0.7, 0.9
                                     Rectangle:
                                         size: self.size
                                         pos: self.pos


         BoxLayout:
                                        height: 260
         orientation: 'horizontal'
                                 canvas.before:
                                    Color:
                                         rgb: 0.7, 0.7, 0.9
                                     Rectangle:
                                         size: self.size
                                         pos: self.pos


         BoxLayout:
                                        height: 260
         orientation: 'horizontal'
                                 canvas.before:
                                    Color:
                                         rgb: 0.7, 0.7, 0.9
                                     Rectangle:
                                         size: self.size
                                         pos: self.pos

         BoxLayout:
                                         height: 260
         orientation: 'horizontal'
                                 canvas.before:
                                    Color:
                                         rgb: 0.7, 0.7, 0.9
                                     Rectangle:
                                         size: self.size
                                         pos: self.pos

MyLabel:
height: 260
size_hint: 1, None
text: 'Typ'

kv.PNG

Richard DeVost

unread,
Jun 10, 2016, 12:24:27 AM6/10/16
to Kivy users support
Hi Mihály,

A few suggestions for your code:
  1. The indentation of ScrollView is one tab too many. It should line up with id.
  2. Don't give ScrollView size attributes. The next line should be an indented GridLayout or preferably a BoxLayout.
  3. I've found BoxLayouts more flexible to work with than GridLayout. So consider using a BoxLayout as the one widget inside the ScrollView.
  4. Add a size_hint_y: None before each of the height: 260 lines. 
Good luck,
Richard

Mihály Mirk

unread,
Nov 21, 2016, 6:59:42 AM11/21/16
to Kivy users support
Thx, it helped me a lot.
Reply all
Reply to author
Forward
0 new messages