Newbie question: ScrollView doesn't have visible scroll bars (and sizing issues)?

1,045 views
Skip to first unread message

Rene Horn

unread,
Nov 25, 2012, 12:47:59 AM11/25/12
to kivy-...@googlegroups.com
I was playing around with the Bubble example code (http://kivy.org/docs/api-kivy.uix.bubble.html, and but_bubble is amusing) and decided to add a text box so I could add more BubbleButtons, and then decided to add a ScrollView so that when it got too big, it could just be scrolled, but I noticed that there didn't seem to be any visible hints that it was scrollable.  Is this normal?

Here's the code: http://bpaste.net/show/A1YChOuOPXalgrrpSLRF/

Also, for some reason, the width of the scroll view became the width of the window, and the bubble is now on the left side--neither of which were intended.  I was hoping that it would just stay in the middle, but I'm not exactly sure I completely understand how its sizing and positioning of things work.  How should that be changed so that the scroll view has just a small width in the center again?

Rene

Rene Horn

unread,
Nov 25, 2012, 1:49:24 AM11/25/12
to kivy-...@googlegroups.com
Ok, so I figured out the problem with the size issue, and realized that I misread the documentation on ScrollView, and thought that it said that the size_hint had to be disabled on the ScrollView widget itself instead of the child, so the show_bubble function looks like this:

   
def show_bubble(self, *l):
       
if not hasattr(self, 'bubb'):
           
self.bubb = bubb = cut_copy_paste()
           
self.scroller = ScrollView(size_hint=(None, None), size=(160, 100),
                                       pos_hint
={'center_x': .5, 'y': .6})
           
self.scroller.add_widget(bubb)
           
self.add_widget(self.scroller)
       
else:
            values
= ('left_top', 'left_mid', 'left_bottom', 'top_left',
               
'top_mid', 'top_right', 'right_top', 'right_mid',
               
'right_bottom', 'bottom_left', 'bottom_mid', 'bottom_right')
            index
= values.index(self.bubb.arrow_pos)
           
self.bubb.arrow_pos = values[(index + 1) % len(values)]


Full source code here: http://bpaste.net/show/8MvTXf1y7NeAErY44SOa/

This doesn't solve my main issue with ScrollView in that there are no visible scroll bars or anything to indicate that anything can be scrolled.

Rene

Akshay Arora

unread,
Nov 25, 2012, 10:26:29 AM11/25/12
to kivy-...@googlegroups.com
Hello Rene,

ScrollBars are only visible by default when scrolling. You could override the scrollview rule in your kv and set it otherwise.


<ScrollView>:
    canvas.after:
        Color:
            rgba: self.bar_color[:3] + [self.bar_color[3] * 1 if self.do_scroll_y else 0]
        Rectangle:
            pos: self.right - self.bar_width - self.bar_margin, self.y + self.height * self.vbar[0]
            size: self.bar_width, self.height * self.vbar[1]
        Color:
            rgba: self.bar_color[:3] + [self.bar_color[3] * 1 if self.do_scroll_x else 0]
        Rectangle:
            pos: self.x + self.width * self.hbar[0], self.y + self.bar_margin
            size: self.width * self.hbar[1], self.bar_width

The code  above just is a extracted from style.kv and only changes `self.bar_alpha` with `1`, this should provide a constant white scroll bar on the right and bottom edges. You can adjust the look and feel by setting variables like `bar_color` , `bar_width`and `bar_margin`.

Regards

--
 
 

Reply all
Reply to author
Forward
0 new messages