Text box with dynamic scrollbar?

843 views
Skip to first unread message

Maxim Tsoy

unread,
Oct 2, 2013, 8:09:55 AM10/2/13
to kivy-...@googlegroups.com
Hi! I need to create a widget for displaying a console log in my app.
The ideal solution would be the readonly text box with a scrolling feature.
Unfortunately, I didn't manage to get this behavior with TextInput (or Label) and ScrollView, because ScrollView requires included widget to have a pre-defined height. But I need the infinite text input height in common case.
What is the best way to solve this problem? Do I miss something about TextInput? I think it is very common situation...

Akshay Arora

unread,
Oct 2, 2013, 2:56:35 PM10/2/13
to kivy-...@googlegroups.com
Hi,
textinput has a minimum_height which is updated based on content, this should be used to set the height  of the textinput just like in gridlayout.

This feature might only be available in 1.8.0 dev version, before that you needed to do the calculation yourself using the no of lines and line_height

regards


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Maxim Tsoy

unread,
Oct 2, 2013, 3:55:42 PM10/2/13
to kivy-...@googlegroups.com
Thank you so much!
I was wondering how did I know the number of lines, but this answer helped me. Thanks again ;)

среда, 2 октября 2013 г., 22:56:35 UTC+4 пользователь qua-non написал:

Akshay Arora

unread,
Oct 2, 2013, 4:36:28 PM10/2/13
to kivy-...@googlegroups.com
I've updated the answer on SO to include the new way for 1.8.0. If that answer helped you then maybe up vote it so others looking for similar questions can easily find it.

Maxim Tsoy

unread,
Oct 3, 2013, 1:30:38 PM10/3/13
to kivy-...@googlegroups.com
One more thing: can something similar be done with Label? There's nothing like _lines in that class, but maybe texture property would help?

четверг, 3 октября 2013 г., 0:36:28 UTC+4 пользователь qua-non написал:

Akshay Arora

unread,
Oct 3, 2013, 1:55:56 PM10/3/13
to kivy-...@googlegroups.com
If you set the `text_size` to let's say `100, None` the text would be unrestricted on the height and wrap when it is greater than 100 pixels. You can then use label.texture_size[1] to get the height of the text...

To understand text_size take a look at examples/widgets/text_align.py and search for kivy text_alignment on SO.
Reply all
Reply to author
Forward
0 new messages