In this video I’ll show you how to scroll between multiple windows or screens with ScreenManager for Kivy and Python.

Kivy isn’t great at allowing you to create multiple windows. But what it DOES allow you to do is create multiple “screens” inside your main window, and that’s what we’ll do in this video.

We’ll use ScreenManager to manage our different screens, and I’ll show you how to scroll between them with the click of a button.

Python Code: new_window.py
GitHub Code: new_window.py

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen 

#Define our different screens
class FirstWindow(Screen):
	pass

class SecondWindow(Screen):
	pass

class WindowManager(ScreenManager):
	pass

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


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

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


Kivy Design Code: new_window.kv
GitHub Code: new_window.kv

WindowManager:
	FirstWindow:
	SecondWindow:


<FirstWindow>:
	name: "first"

	BoxLayout:
		orientation: "vertical"
		size: root.width, root.height

		Label:
			text: "First Screen"
			font_size: 32

		Button:
			text: "Next Screen"
			font_size: 32
			on_release: 
				app.root.current = "second"
				root.manager.transition.direction = "left"


<SecondWindow>:
	name: "second"

	BoxLayout:
		orientation: "vertical"
		size: root.width, root.height

		Label:
			text: "Second Screen"
			font_size: 32

		Button:
			text: "Go Back"
			font_size: 32
			on_release: 
				app.root.current = "first"
				root.manager.transition.direction = "right"

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