Customize Scatter class (Inheritance)

14 views
Skip to first unread message

micdac

unread,
Aug 21, 2017, 12:35:11 PM8/21/17
to Kivy users support
Hi,
I am trying to customize some behavior of the Scatter class, for instance that rotations are only in discrete (e.g. 10degs) angle are possible, but lets say for simplicity that I want to add a print statement:

class MyScatter(Scatter):                                                                                                          
   
def __init__(self, **kwargs):                                                                                                  
       
super(MyScatter, self).__init__(**kwargs)                                                                                  
                                                                                                                                   
   
def _set_rotation(self, rotation):                                                                                                    
       
print("---------------> rotation = {}".format(rotation))                                                                    
       
super(MyScatter, self)._set_rotation(rotation)  

However, it seems that I am not overriding Scatter's methods.
I also tried something else, pulled a local copy from uix/scatter.py and renamed all the variables to MyScatter. But the MyScatter objects show no interaction (dragging, rotation, etc.).
So I am a little bit puzzled.

Cheers,
Michael

 


ZenCODE

unread,
Aug 21, 2017, 2:40:23 PM8/21/17
to Kivy users support
Try returning appropriate values. e.g.

class
MyScatter(Scatter):

     def __init__(self, **kwargs):                                                                                                  
        return super(MyScatter, self).__init__(**kwargs)                                                                                                                                                             
   
def _set_rotation(self, rotation):                                                                              
       
print("---------------> rotation = {}".format(rotation))                                                                    
      
return super(MyScatter, self)._set_rotation(rotation)  

 

micdac

unread,
Aug 22, 2017, 7:36:50 AM8/22/17
to Kivy users support
No, that does not solve the problem:)
Reply all
Reply to author
Forward
0 new messages