In this video I’ll show you how to use the Splitters to split apart different sections or Widgets of your app and allow the user to resize things on the fly.

Splitters allow your user to resize or rearrange parts of your app themselves on the fly. They’re really easy to use, just call a Splitter Widget in your KV file on any widget you want to make resizable. Then set the direction that the splitter will go.

Python Code: split.py
GitHub Code: split.py

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.lang import Builder


# Designate Our .kv design file 
Builder.load_file('split.kv')

class MyLayout(Widget):
    pass

class AwesomeApp(App):
    def build(self):
        return MyLayout()

if __name__ == '__main__':
    AwesomeApp().run()






Kivy Design Code: split.kv
GitHub Code: split.kv

<MyLayout>
	BoxLayout:
		orientation: "vertical"
		size: root.width, root.height

		Splitter:
			sizable_from: 'bottom'
			Button:
				text: "Hello World 1"
				font_size: 32

		Label:
			text: "This is some text!"
			font_size: 32

		
		Splitter:
			sizable_from: 'top'
			Button:
				text: "Hello World 2"
				font_size: 32

		GridLayout:
			cols:2

			Button: 
				text: "Left"
				font_size: 32

			Splitter:
				sizable_from: 'left'

				Button: 
					text: "Right"
					font_size: 32

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder