Tem 302016
 
3.290 views

Ubuntu 16.04 Hikayeleri No-04 Kivy

Daha önce Ubuntu 16.04 üzerine Kivy kurulumunun nasıl yapıldığını anlatmıştım: Python için Yeni bir Çalışma Çerçevesi Kivy

Bu yazımda da Kivy’nin Ubuntu 16.04 üzerine nasıl kurulduğunu anlatacağım. Kullanacağımız Python sürümü 3.5.1.

Kivy’yi doğrudan Ubuntu deposundan yüklemek mümkün. Ancak bu yüklemede bazı bağımlılık sorunları ortaya çıkabiliyor. O yüzden öncelikle kullanacağımız Kivy deposunu sistemimize tanımlıyor ve sistemimizi yeni tanımımızı kapsaması için güncelliyoruz:

sudo apt-add-repository ppa:kivy-team/kivy
sudo apt-get update

Sonra da Python3 için Kivy’yi sistemimize kuruyoruz.

sudo apt-get install python3-kivy

Kurulum sırasında bağımlılık sorunu çıkarsa, şu komutu işletin. Zaten bu öneriyi sistem de karşınıza getirecektir:

sudo apt-get -f install

Kivy deposunda kullanıma hazır onlarca örnek var. Onları da aşağıdaki komutla yüklüyoruz. Elbette örnekleri yüklemek şart değil ama, incelemekte yarar olacağı muhakkak…

sudo apt-get install python-kivy-examples

Bu örneklerin kurulduğu klasör şu adreste:

/usr/share/kivy-examples

İsterseniz bu örneklerden birini deneyelim hemen: kivy_examples/canvas/animation/animate.py

Ubuntu 16.04 Hikayeleri No-04 Kivy

'''
Widget animation
================

This example demonstrates creating and applying a multi-part animation to
a button widget. You should see a button labelled 'plop' that will move with
an animation when clicked.
'''

import kivy
kivy.require('1.0.7')

from kivy.animation import Animation
from kivy.app import App
from kivy.uix.button import Button


class TestApp(App):

    def animate(self, instance):
        # create an animation object. This object could be stored
        # and reused each call or reused across different widgets.
        # += is a sequential step, while &= is in parallel
        animation = Animation(pos=(100, 100), t='out_bounce')
        animation += Animation(pos=(200, 100), t='out_bounce')
        animation &= Animation(size=(500, 500))
        animation += Animation(size=(100, 50))

        # apply the animation on the button, passed in the "instance" argument
        # Notice that default 'click' animation (changing the button
        # color while the mouse is down) is unchanged.
        animation.start(instance)

    def build(self):
        # create a button, and  attach animate() method as a on_press handler
        button = Button(size_hint=(None, None), text='plop',
                        on_press=self.animate)
        return button

if __name__ == '__main__':
    TestApp().run()
python3 animate.py

komutu ile animasyonu başlatabilirsiniz. Bu, basit bir animasyon. Onu daha etkin bir hale dönüştürmek size kalmış.

Ahmet Aksoy

Referanslar:

 Bir yanıt bırakın

Bu HTML tagleri ve özellikleri kullanabilirsiniz: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(gerekli)

(gerekli)

This site uses Akismet to reduce spam. Learn how your comment data is processed.