Kivy PDF
Kivy PDF
Kivy PDF
(HTTP://KARANBALKAR.COM/)
S T A R T PA US E R UN BUT NE VE R S T OP!!!
Hey everyone!
Its time for another cool Kivy tutorial. In this one I
will explain how to use the Clipboard core module
to copy text from a Text Input widget. The text
thus copied will be applied to a Button
(http://kivy.org/docs/api-kivy.uix.button.html),
displayed in our layout.
(http://feeds.feedbur
ner.com/karanbalkar)
Feed
(http://karanbalkar.co
m/)
Using Proximity
sensor in Android
(http://feedproxy.goog
le.com/~r/karanbalkar
/~3/pywJtsUtqc0/)
Whats seen through
[Glass]
(http://feedproxy.goog
le.com/~r/karanbalkar
/~3/2Gx4v2G5IPk/)
Display static Google
Maps in Android
(http://feedproxy.goog
le.com/~r/karanbalkar
/~3/jYgliX41RS0/)
On
EmailAddress
the
other
hand,
the
Text
Input
On
the
other
hand,
the
Text
Input
(http://kivy.org/docs/api-kivy.uix.textinput.html)
widget provides a box of editable plain text. At
present it supports unicode, multi line, cursor
navigation, selection and clipboard features.
EmailAddress
Subscribe
Join me on Facebook
Usage of Clipboard:
ThreadsOfLifebyKaran
Balkar
>>> from kivy.core.clipboard import Clipboard
>>> Clipboard.get_types()
Megusta
['TIMESTAMP', 'TARGETS', 'MULTIPLE', 'SAVE_TARGETS'
'COMPOUND_TEXT', 'TEXT', 'STRING', 'text/plain;charset=utf-8'
A188personaslesgustaThreadsOfLifeby
'text/plain']
KaranBalkar.
>>> Clipboard.get('TEXT')
'Hello World'
>>> Clipboard.put('Great', 'UTF8_STRING')
>>> Clipboard.get_types()
['UTF8_STRING']
>>> Clipboard.get('UTF8_STRING')
'Great'
PluginsocialdeFacebook
Favorite Links
Android Developers
Blog (http://androiddevelopers.blogspot.in
/)
Another Stupid Coder's
Blog
(http://srivatsaniyer.bl
ogspot.in/)
Coding Horror
(http://www.codinghor
ror.com/blog/)
Experience The
Creativity
(http://sarangasl.blogs
pot.in/)
Manas Gajare's Blog
(http://manasgajare.c
om/)
The Global Panorama
(http://theglobalpanor
ama.com/)
Blog Stats
Visits today: 1359
class MyClipBoardApp(App):
def build(self):
root= GridLayout()
layout = FloatLayout(orientation='horizontal'
Recent
Posts
#call function when text changes inside TextInp
ut
textinput.bind(text=on_text)
print ('value is ', textinput.text)
Using Proximity
print Clipboard.put(textinput.text,'UTF8_STRING'sensor in Android
print Clipboard.get('UTF8_STRING')
#Use copied clipboard value as text for Button (http://karanbalkar.co
m/2014/07/usingbutton.text= Clipboard.get('UTF8_STRING'
layout.add_widget(button)
proximity-sensor-inlayout.add_widget(textinput)
android/)
root.add_widget(layout)
return root
Whats seen through
if __name__ == '__main__':
MyClipBoardApp().run()
[Glass]
(http://karanbalkar.co
m/2014/07/whatsseen-through-glass/)
Display static Google
Maps in Android
(http://karanbalkar.co
m/2014/07/displaystatic-google-maps-inandroid/)
Using JSoup in Android
(http://karanbalkar.co
m/2014/06/usingjsoup-in-android/)
(http://karanbalkar.com/2013/06/learningkivy-clipboard-and-textinput/before_text_changed/)
before text changed
Populate Highcharts
with JSON data using
jQuery
(http://karanbalkar.co
m/2014/06/populatehighcharts-with-jsondata-using-jquery/)
Recent Comments
KeyEvent.KEYCODE_MI
NUS funktioniert nicht
- Android-Hilfe.de
(http://www.androidhilfe.de/android-appentwicklung/577059keyeventkeycode_minusfunktioniertnicht.html#post771151
7) on Tutorial #11:
7) on Tutorial #11:
Using TextWatcher in
Android
(http://karanbalkar.co
m/2012/10/tutorial11-using-textwatcherin-android/#comment1816)
(http://karanbalkar.com/2013/06/learningkivy-clipboard-and-textinput/after_text_changed/)
after text changed
Hello friends!
Today, we will learn about a very simple yet
fascinating Kivy widget called Bubble. The Bubble
(http://kivy.org/docs/api-kivy.uix.bubble.html)
widget is basically a small pop up that appears and
consists of menu options that are stacked either
horizontally or vertically.
Tags
agent,
bubble.background_color = (1, 0, 0, .5) #50% translucentaccelerometer,
red
bubble.border = [0, 0, 0, 0]
background_image = 'path/to/background/image'
animation, applications,
arrow_image = 'path/to/arrow/image'
android,
birthday,
So now lets
widget!
begin
implementing
the Bubble
Button,
c++, college,
engineering,
event,
friendship, games,
glass,
goldengate,
java,
jython,
kivy, life,
memories, milestone,
MySQL, network,
notification,
ODI,
oracle,
PhoneGap, processing,
python, qt 5, sony,
Struts 2, tool,
website, widget,
windows, xml,
def show_bubble(self,*args):
my_bubble= Bubble(orientation = 'horizontal'
#Customizing my bubble
Categories
my_bubble.background_color =(20, 0, 0, .
my_bubble.border = [50, 50, 50, 10]
my_bubble.arrow_pos= 'top_left'
Personal
my_bub_btn1= BubbleButton(text='Copy',size_hint
my_bub_btn2= BubbleButton(text='Cut',size_hint (http://karanbalkar.co
my_bub_btn3= BubbleButton(text='Paste',size_hintm/category/personal/)
#Add items to bubble
Poems
my_bubble.add_widget(my_bub_btn1)
my_bubble.add_widget(my_bub_btn2)
(http://karanbalkar.co
my_bubble.add_widget(my_bub_btn3)
m/category/poems/)
self.add_widget(my_bubble)
if __name__ == '__main__':
MyBubbleApp().run()
Tech
(http://karanbalkar.co
m/category/tech/)
Run
the
above
script
by
typing
kivy
bubbledemo.py inside the command prompt and
you should see the following output!
Archives
July 2014
(http://karanbalkar.co
m/2014/07/)
June 2014
(http://karanbalkar.co
m/2014/06/)
May 2014
(http://karanbalkar.co
m/2014/05/)
(http://karanbalkar.com/2013/05/learning-kivybubble/bubble_demo_1/)
March 2014
(http://karanbalkar.co
m/2014/03/)
February 2014
(http://karanbalkar.co
m/2014/02/)
January 2014
(http://karanbalkar.co
m/2014/01/)
December 2013
(http://karanbalkar.co
m/2013/12/)
November 2013
(http://karanbalkar.co
m/2013/11/)
October 2013
(http://karanbalkar.co
m/2013/10/)
m/2013/10/)
September 2013
(http://karanbalkar.co
m/2013/09/)
August 2013
(http://karanbalkar.co
m/2013/08/)
(http://karanbalkar.com/2013/05/learning-kivybubble/bubble_demo_2/)
Posted in Tech (http://karanbalkar.com/category/tech/) |
Tagged Bubble (http://karanbalkar.com/tag/bubble/), kivy
(http://karanbalkar.com/tag/kivy/), python
July 2013
(http://karanbalkar.co
m/2013/07/)
June 2013
(http://karanbalkar.co
m/2013/06/)
(http://karanbalkar.com/tag/python/), widget
(http://karanbalkar.com/tag/widget/) | Leave a comment
(http://karanbalkar.com/2013/05/learning-kivybubble/#respond) |
May 2013
(http://karanbalkar.co
m/2013/05/)
April 2013
(http://karanbalkar.co
m/2013/04/)
Learning Kivy:
TabbedPanel
(http://karanbalkar.com/2
013/05/learning-kivytabbedpanel/)
Posted on MA Y 1 9 , 2 0 1 3
(HT T P:/ / KA R A NBA LKA R .COM/ 2 0 1 3 / 0 5 / LE A R NINGKIVY-T A BBE DPA NE L/ ) by KA R A N BA LKA R
(HT T P:/ / KA R A NBA LKA R .COM/ A UT HOR / KA R A NBA LK
AR/)
Hello everyone!
On May 13th, 2013 Kivy launched version 1.7.0 for
its platform. The new version includes some cool
features as well. You can have a look at the
changelog
from
over
here
(http://kivy.org/#changelog).
Todays Kivy tutorial talks about one of the existing
complex UX widgets called TabbedPanel. The
TabbedPanel
(http://kivy.org/docs/apikivy.uix.tabbedpanel.html)
widget
manages
March 2013
(http://karanbalkar.co
m/2013/03/)
February 2013
(http://karanbalkar.co
m/2013/02/)
January 2013
(http://karanbalkar.co
m/2013/01/)
November 2012
(http://karanbalkar.co
m/2012/11/)
October 2012
(http://karanbalkar.co
m/2012/10/)
September 2012
(http://karanbalkar.co
m/2012/09/)
(http://karanbalkar.com/2013/05/learning-kivytabbedpanel/kivy_tabbedpanel_2/)
(http://karanbalkar.com/2013/05/learning-kivytabbedpanel/kivy_tabbedpanel_3/)
(http://karanbalkar.com/2013/05/learningkivy-tabbedpanel/kivy_tabbedpanel_1/)
Output screenshots
Hey everyone!
Working on Kivy has been an amazing learning
experience.
Kivy
has
made
user
interface
development a lot easier. Today, I will talk about
Accordion, one of the interesting widgets that Kivy
has to offer to developers out there.
Accordion
Accordion
is
basically
a
Widget
(http://kivy.org/docs/api-kivy.uix.widget.html)
in
the form of a menu where in the options are
divides
the
(http://kivy.org/docs/api-
highlight=accordion#kivy.uix.accordion.AccordionIt
em.title).
[AccordionItemTitle@Label]:
text: ctx.title
canvas.before:
Color:
rgb: 1, 1, 1
BorderImage:
source:
ctx.item.background_normal \
if ctx.item.collapse \
else ctx.item.background_selected
pos: self.pos
size: self.size
PushMatrix
Translate:
xy: self.center_x, self.center_y
Rotate:
angle: 90 if ctx.item.orientation =
axis: 0, 0, 1
Translate:
xy: -self.center_x, -self.center_y
canvas.after:
PopMatrix
(http://karanbalkar.com/2013/05/learning-kivyaccordion/kivy_accordion_1/)
(http://karanbalkar.com/2013/05/learningkivy-accordion/kivy_accordion_2/)
Output
Hey everyone!
In
my
previous
(http://karanbalkar.com/2013/04/learning-kivycarousel-and-asyncimage/) Kivy tutorial I talked
about the Carousel widget and the AsyncImage
class that one can use to display and load images
respectively. Today I would be talking about the
Graphics module of the Kivy framework!
1. Graphics (kivy.graphics)
From
the
Kivy
documentation,
the
Graphics
instructions
Color
and
Rectangle
are
Canvas
(http://kivy.org/docs/api-
(http://karanbalkar.com/2013/04/learningkivy-canvas/kivy_canvas_demo/)
Output
Hello everyone!
Today I will talk about two interesting Widgets
(http://kivy.org/docs/guide/widgets.html) of the
Kivy framework. Both these widgets can be used to
display/load images in a particular manner.
1. Carousel
As mentioned in the Kivy docs, the Carousel
(http://kivy.org/docs/api-kivy.uix.carousel.html)
widget provides a mobile-friendly carousel view
where one can swipe between slides. One can add
any content to the carousel and use it horizontally
or vertically. The carousel can display pages in loop
(http://kivy.org/docs/apikivy.uix.carousel.html#kivy.uix.carousel.Carousel.lo
op). One can also navigate to the next slide or the
previous slide using the
(http://kivy.org/docs/api-
Carousel
properties
kivy.uix.carousel.html#kivy.uix.carousel.Carousel.pr
evious_slide).
(http://karanbalkar.com/2013/04/learningkivy-carousel-andasyncimage/kivy_carousel_view/)
asyncimage/kivy_carousel_view/)
Kivy Carousel View
Here
is
the
Source
code
(https://github.com/karanbalkar/KivyCarouselDemo
)
2. AsyncImage
Now, the AsyncImage
kivy.uix.image.html?
(http://kivy.org/docs/api-
highlight=async%20image#kivy.uix.image.AsyncIm
age) class is used to load images asynchronously
from an external webserver. All one needs to do is
specify the URL of the website that contains the
data. One can use AsyncImage in combination
with Carousel to load and display images.
Heres a short implementation of the AsyncImage
class along with the Carousel view.
Once again create a new Python script. Add the
following code. Run it as explained previously and
you should see
asynchronously!
some
images
getting
loaded
(http://karanbalkar.com/2013/04/learning-kivy-carouseland-asyncimage/#comments) |
Hello everyone!
The Kivy framework provides the kivy.animation
module to animate widgets. For any animation, we
must specify certain values that represent the
position of the animated object.
To
use
Animation
(http://kivy.org/docs/apikivy.animation.html) in Kivy one needs to follow
two simple steps namely:
1. Setup an Animation object
2. Use the Animation object on a Widget
There are two kinds of Animation that can be
applied:
1. Sequential Animation
As the name suggests, it is used to join animations
sequentially using the + operator.
Example from Kivy docs:
anim = Animation(x=50) + Animation(size=(80, 80
anim.start(widget)
The above example will animate to x=50 over 1
second, then animate size to (80, 80) over the next
two seconds.
2. Parallel Animation
Hello everyone!
(http://karanbalkar.com/?
attachment_id=439#main)
VideoPlayer widget snapshot 1
(http://karanbalkar.com/?
attachment_id=440#main)
VideoPlayer widget snapshot 2
Scatter widget
The
Scatter
(http://kivy.org/docs/apikivy.uix.scatter.html) is a very simple widget to
understand. It is basically used to build interactive
widgets that can be translated, rotated and scaled
with two or more fingers on a multitouch system. It
acts as a container and is combined with other
widgets.
Create a new Python script named scatterdemo.py
and write the following code:
import kivy
kivy.require('1.4.0')
from kivy.app import App
from kivy.uix.scatter import Scatter
from kivy.uix.image import Image
class MyApp(App):
def build(self):
scatter= Scatter()
# store kivy.jpg image in same folder as the python script
image= Image(source='kivy.jpg')
scatter.add_widget(image) #combine image widget with scatter
return scatter
if __name__ == '__main__':
MyApp().run()
Run the application as done before and you will see
an image of the Kivy logo. You can try dragging,
rotating the image using the mouse.
(http://karanbalkar.com/?
attachment_id=442#main)
Drag image
(http://karanbalkar.com/?
attachment_id=443#main)
Rotate image
kivy.uix.camera.html), Window
(http://kivy.org/docs/api-kivy.core.window.html)
and Button (http://kivy.org/docs/apikivy.uix.button.html)
Posted in Tech (http://karanbalkar.com/category/tech/) |
Tagged camera (http://karanbalkar.com/tag/camera/), kivy
(http://karanbalkar.com/tag/kivy/), python
(http://karanbalkar.com/tag/python/) | 3 Comments
(http://karanbalkar.com/2012/10/tutorial-6-working-withcamera-in-kivy/#comments) |
(http://karanbalkar.com/2012/09/getting-startedwith-kivy/kivy1/)
Copy the path to this folder.
to
command
prompt
once again,
(http://karanbalkar.com/2012/09/getting-startedwith-kivy/kivy2/)
Posted in Tech (http://karanbalkar.com/category/tech/) |
Tagged cross platform (http://karanbalkar.com/tag/crossplatform/), kivy (http://karanbalkar.com/tag/kivy/), python
(http://karanbalkar.com/tag/python/) | 2 Comments
(http://karanbalkar.com/2012/09/getting-started-withkivy/#comments) |
TH R EA D S O F L IF E