Skip to content

Instantly share code, notes, and snippets.

@Kovak
Created August 11, 2013 20:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Kovak/6206701 to your computer and use it in GitHub Desktop.
Save Kovak/6206701 to your computer and use it in GitHub Desktop.
Nesting Box Layouts in Kivy
from kivy.app import App
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
class HBoxWidget(Widget):
def __init__(self, **kwargs):
super(HBoxWidget, self).__init__(**kwargs)
class VBoxWidget(Widget):
def __init__(self, **kwargs):
super(VBoxWidget, self).__init__(**kwargs)
class ContainerBox(BoxLayout):
def __init__(self, **kwargs):
super(ContainerBox, self).__init__(**kwargs)
class TestApp(App):
def build(self):
return ContainerBox()
if __name__ == '__main__':
TestApp().run()
<HBoxWidget>:
BoxLayout:
size: root.size
pos: root.pos
id: boxlayout_h
orientation: 'horizontal'
ToggleButton:
text: 'h1'
group: 'test'
ToggleButton:
text: 'h2'
group: 'test'
<VBoxWidget>:
BoxLayout:
orientation: 'vertical'
size: root.size
pos: root.pos
ToggleButton:
text: 'v1'
group: 'test'
ToggleButton:
text: 'v2'
group: 'test'
<ContainerBox>:
orientation: 'horizontal'
HBoxWidget:
VBoxWidget:
@mrroot5
Copy link

mrroot5 commented Mar 6, 2017

Thanks to your code. I can build my layout with boxlaytout and nesting gridlayout :-)

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