Kivy with Python tutorial Part 8 - Simple Drawing Application

preview_player
Показать описание
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.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

thanks again for these good tutorials:
i modified a little the script so i can click without dragging and create straight lines, and if i want i can start dragging
and i'll have a freeform shape, so i'll end up with a mixed shape. Of course it still lots of work to make it more useful, because now after finishing the dragging i cannot start a new independent shape. Anyway here's my code:
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Line


class Drawapp(Widget):
def __init__(self, **kwargs):
super(Drawapp, self).__init__(**kwargs)
self.arr = []

def on_touch_down(self, touch):
with self.canvas:
touch.ud["polyline"] = Line(points=(touch.x, touch.y))
self.arr.append((touch.x, touch.y))
if len(self.arr) <= 2:
for idx in range(len(self.arr)):
touch.ud["polyline"].points += self.arr[idx]
else:
for idx in range(len(self.arr)):
touch.ud["polyline"].points += self.arr[-2]

def on_touch_move(self, touch):
touch.ud["polyline"].points += (touch.x, touch.y)


def on_touch_up(self, touch):
self.arr.append((touch.x, touch.y))

class SimpleApp5(App):
def build(self):
return Drawapp()

if __name__ == "__main__":
SimpleApp5().run()

MiledRizk
Автор

sentdex , you have a great channel and tutorials but i have a question ... how to access hardware api for phones (android and ios) to benefit from cervices like gps location and gyro ...???

mushinart
Автор

is there any way to alter line thickness and color?

shivamsahil
Автор

Everyone does the paint example, nobody demonstrates how to modify an existing application with working buttons for a touch screen.

Anyone know any good resources for accomplishing this?

kphxmfi
Автор

Hi, sentdex. Very interesting video... I would like to know how to make notifications for App's in kivy... Do you have information about that? Thanks in advance...

jeancarlosadrianza
Автор

Quick question, can pyqt do something similar?

unknownlifeform
Автор

Thanks for the tutorial, but what does touch.ud means ? and what is it exactly (variable : list )? a kivy keyword ? and what can I do else than writing ["Line"] ? Can I change Line to sth else ?
And your tutorials are awesome ! <3

TarekAlouiGeek
Автор

how to add vertical scrollbar for the canvas in the paint application.Please help me out

vijaykumarsamanthapudi
Автор

Sir i just cand draw a line not the curves

sumansharma