I am trying to change the four parent box layout size in kivy using python.
Code -
class Run_app(App):
def b1(self):
self.b1 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.15))
#< ADDED Two to three box layouts to self.b1>
return(self.b1)
def b2(self):
self.b2 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.45))
#< ADDED Two to three box layouts to self.b2>
return(self.b2)
def b3(self):
self.b3 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.20))
#< ADDED Two to three box layouts to self.b3>
return(self.b3)
def b4(self):
self.b4 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.20))
#< ADDED Two to three box layouts to self.b4>
return(self.b4)
def build(self):
self.title = "GUI"
self.root = BoxLayout(orientation="vertical", padding=15, spacing=15, )
self.root.add_widget(self.b1())
self.root.add_widget(self.b2())
self.root.add_widget(self.b3())
self.root.add_widget(self.b4())
return(self.root)
I tried to change the size of the boxes(b1, b2, b3, b4), But the size is not changing, Could you please explain how to change the size of the parent box layout in kivy,
Thank you
If you are setting size
, then you must set size_hint
to None
, otherwise your size
setting will be ignored. For example:
self.b1 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.15), size_hint=(None, None))
Note that a BoxLayout
with a size of (1, 0.15) won't be very useful. Perhaps you meant:
self.b1 = BoxLayout(orientation="horizontal", spacing=10, size_hint=(1, 0.15))
(Just replacing size
with size_hint
).