scroll view not scrolling -

1,232 views
Skip to first unread message

Leon A

unread,
Oct 14, 2013, 2:07:07 PM10/14/13
to kivy-...@googlegroups.com
I have a feeling its because of the way i've implemented it.

Any reason why this is not scrolling guys and gals? 

import kivy
from scapy.all import *
from kivy.uix.stacklayout import StackLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.app import App
from kivy.uix.scrollview import ScrollView
from kivy.properties import ObjectProperty

Builder.load_string('''
<RebornTool>:
   
    scrll: scrll
    box: box
    orientation: '
tb-lr'
    cols: 2
    spacing: 4
    canvas:
        Rectangle:
            source: '
bg.jpg'
            size: self.size

    BoxLayout:
        size_hint: .5, None
        orientation: '
horizontal'
        Button:
            text: '
connection info'
           
    BoxLayout:
        size_hint: .5, .65
        orientation: '
horizontal'
        Label:
            text: '
Filler'
       
    BoxLayout:
        size_hint: .5, None
        orientation: '
horizontal'
        Button:
            text: '
Scan'
            on_release: root.results()
        Button:
            text: '
Exit'    

    ScrollView:
        id: scrll
        size_hint:(None, None)
        minimum_height:scrll.setter('
height')
        BoxLayout:
            id: box
            orientation: '
vertical'
            size_hint:(None, None)
'''
)

#mainscreen
class RebornTool(StackLayout):
   
def __init__(self, **kwargs):
       
super(RebornTool, self).__init__(**kwargs)
        box
= ObjectProperty()
        scrll
= ObjectProperty()
       
def results(self):
                               
       
for i in range(30):
                    btn
= Button(text=str(i),
            size_hint_y
=None,height=40)
           
self.box.add_widget(btn)
       
class RebornApp(App):
   
def build(self):
       
return RebornTool()

if __name__=='__main__':
   
RebornApp().run()



ZenCODE

unread,
Oct 14, 2013, 3:28:11 PM10/14/13
to kivy-...@googlegroups.com
It's not scrolling because there is nothing in it. Try modding your kv as follows, changing the image source to a pic on your disc.

The trick is to set the scrollview contents size. Take away the image to see where exactly the scrollview is.

')
       
        canvas:
            Color:
                rgba: 1, 0, 0, 0.5
            Rectangle:
                size: self.size
                pos: self.pos
        Image:
            id: box            
            source: '
/mnt/Zen320/Zen/My Pictures/Computer/00591calmafterthestorm1600x120.jpg'
            size: 1020, 1000
#        BoxLayout:
#            id: box
#            orientation: '
vertical'
            size_hint:(None, None)


'''
)
Hope that helps ;-)

Cheers

Leon A

unread,
Oct 14, 2013, 3:53:58 PM10/14/13
to kivy-...@googlegroups.com
Cheers Zen, im  a little confused tho,.In my original code when you click the scan button the scroll view is populated by a boxlayout which has 29 buttons so it is populated. or is this wrong?

ZenCODE

unread,
Oct 14, 2013, 4:04:55 PM10/14/13
to kivy-...@googlegroups.com
I think the issue there is that the BoxLayout does not have a size. If you set the it's size hint to (None, None) and manually give it a width and height (like the image), it should work? You might want to try with labels first to eliminate the possibility of the button consuming the on_touch_down events...(have not worked much with ScrollViews...;-)

ZenCODE

unread,
Oct 14, 2013, 4:07:46 PM10/14/13
to kivy-...@googlegroups.com
ps. I see you set the hieght of the buttons to 40, so you probably want this after you loop/

    self.box.size_hint_y = None
   
self.box.height = 30 * 40



Leon A

unread,
Oct 14, 2013, 4:15:22 PM10/14/13
to kivy-...@googlegroups.com
Once again zen you are da man!! scrolling away :)
Cheers Mate.

Gully

unread,
Oct 15, 2013, 3:52:43 AM10/15/13
to kivy-...@googlegroups.com
As someone once suggested here, this is a good place to use a GridLayout with the desired number of cols/rows and setting

size: self.minimum_size

which automatically does the calculation for you :)

ZenCODE

unread,
Oct 15, 2013, 4:40:36 AM10/15/13
to kivy-...@googlegroups.com
Nicer! Thanks Gully

Leon A

unread,
Oct 15, 2013, 11:30:50 AM10/15/13
to kivy-...@googlegroups.com

Thanks for the Info :)

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/RojDZPmhW9o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages