Kivy with Python tutorial for Mobile Application Development Part 1
Key Takeaways
This video tutorial covers the basics of Kivy, a cross-platform software development kit for creating mobile applications, and demonstrates how to install and use Kivy with Python for mobile application development. The tutorial also covers the installation of Pygame and Kivy using pip install and the Python package website, and provides sample code for creating a simple Kivy application.
Full Transcript
hello everybody and welcome to the first video of my KV Basics with Python tutorial Series in this video what we're going to be talking about is actually just acquiring KV what KV is and all of that and really just testing the installation so let's go ahead and get started first of all what is Ki so this is the KY website key.org and whenever you go there you'll just be sent to this hashtag home so Ki is just a crossplatform uh software development kit so you can think of it it's just a goey some way to make goys with python kind of like tkinter only the kicker with KY is that it's crossplatform and of course being crossplatform to like Linux Mac OS and windows isn't too phenomenal obviously you can do that with tkinter but where this shines is it is crossplatform even into Mobile with IOS and Android and uh with that it also can interact with special features of your phone so for example on your phone uh you have for one a touchcreen but also there's various hand gestures that you can do with a phone like the basic ones would be you know like this is supposedly a zoom and then you can do like this and that zooms out uh stuff like that you're able to do and you alternatively you can also you know do spins and all kinds of stuff uh and that's really specific to the operating system that you're on so what Ki does is it it kind of allows for that and also you can connect to say like the Android API and you can access the you know the phone's camera let's say or the gyro or whatever so with that kyv is obviously quite powerful there's a lot of cool stuff that you can do and it's relatively simplistic to get started um and you you can basically use this and then you can use something like buildozer for example for Android you can convert it to an Android application put it in Google Play and you're all set you're going to get rich so not really but anyway uh so that's that let's go ahead and get started so what do we need so for KY to work you need py game first then Ki KI kind of uses piy game so uh to get Pi first you're going to want to get pame then Ki so obviously if you're on say uh Linux you would use something like pseudo app get install python py game if you have Pip uh already installed you could just say pip install py game um and if you're on Windows you can do this as well if you have a 32-bit operating system anyways so I'll hit it I'm I'm using or a 32-bit python now I hit it I since I have a 64-bit version of python it gets a little angry with me so I have to use a different um a different thing and I'll show that as well but anyways for most people either Pudo app get or pip install will work also I have a pip install tutorial video so if you have any confusion with how to use pip install uh check that out so finally I will just show uh the final place you can get it if you are already familiar with Pip is you can come to this website here and he's got all of the Python packages it used to be just simple binary ex but he's moved to Wheels curses but anyways you can come here and you can just type in py game and actually here's Ki as well happened to be the first thing that was found but you can get the KY wheel so for example I'm on 3.4 so this is C Python 3.4 and then this is for a 64bit window so I would download this one and wait for it and then I would go click on py game and I would download this one for py game same thing so now you've got those two wheels and again this is for if you're like a 64-bit version of Windows or for whatever reason you couldn't get the other stuff to work for you but anyways once those are downloaded you'll go to your downloads page and we'll we'll leave and actually I'm going to close out of this because I'm going to use something different now uh but anyways you can come here just go to your computer and on downloads you can just hold shift right click and we're going to open the command window there so that opens up a command window into that directory so then for me I could do something like this pip install and I already forgot what they're calling them so so at least it starts with p game so pip install py game and I'll hit Tab and that's the full wheel so now I could hit enter and this will install based on that wheel file although I still got it an error here oh okay I know what it's doing it's referencing my uh I have two versions of python here two 2.7 and three so to reference three very specifically cpython 34 SL I think it'll be script SL pip install and let's try that one more time and in fact let me uh thought I could go here we go edit see default prop we'll go to properties and hopefully we can make this text a little bigger there we go font so y'all can read it okay so anyways uh that should be it I can't remember if it's a capital s or not I'm pretty sure it is we'll hit enter and see what happens yeah there we go so that installs py game for me anyways since I'm on a 64-bit obviously if you're on 32-bit you can use this process as well you would just download the different you know say you on python 34 32bit this would be your download instead so now we'll now that we've got python we can also do the same thing with Ki so pip or actually let's just do an up arrow and we'll just delete this original one and then we'll say kyv there's the kyv wheel hit enter wait for it downloads unpacks and OB I already have kyv so it says everything was satisfied but anyway so that's the installation process for kiwi it's going to vary slightly depending on your operating system although basically every new version of either 27 or 34 is going to come with pips so pip is probably the easiest method and then again if you have a 64-bit or some other operating system then um at least for Windows um you can use this this website here I'll put a link to uh this website in the description if I forget someone remind me and I will put it there I like to forget so anyways once you have that you're ready to go ahead and get started so I'm going to just minimize this all for now I don't think I'll need it again but first let's go ahead and just import uh kyv and let me make my font here bigger as well I forgot to do that so sorry apply import kyv and just make sure we we can run this so just save and run that and uh make sure you don't get any errors this is just some info you'll see that KY spits out a lot of stuff so anyway uh so that's that so import KB as long as that works you installed things correctly or at least up till this point now if you if you're following along right on this video you'll find uh that you are right when this video is released you're probably using uh kyv 1.8.0 I think um and so what you can do is if you're using something that is a newer version of Ki that maybe isn't available to older versions you can and you might see that people suggest that you always do something like this so ki. require and you can require a version number so 1.8.0 uh I think is the one that we're using I already forgot but let's just K requireed 1.8.0 and see if we have any issues no yeah so V 1.8.0 everything's fine and if you if someone is using an older version of Ky and they try this it just won't work so and it'll you know give them an error like oh you don't have that so let's try let's try 1.9.0 not quite sure what'll pop up here but yeah right so it just gives you an error it says it's too old anyway this isn't totally necessary you can have a KYB script without it but most people will just add the latest version but again if they have an old if the person has an older version it doesn't necessarily mean it won't run so I'm going to comment it out for now but you might want to add that in a production version if you're using features that require a certain version moving along um so now what we're going to go ahead and do is create our first app class and so this is basically um going to be the Crux of your kyv application so instead of import kyv we're actually going to do from KV import app and actually it's capital a m this is a class so from KY import app you can have the KY require if you want um but I'm not going to leave it there just because it's not really necessary for the stuff we're using now the next thing that we're going to do is we're going to go ahead and go from k.u. label we want to import uh the label so what is this now Ki is actually extensively um documented both in the kyv code itself and on the kyv website but let's say you're curious about the Ki uh code so we're seeing from k.u. label and we're importing this label and what label is is it's just straight up like a label you can think of a label much like the labels in tkinter if you're familiar but a label can also be a button and a button is an element of a label so anyway let's let's look at that real quick so I'm going to open up computer see python 34 lib it'll be in site packages and then we're looking for KY so here is Ki we open up key and we can see we're from ky. uix so we'll go into the U directory. label so now we're looking for label script here it is we're going to right click edit with idle and this is our actual label. P so we can come down here and we can see that all this is just commented stuff but here's our class label and then we can basically see this is the initialization so this is always run and then these are all like the elements of labels but you can see that you've got you know you can update the texture you this is the create label uh more update there on touchdown so you can see there's already code created for if you were to press uh then there's you know basically just a whole bunch of stuff anyway if you want to read through all the stuff that is possible with a label you can and obviously you can see uh it's extremely well documented actually in the code itself I mean everything has far more documentation than the there's there's like more documentation here than code so anyway that should be pretty useful but as you can see I mean this is all for just label right so there's a lot of stuff you can do uh with Ki but you can also go to the KY website and they have quite a bit of documentation uh for various things on their website so you can go um docs and within docs I'm pretty yeah there's like a search here so you can search things in the documentation uh that you're looking for so if you're looking for a button or if you're looking for canvas drawing or whatever you can search it but we'll talk a little bit more on that uh in a little bit so now what we want to do is just build a quick simple um application just to show you guys the back end so it's a lot K is a lot like py game where there's uh the back end is really written for you you don't need to write code although with P game you have to write code for a button but you don't have to write code for like where is the mouse on the screen that's already done for you you don't have to write code uh to do like the multi-touch app you know apps and stuff like that you don't have to do any of that your job is just to focus on the logic so it's actually it's really useful um in that regard so anyways let's go ahead and do uh we'll create create our class and we're going to call this simple kyv and that's our simple kyv class and then in here for the inheritance we're going to inherit from the app class so let's uh Ki and then we open up the app class here and this is your app class not too much here but that's what we're inheriting from so basically we're inheriting all of this and here is your actual app class so this entire thing here this is all the code that we've just inherited so again you don't just understand like that's what you're that's what I mean by they've done a lot of the work for you because this is all the work you would you know normally probably need to write yourself but someone has already done it for you so anyways we're inheriting from app now uh moving right along also if you're not too familiar with object oriented programming my channel typically we build everything with functions uh but when it comes to goys object-oriented programming is definitely the way to go so we use that here I do have an objectoriented crash course with using tkra as an example so if you're a little confused you can check that out I will put links to that as well so anyways class simple ke inheriting from app uh now what we're going to just do is Define our build and uh we just passed the traditional self there again if you don't understand that check out the crash C Define build and then we're just going to have it return uh capital L label and then we're going to say the text of that label again if you want to know more about the parameters possible with label look at that k.u. label and then the label class within and we're just going to say the typical hello world exclamation mark cuz this computer is really excited to say hello now uh that's that so we have our app and it's that's pretty much all we have to do at this point so now what we're just going to say is if name equals uh main just that typical line you don't really need this this is just so if you were to import this script uh it would only run if you were actually running the script so this wouldn't this code wouldn't run if you we were importing it but anyway simple kyv uh and then Dot run and that will actually run our uh script so we can go ahead and save and run that now oh actually I already know what I sample kyv simple kyv and then what was the actual error that was thrown cannot import name app from kyv oh I know what I've done right so from kv. apppp right so what we're we're just like label right we were this is the uh the ual script name so from ky. apppp here we open that up that's from ky. apppp and then we're trying to import the app class wherever it is like I said so much documentation anyway we're importing app which by the way inherit from event dispatchers so as you can imagine there's a lot of code that is Rewritten for or already written for you anyway simple key app run that should be all set now wait for it and here we have our hello world applic application boom okay so 15 minutes basic kyv application but what's neat is this application already could run just about all the major operating systems Android iOS Windows Linux and Mac OS I think I was what I forgot anyway uh pretty cool obviously you're wer this isn't really interactive in any way although we can resize this application already which is pretty neat um and you can see it just basically by default kind of fixes whatever it needs to fix so again that's pretty cool and we basically did all that in very few lines of code here so anyway what we're going to be talking about is kind of expanding on this expanding more of your options for the guy there's actually a lot of more to cover as far as the basics are concerned so that's what we're going to be talking about next is kind of expanding on this so anyway uh stay tuned for that if you guys have any questions or comments please feel free to leave them below otherwise as always thanks for watching thanks for all the supports subscriptions and until next time
Original Description
Welcome to the introduction to Kivy basics tutorial video. In this tutorial, we cover what Kivy is (cross-platform software development kit, which supports iOS, Android, Windows, Linux, and Mac).
http://kivy.org/#home
http://www.lfd.uci.edu/~gohlke/pythonlibs/
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: AI Pair Programming
View skill →
🎓
Tutor Explanation
DeepCamp AI