Home > kivy, multitouch, python > Kivy – Multiple Layouts

Kivy – Multiple Layouts

September 14th, 2011 Leave a comment Go to comments

I wonder how can I have several layouts and change between them using kv files in kivy. Actually I have the answer.

You have to create an ejercicio.kv file. You have to define the classes you are going to use for each layout such as.

#:kivy 1.0





Once we have our definitions for each layout, we have to implement the python part and create classes for each definition.

import kivy

from kivy.uix.floatlayout import FloatLayout
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.app import App

class Ejercicio(FloatLayout):
    def do_action(self):

class Layout1(FloatLayout):
def do_action(self):

class Layout2(FloatLayout):
     def do_action(self):

class MyLabelWithBackground(Label):

class EjercicioApp(App):
    def build(self):
parent = Widget()
        #a = Ejercicio(size=(1024, 768))
b = Layout1(size=(1024, 768))
        #c = Layout2(size=(1024, 768))
        #d = MyLabelWithBackground(text=”Hola mundo”)
        return parent

if __name__ in (‘__android__’, ‘__main__’):

You can change between each definition uncomment the source.

Categories: kivy, multitouch, python Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.