Skip to content

Instantly share code, notes, and snippets.

@Alan-FGR
Last active August 29, 2015 14:27
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 Alan-FGR/49a7fcaef57c62c9a03c to your computer and use it in GitHub Desktop.
Save Alan-FGR/49a7fcaef57c62c9a03c to your computer and use it in GitHub Desktop.
kivy gridlayout problem
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.app import Builder, App
from random import randint
Builder.load_string("""
<GridLayout>:
canvas:
Color:
rgba: 1,0,0,1
Line:
rectangle: self.x+1,self.y+1,self.width-1,self.height-1
<Image>:
canvas:
Color:
rgba: (0,1,0,0.3)
Rectangle:
pos: self.pos
size: self.size
<Label>:
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
""")
class ACListEntry(GridLayout):
def __init__(self, **kwargs):
super(ACListEntry, self).__init__(cols=2, size_hint_y=None, **kwargs)
self.bind(minimum_height = self.setter("height"))
img = Image(size_hint = (None,None), size = (60,60), source = "")
self.add_widget(img)
lbl = Label(text="TEST layout problem fds af dfsad fsd asdfs adfsad fdsf "*randint(1,6))
self.add_widget(lbl)
class MyApp(App):
def build(self):
mainlayout = GridLayout(cols=1)
for _ in xrange(5):
mainlayout.add_widget(ACListEntry())
return mainlayout
MyApp().run()
@Alan-FGR
Copy link
Author

Hey guys, any ideas why the code above doesn't produce the expected result? ACListEntry ends up very tall. definitely not the minimum_height.

@Alan-FGR
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment