Sie sind auf Seite 1von 14

Nik Klever University of Applied Sciences Augsburg

KIVY - A Framework for


Natural User Interfaces
Nik Klever
Faculty of Computer Sciences
University of Applied Sciences Augsburg
Source of all Slides adopted from http://www.kivy.org
Nik Klever University of Applied Sciences Augsburg
Kivy - Open Source ibrary
Kivy is an

Open Source Python library for

rapid development of applications


t!at make use of

innovative user interfaces"


suc! as multi-touc! apps#
Nik Klever University of Applied Sciences Augsburg
Cross $latform
Kivy is running on

Linux

!indo"s

#acOS$

%ndroid and

IOS
%ou can run t!e same code on all supported platforms#
&t can use natively most input protocols and devices like

WM_Touch WM_!e" o" Windows

Mac #S $ Trackpad a"d Magic Mouse o" MacOSX

mtdev %i"u& Ker"el '() T*(# o" Linux.


A multi-touc! mouse simulator is included#
Nik Klever University of Applied Sciences Augsburg
'usiness Friendly
Kivy is ())* free to use" under +$ , licence#
-!e toolkit is professionally developed" backed
and used# %ou can use it in a product and sell
your product#
-!e frame"or& is stable and !as a documented
%PI" plus a programming guide to !elp for in t!e
first step#
Nik Klever University of Applied Sciences Augsburg
+$U accelerated
-!e grap!ics engine is built over Open'L (S )
using modern and fast way of doing grap!ics#
-!e toolkit is coming wit! more t!an .) widgets
designed to be e/tensible# 0any parts are written
in C using *ython" tested wit! regression tests#
Nik Klever University of Applied Sciences Augsburg
$!ilosop!y - (
+resh
Kivy is made for today and tomorrow# Novel input methods suc! as 0ulti-
-ouc! !ave become increasingly important# Kivy is created from scratc!"
specifically for t!is kind of interaction#
+ast
Kivy is fast# -!is applies to bot!1 application development and application
execution speeds# -ime-critical functionality in Kivy is implemented on t!e *
level to leverage t!e power of e/isting compilers# 0ost importantly" we use t!e
'PU w!erever it makes sense in our conte/t#
+lexible
Kivy is fle/ible# -!is means it can be run on a variety of different devices"
including Android and iOS powered smartp!ones and tablets# 2e support all
ma3or operating systems 42indows" inu/" OS 56# Kivy supports -U&O
4-angible User &nterface Ob3ects6 and a number of ot!er input sources#
Nik Klever University of Applied Sciences Augsburg
$!ilosop!y - .
+ocused
Kivy is focused# %ou can write a simple application wit! a fe" lines of code#
Kivy programs are created using t!e $yt!on programming language" w!ic! is
incredibly versatile and powerful" yet easy to use# &n addition" we created our
own description language" t!e Kivy Lan,ua,e" for creating sop!isticated user
interfaces# -!is language allows you to set up" connect and arrange your
application elements 7uickly#
+unded
Kivy is actively developed by professionals in t!eir field# Kivy is a
community-influenced" professionally developed and commercially backed
solution#
+ree
Kivy is free to use# %ou don8t !ave to pay for it# %ou don8t even !ave to pay
for it if you8re making money out of selling an application t!at uses Kivy#
Nik Klever University of Applied Sciences Augsburg
Core
-!e code in t!e core package provides commonly used features" suc! as1

*loc&
%ou can use t!e clock to sc!edule timer events# 'ot! one-s!ot timers and periodic
timers are supported

*ache
&f you need to cac!e somet!ing t!at you use often" you can use our class for t!at
instead of writing your own#

'esture -etection
2e s!ip a simple gesture recogni9er t!at you can use to detect various kinds of
strokes" suc! as circles or rectangles# %ou can train it to detect your own strokes#

Kivy Lan,ua,e
-!e kivy language is used to easily and efficiently describe user interfaces#

Properties
-!ese are not t!e normal properties t!at you may know from pyt!on# -!ey are
our own property classes t!at link your widget code wit! t!e user interface
description#
Nik Klever University of Applied Sciences Augsburg
U&5 42idgets : ayouts6
-!e U&5 module contains commonly used widgets and layouts t!at you can
reuse to 7uickly create a user interface#

!id,ets
2idgets are user interface elements t!at you add to your program to provide
some kind of functionality# -!ey may or may not be visible# ;/amples
would be a file browser" buttons" sliders" lists and so on# 2idgets receive
0otion;vents#

Layouts
%ou use layouts to arrange widgets# &t is of course possible to calculate your
widgets8 positions yourself" but often it is more convenient to use one of our
ready made layouts# ;/amples would be +rid ayouts or 'o/ ayouts# %ou
can also nest layouts#
Nik Klever University of Applied Sciences Augsburg
&nput ;vents 4 -ouc!es 6
Kivy abstracts different input types and sources suc! as touc!es" mice" -U&O or similar#
2!at all of t!ese input types !ave in common is t!at you can associate a .< onscreen-position
wit! any individual input event#
All of t!ese input types are represented by instances of t!e -ouc!46 class# A touc! instance" or
ob3ect" can be in one of t!ree states# 2!en a touc! enters one of t!ese states" your program is
informed t!at t!e event occurred# -!e t!ree states a touc! can be in are1

-o"n
A touc! is down only once" at t!e very moment w!ere it first appears#

#ove
A touc! can be in t!is state for a potentially unlimited time# A touc! does not !ave to be in t!is
state during its lifetime# A =0ove8 !appens w!enever t!e .< position of a touc! c!anges#

Up
A touc! goes up at most once" or never# &n practice you will almost always receive an up event
because nobody is going to !old a finger on t!e screen for all eternity" but it is not guaranteed#
&f you know t!e input sources your users will be using" you will know w!et!er or not you can
rely on t!is state being entered#
Nik Klever University of Applied Sciences Augsburg
;vents and $roperties
Nik Klever University of Applied Sciences Augsburg
-utorial ;/ample Pon,
Pon, is an easy" small and very common e/ample of t!e old $ing-$ong Computer
+ame > it is introduced as a tutorial for Kivy on t!e site
!ttp1??kivy#org?docs?tutorials?pong#!tml
!hat is needed . <ownload Kivy as described on t!e <ownload Site
/o"0o1(xample on %ndroid1
(# <ownload t!e Kivy aunc!er App from t!e +oogle $lay Store
.# Create a directory named &ivy in t!e root-directory on t!e storage of your Android
smartp!one
,# Create a directory named pon, in t!is directory
@# Copy t!e files main2py and pon,2&v into t!is directory pong
A# Create a file name android2txt wit! t!e following content1
title=Pong Tutorial
author=KivyTeam
orientation=landscape
B# Cun t!e application Kivy Launcher and select Pon, 0utorial
D# C!ange pong#kv for your special needs 4e#g# introduce a Color6
Nik Klever University of Applied Sciences Augsburg
Euestions F
Kivy is well documented on itGs 2ebsite
!ttp1??www#kivy#org
-!anks to all contributors of Kivy" especially t!e core team

0at!ieu Hirbel

-!omas Iansen

+abriel $ettier

Das könnte Ihnen auch gefallen