Skip to content

Instantly share code, notes, and snippets.

@mrroot5
Forked from Kovak/main.py
Last active March 6, 2017 13:40
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 mrroot5/8e8c641d2ce4ddabf943d17a9ae3c88f to your computer and use it in GitHub Desktop.
Save mrroot5/8e8c641d2ce4ddabf943d17a9ae3c88f to your computer and use it in GitHub Desktop.
Nesting Grid Layouts in Kivy
# buttonsgrid.kv
<VideoGrid>
cols: 1
rows: 1
Button:
text: 'Video'
<ButtonsGrid>:
cols: 3
rows: 5
Button:
id: btn00
text: '0,0'
disabled: True
Button:
id:btnUp
text: 'Adelante'
on_press: root.forward(btnUp)
Button:
id: btn02
text: '0,2'
disabled: True
Button:
id:btnLeft
text: 'Izquierda'
on_press: root.left(btnLeft)
Button:
id: btn11
text: '1,1'
disabled: True
Button:
id:btnRight
text: 'Derecha'
on_press: root.right(btnRight)
Button:
id: btn20
text: '2,0'
disabled: True
Button:
id:btnDown
text: 'Atrás'
on_press: root.back(btnDown)
Button:
id: btn22
text: '2,2'
disabled: True
<Status>:
cols: 1
rows: 1
<ContainerBox>:
orientation: 'horizontal'
VideoGrid:
ButtonsGrid
#!/usr/bin/env python3
# App to magane a bot with a webcam
# Py modules
import requests
# Kivy imports
import kivy
kivy.require('1.9.1') # replace with your current kivy version !
# Kivy modules
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
import kivy.uix.gridlayout as gridl
class VideoGrid(gridl.GridLayout):
pass
class ButtonsGrid(gridl.GridLayout):
apiURL = 'https://api.github.com/'
def forward(self, btn):
print(btn.text)
# r = requests.get(self.apiURL + "events")
# response = r.json()
# print(response)
def right(self, btn):
print(btn.text)
# r = requests.get(self.apiURL + "events")
# response = r.json()
# print(response)
def back(self, btn):
print(btn.text)
# r = requests.get(self.apiURL + "events")
# response = r.json()
# print(response)
def left(self, btn):
print(btn.text)
# r = requests.get(self.apiURL + "events")
# response = r.json()
# print(response)
class ContainerBox(BoxLayout):
pass
class ButtonsGridApp(App):
def build(self):
return ContainerBox()
if __name__ == '__main__':
ButtonsGridApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment