0

I'm trying to do write a chat application with an interface that has users names on the side pane that's scrollable.

I have 2 questions:

1- This code is not scrolling, please let me know what I'm doing wrong:

stacklayout2 = StackLayout(orientation='lr-tb',)
## Scrollview layout
scroll_layout = GridLayout(cols=1, 
                           spacing=20,
                           size_hint_y=None
                           )
scroll_layout.bind(minimum_height=layout.setter('height'))

for i in range(10):
    scroll_layout.add_widget(ToggleButton(text=str(i), 
                                          size_hint_y=None, 
                                          height=40
                                          )
                            )


scrollview = ScrollView(size_hint=(.3,.5), do_scroll_x=False)
scrollview.add_widget(scroll_layout)


stacklayout2.add_widget(scrollview)
stacklayout2.add_widget(Button(text='Send',size_hint=(.2,.2)))

s2.add_widget(stacklayout2)

2- Is it the best way to put (clickable/selectable) users on the side pane, I'm doing it right?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
securecurve
  • 5,589
  • 5
  • 45
  • 80
  • why was "size_hint_y=None" commented? it should be activated, or your gridlayout will take exactly 100% of the height and you won't have anything to scroll…, also, didn't you mean "scroll_layout.setter('height')"? – Tshirtman Jan 27 '13 at 12:03
  • It doesn't work with or without "size_hint_y=None" part, so, I thought to take it off until I find the real reason behind the non-scrolling pane -- anyway, I'll remove the comment and update the post. I'm not sure what you mean by your question, are you referring to my second question in the main post? – securecurve Jan 27 '13 at 12:49
  • 1
    Binding of the scroll_layout on 7th row should refer to the scroll_layout: scroll_layout.bind(minimum_height=scroll_layout.setter('height')) – Edu Jan 27 '13 at 13:12
  • Thanks dude, this was really the problem. – securecurve Jan 27 '13 at 13:34
  • @tshirtman you said it first, but I didn't get it, so please add your comment as an answer check-mark it. – securecurve Jan 27 '13 at 13:37
  • also guys I need an answer to my second question, is it the best way to make a scrollable pane of users, by making them clickable buttons or toggle buttons, I'm not sure what is the best approach. – securecurve Jan 27 '13 at 13:39

1 Answers1

3

Resubmitting as answer as requested :)

the error is on the binding,

scroll_layout.bind(minimum_height=scroll_layout.setter('height'))

is what you need, so scrool_layout height is updated when it minimum_heigh is updated.

Tshirtman
  • 5,859
  • 1
  • 19
  • 26
  • Then you got the answer checked, and +1 candy :) – securecurve Jan 28 '13 at 16:06
  • btw, in the non-multiline textinput, I'm using this `on_text_validate`, I went to documentation and I found this line: `Fired only in multiline=False mode, when the user hits ‘enter’. This will also unfocus the textinput.`, how can I keep the focus on the field? – securecurve Jan 28 '13 at 16:14
  • I would set `your_input.focus=True` again in your binding to on_text_validate. :) – Tshirtman Jan 28 '13 at 23:14