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

Kivy – Multiple Layouts

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: