Skip to content

Instantly share code, notes, and snippets.

@amalgamatedclyde
Created January 4, 2014 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalgamatedclyde/8257202 to your computer and use it in GitHub Desktop.
Save amalgamatedclyde/8257202 to your computer and use it in GitHub Desktop.
if i add the gridlayout directly to the scrollview instead of adding it to the relative layout the scroll works
import kivy
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.relativelayout import RelativeLayout
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
from kivy.config import Config
Config.set('graphics', 'width', '1920')
Config.set('graphics', 'height', '1200')
kivy.require('1.8.0')
button_list = []
everyone = [ i for i in range(117)]
class MyGridLayout(GridLayout):
def __init__(self, **kwargs):
super(MyGridLayout, self).__init__(**kwargs)
self.bind(minimum_height=self.setter('height'))
s = ScrollView()
r = RelativeLayout(size_hint_y = None)
g= MyGridLayout(cols=5, size_hint_y = None)
r.size = g.size
r.add_widget(g)
for i in everyone:
b= Button(text = str(i), size_hint= (None, None), size = ('150dp', '150dp'))
g.add_widget(b)
r.pos_hint = {'top': 1}
s.add_widget(r)
s.pos_hint = {'top': 1}
c = FloatLayout()
c.add_widget(s)
class testApp(App):
def build(self):
return c
if __name__ == '__main__':
testApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment