Kivy with Python tutorial Part 8 - Simple Drawing Application

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

Key Takeaways

This video tutorial demonstrates how to create a simple drawing application using Kivy with Python, utilizing touch input to draw lines on a canvas.

Full Transcript

hello everybody and welcome to the eth Ki Basics tutorial video with python in this video we're going to make a sort of uh drawing application so to do that from where we are it's actually not very much code because we are already tracking on touchdown on touch and on touch move we actually aren't going to need on touch up but I'm just going to leave it here because it's cool that we even have that so uh with that let's go ahead and import one one more thing and that is going to be from k. Graphics we want to import line with a capital l and that's to actually draw a line basically now what we want to do is on touchdown we want to begin a line so think of like you know you have a pencil you put the pencil to the paper and then starts to make a mark and then as you drag it around it continues you know marking on the paper so that's what we kind of want to do want touchdown we want to begin that Mark and then we want to continue that Mark as long as our touch is moving on even though in theory you might think in your head well don't we have to do something ontouch up to stop the line drawing no because ontouch move will just cease to exist anymore so we actually don't need to do anything there but anyway uh we need line and that's really all we have to add as far as Imports are concerned and now we just need to code the on touchdown and move stuff so I'm going to call this uh I don't know draw class draw input and then before we forget we need to take this right here and instead of touch input down here it needs to be draw input so I just want to change that other than other than that we're ready to go so now we say with self. canvas and this is the canvas of our application uh so self. canvas is just referring to that so you don't really need to like define canvas or anything so with self. canvas what do we actually want to do well we're going to say touch. UD and UD now uh we're going to reference the line element in there and we're going to say that is equal to line and we're going to say the points of that line is right now going to only be a single point in the line but the points for now are equal to touch dox touch doy so literally the X and Y values of of uh where we touch down so line at the moment is literally uh just actually a point it's not really a line it's simply a point but then what we do is we've since we've got that now what we're going to do is that should I'm going just make sure we close that off right yes so now we've got a line there and that will actually show something but not very much and then now on touch move what we want to do is we're going to say touch. UD uh and then again again we're referencing the line element whoops line like this and then we're going to say dot points plus equals and we want to plus equals the exact same thing pretty much right here so plus equals this so again this is just the this is the line function and we're saying we already established touch. UD line equals line which we imported up here and where we say the points of line so where we basically said line do points cuz touch UD uh line is equal to basically this line right up here so now we're saying line. points which originally line dot points was touch just X and Y of the original touch now we're saying we want to add to those points and we're adding every single movement of touch X and touch y we just add all of those movements and that's really it that's all we have to do with this and so now we can just save and run this hopefully and here we have our application and yeah sure enough you can click and you can start to write things so hi awesome and then we can actually you know resize this and we'll see that okay we just gained a lot more space and uh now we can write even more stuff and I'm really good at writing with the mouse tutorials you probably wouldn't even know that was tutorials immediately anyway so that's that that's pretty much all of um the basic basics for using canvas anyways but that's pretty cool like how quickly you can uh actually you know reference the drawing ability and the canvas ability of uh K so anyways I hopefully you guys enjoyed if you have any questions or comments please please feel free to leave them below otherwise as always thanks for watching thanks for all the support and subscriptions and until next time

Original Description

In this Kivy application development tutorial, we cover how to use the touch input from the user to create a simple drawing application, treating the presses from the user as a pencil. 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 tutorial teaches how to create a simple drawing application using Kivy with Python, covering touch input, canvas, and line drawing. It provides a basic understanding of Kivy's capabilities for mobile application development.

Key Takeaways
  1. Import the necessary modules, including Kivy and its graphics components
  2. Create a class to handle touch input and drawing
  3. Define the ontouchdown and ontouchmove functions to handle user input
  4. Use the line function to draw lines on the canvas
  5. Test and run the application
💡 Kivy's touch input and canvas capabilities can be easily utilized to create interactive and engaging applications, such as a simple drawing application.

Related Reads

📰
The Only AI Tools a Small Business Actually Needs in 2026
Discover the essential AI tools for small businesses in 2026 to boost efficiency and customer engagement
Dev.to AI
📰
I Built an AI Life Planner the Month I Graduated and Switched to Linux Halfway Through
Learn how to build a personal AI life planner by following the author's journey, from initial development to switching to Linux halfway through, and apply these skills to your own projects
Dev.to · Hilal
📰
Your Second Brain Is a Graveyard. Your AI Has Amnesia. (Part 1)
Learn why your second brain and AI tools are failing you and how to address these issues
Medium · AI
📰
The Python Automation Business I Started With 200 Lines of Code Eventually Replaced My Freelance…
Learn how a simple 200-line Python script can turn into a full-fledged automation business, replacing freelance work
Medium · Programming
Up next
How AI Is Transforming Analytics in Tableau Cloud & Server
Salesforce Product Center
Watch →