Kivy with Python tutorial Part 10 - Screen Manager

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

Key Takeaways

This video tutorial covers the Kivy Screen Manager, a tool for managing multiple screens in a Kivy application, and demonstrates how to use it to create a simple app with multiple screens and transitions.

Full Transcript

what is going on everybody welcome to the 10th Cavey tutorial video in this video we're gonna be talking about the screen manager so I've already talked about this what the purpose of the screen manager is in the last video so we're just going to go ahead and hop right on into it so to get the screen manager we have to make another import and this one's going to be from TV UI x dot screen manager import screen manager we're gonna also need screen and then we're gonna import fade transition so not only is it going to allow us to change between screens there's a quite well there's a handful of transitions that you can use that just kind of makes it look a little better as you transition and it literally a transition helps the user know that transition is even occurring right but it's also it's just more user friendly and it looks better so anyway those are the things that we need and now we're ready to actually build our application luckily or at least for this tutorial we can do it pretty simply we're just going to need a lot of classes that happen to pass but anyways first we're gonna have a class and we're gonna have a main screen and main screen is going to inherit from screen basically to use a screen manager we need to import from screen and inherit from screen rather and then so main screen will pass then we're gonna have class another screen again it's going to inherit from screen and again it's just gonna pass and then we'll have class screen manage management it's really easy to koi when you're like doing tutorials or just like trying to learn about something it's really easy to make the function named the same thing as what you're working with either a module or exactly this because generally they name their things a pretty intuitive name as well so you can get in all kinds of trouble anyway screen manager don't do that so this will be a screen management class which we'll cover in just a moment and then it's going to inherit from screen manager which is here you guessed it it's gonna pass okay so we don't really need any logic at this point simply because we are really just doing like the visual and keavy kind of stuff at this point so we don't actually need to put any logic here but soon you can imagine you might and that's basically it although we need to get rid of these right here so presentation is not a function it's just a variable so we're going to go ahead and get rid of that and now we're ready to move into our kv file so we'll save that there and we'll come over to our ki v file and I'm just going to go ahead and delete everything out of this main kv we don't really need anything there and if ya I'm gonna delete okay so now that we want to do is we want to utilizes meet or fade transition and later on you can actually you might do something with it but actually probably the main use of fade transitions going to be in the key V file anyways but so to do it import in your ki V file it's really quite simple but I guess it's it's kind of flipped around but anyway it's kind of I'll just show you so we want to import what we want to import fade transition and then from where so key v UI x dot screen manager dot fade transition okay and that's our import that's really the only thing we need to right there now we're gonna reference first screen management and basically talk about what screen management is managing so first we have screen management colon tab and first we're going to reference transition transition is you know like an element of our screen manager okay so what we inherited from to make our screen management class their transition you guessed it we're going to use the fade transition then uh what are the screens that we're managing will remain judging main screen and we're gonna manage another screen okay and later on you might be able to add some stuff here for now we'll just leave those actually completely blank so now let's create our main screen rules here and um again TV files are not like spreadsheets Earths spreadsheets style sheets um in the sense that you know like you reference say an ID so main screen is our you know parent and then we've got this child you know ID basically and then we can pass some more things and actually reference that ID and have a user scroll to that ID and all that kind of stuff it's kind it's basically the same thing here so here we're gonna give it a name in the name of main screen we're just gonna say is main and that's basically it and then we we want a budding here capital B for button by the way we want a button tab over we're gonna have a few elements here and what this button is going to do is on release which is a function of a button here on release what do we want to happen well app dot root dot current so our app is basically this right main app and then we're saying basically dot root dot current for the current screen that we're looking at and we want to actually change that to other if the button is going to be the on so the main screen and it would be like hey go to another page or go to these settings or whatever basically this is what controls what this button does so we want it to head to other for another page so the name of our say another screen for the IDE like the ID anyways the name is going to be other so that's kind of how you reference them anyways that's on release but we need a few other things first of all we need some text to let the user know what the heck is about to happen well just look how this actually next screen that's probably the easiest and then finally font size will just say 50 so it's nice and clear and that's basically it with the main screen and now we're going to code the another screen I'm going to just copy this paste this instead of a main screen it is another screen name is other when we release the button on this screen we want to change back to the main screen and then of course this will say something about going back home so we'll just say back home okay easy enough and now we've got basically all of our required you know TV stuff and we've got our buttons we've got our screen manager managing our screens or screens are willing to change the current screen to other and the way that we're doing that is with a fade a transition so I think we're ready to run let's see if we have any errors so you can run that our screen comes up short off we have next screen we click on next screen and we see it faded to this screen here we'll click it again and we go back home so we can see that this basically worked the way that we at least for now have intended obviously the button is giant and we don't really do anything else but we are able to go back and forth between various screens and then obviously as time goes on we can add some information it's more you know kind of gooey stuffs logic here and then come into our actual TV file add some more kind of graphics and customization and maybe not make the button take up the whole screen that kind of stuff so we're gonna add stuff there so I figured that most or the best thing to do now would be show since in the previous video we actually made an application where we were drawing stuff right why not just add that application as if it was you know anything else so we'll add that application will basically come to the main screen we'll hit this it'll come to our application and then maybe there's a button that heads us back home okay something simple like that so that's what we're gonna cover in the next video so stay tuned for that if you guys have any questions or comments on this video please feel free to leave them below otherwise as always thanks for watching thanks for all the support subscriptions until next time

Original Description

In this Kivy application development tutorial, we cover the screen manager. For any medium or larger application, you're likely going to need to allow the user to go to and from various screens, like settings, home, and the game, for example. Kivy comes with a very nice "Screen Manager" which helps you do this. sample code: http://pythonprogramming.net http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This video teaches how to use the Kivy Screen Manager to create a simple app with multiple screens and transitions. The Screen Manager is a powerful tool for managing multiple screens in a Kivy application, and this video demonstrates how to use it to create a basic app.

Key Takeaways
  1. Import the Screen Manager from Kivy
  2. Create a Screen Management class that inherits from ScreenManager
  3. Define the screens to be managed by the Screen Manager
  4. Use the Fade Transition to transition between screens
  5. Create a Kv file to define the UI for each screen
  6. Use the Screen Manager to switch between screens
💡 The Screen Manager is a powerful tool for managing multiple screens in a Kivy application, and the Fade Transition can be used to create a smooth transition between screens.

Related AI Lessons

How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Learn to create a second version of yourself inside Obsidian using AI with a step-by-step guide
Medium · ChatGPT
How to prepare for Spain civil service TIC exam using AI in 2026
Learn how to prepare for the Spain civil service TIC exam using AI in 2026, boosting your chances of success with technology-driven study techniques
Dev.to · David García
Going Viral! How I Created AI Kissing Videos Step by Step Easily Using AIAI.com
Create viral AI kissing videos using AIAI.com in a step-by-step process, leveraging AI technology for creative content creation
Medium · AI
How to prepare TIC teacher exams in Spain with AI (oposiciones 2026)
Prepare for TIC teacher exams in Spain using AI with these actionable steps
Dev.to AI
Up next
Low-Tech, High-Impact: Replacing Your Receptionist With a $15 AI Phone System
Maximum Lawyer
Watch →