Positioning a Kivy Animation On Screen. -


i've been playing code how make repetitive rotating animation in kivy?. in code below i'm using rotate image of 45rpm record. i'd change position of record center of screen spin in upper right corner of screen.

i've searched can't find information on how re-position image towards upper right corner and/or information on how ensure keeps rotating once moved.

i'd appreciate help.

thanks in advance.

....brad....

image code at: https://drive.google.com/open?id=0b-t2cvsaoz2vq2hmahm0snlqvlu

# modified https://stackoverflow.com/questions/41321832/how-to-make-a-repetitive-rotating-animation-in-kivy kivy.app import app kivy.lang import builder kivy.uix.floatlayout import floatlayout kivy.animation import animation kivy.properties import numericproperty  builder.load_string('''                                <loading>:     canvas.before:         pushmatrix         rotate:             angle: root.angle             axis: 0, 0, 1             origin: root.center     canvas.after:         popmatrix     image:         source: '45rpm.png'         size_hint: none, none         size: 200, 200         pos_hint: {'center_x': 0.5, 'center_y': 0.5} ''')  class loading(floatlayout):     angle = numericproperty(0)     def __init__(self, **kwargs):         super(loading, self).__init__(**kwargs)         anim = animation(angle = 360, duration=2)         anim += animation(angle = 360, duration=2)         anim.repeat = true         anim.start(self)      def on_angle(self, item, angle):         if angle == 360:             item.angle = 0  class rotationanimation(app):     def build(self):         return loading()  rotationanimation().run()    

thank clear question.

the problem using loading class main widget, should instead called loadingcircle or loadingrecord or , used other widgets.

so, first of all, add main widget (i'll add floatlayout). i'll tell loading go using pos_hint , set size whatever want.

here's code:

from kivy.animation import animation kivy.app import app kivy.lang import builder kivy.properties import numericproperty kivy.uix.floatlayout import floatlayout  builder.load_string('''                                <loading>:     # describe record's position , size here     size_hint: none, none     size: 200, 200     pos_hint: {'top': 1, 'right': 1}     canvas.before:         pushmatrix         rotate:             angle: root.angle             axis: 0, 0, 1             origin: root.center     canvas.after:         popmatrix     image:         source: '45rpm.png'         size_hint: none, none         size: self.parent.size # don't have change every time, change size above         pos_hint: {'center_x': .5, 'center_y': .5} ''')   class loading(floatlayout):     angle = numericproperty(0)      def __init__(self, **kwargs):         super(loading, self).__init__(**kwargs)         anim = animation(angle=360, duration=2)         anim += animation(angle=360, duration=2)         anim.repeat = true         anim.start(self)      def on_angle(self, item, angle):         if angle == 360:             item.angle = 0   class rotationanimation(app):     def build(self):         f = floatlayout()  # new main widget         f.add_widget(loading())  # add loading record         return f   rotationanimation().run() 

the result looks this:

end result


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -