Customize Scatter class (Inheritance)

14 prikaza
Preskoči na prvu nepročitanu poruku

micdac

nepročitano,
21. kol 2017. 12:35:1121. 08. 2017.
u 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

nepročitano,
21. kol 2017. 14:40:2321. 08. 2017.
u 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

nepročitano,
22. kol 2017. 07:36:5022. 08. 2017.
u Kivy users support
No, that does not solve the problem:)
Odgovori svima
Odgovori autoru
Proslijedi
0 novih poruka