gps blinker

200 views
Skip to first unread message

purushottam yadav

unread,
Jan 15, 2022, 8:41:28 AM1/15/22
to Kivy users support

In below code ,   def on_touch_down( self, touch ) ,   def on_release(self):  functions are not working  .

>>> I want to open a new screen on touching  the  blinker  . How to implement this ?   

>>> Do you think any issue with parent widget of this gpsblinker widget , or anything wrong with MapMarker  ? 

from kivy_garden.mapview import MapMarker
from kivy.animation import Animation


class GpsBlinker(MapMarker):
    def blink(self):
        # Animation that changes the blink size and opacity
        anim = Animation(outer_opacity=0, blink_size=50)

        # When the animation completes, reset the animation, then repeat
        anim.bind(on_complete = self.reset)
        anim.start(self)

    def reset(self, *args):
        self.outer_opacity = 1
        self.blink_size = self.default_blink_size
        self.blink()

    def on_release(self):
        print("selecting......blinker>>>>>>>>>>>>>>>>>>>>>"*(80) )
            #self.is_open = not self.is_open

    def on_touch_down( self, touch ):

        if  self.collide_point( *touch.pos ):
            print("selecting......down............."*(80) )
#

    # blink --> outer_opacity = 0, blink_size = 50
    # reset --> outer_opacity = 1, blink_size = default = 25

Elliot Garbus

unread,
Jan 15, 2022, 9:56:36 AM1/15/22
to kivy-...@googlegroups.com

The on_touch_down() method needs to use super() to call on_touch_down of the parent class, passing the touch on to the parent class.

 

    def on_touch_down( self, touch ):
        if  self.collide_point( *touch.pos ):
            print("selecting......down............."*(80) )

        return super().on_touch_down(touch)

 

I’m not familiar with the MapMaker, but if you want to add on_press and on_release events to a widget you can use ButtonBehavior.  See: https://kivy.org/doc/master/api-kivy.uix.behaviors.button.html?highlight=button#module-kivy.uix.behaviors.button

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ff1692e0-573f-400a-ad15-ccdc7c44fa50n%40googlegroups.com.

 

purushottam yadav

unread,
Jan 15, 2022, 1:04:19 PM1/15/22
to Kivy users support

I tried to use button behaviour , But I am getting error  .


01-15 23:31:54.293  2143  3559 D CompatibilityInfo: mCompatibilityFlags - 0
01-15 23:31:54.293  2143  3559 D CompatibilityInfo: applicationDensity - 440
01-15 23:31:54.293  2143  3559 D CompatibilityInfo: applicationScale - 1.0
01-15 23:31:54.294 14137 14265 I python  :  Traceback (most recent call last):
01-15 23:31:54.294 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/app/main.py", line 1842, in <module>
01-15 23:31:54.295 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/app.py", line 949, in run
01-15 23:31:54.295 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/app.py", line 919, in _run_prepare
01-15 23:31:54.295  2143  2722 W DropBoxManagerService: Dropping: keymaster (53 > 0 bytes)
01-15 23:31:54.295 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/app/main.py", line 1400, in build
01-15 23:31:54.295 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/builder.py", line 373, in load_string
01-15 23:31:54.296 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/parser.py", line 402, in __init__
01-15 23:31:54.296 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/parser.py", line 508, in parse
01-15 23:31:54.296 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/parser.py", line 462, in execute_directives
01-15 23:31:54.297 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/builder.py", line 306, in load_file
01-15 23:31:54.297 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/builder.py", line 373, in load_string
01-15 23:31:54.297 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/parser.py", line 402, in __init__
01-15 23:31:54.297  2143  2275 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x11 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
01-15 23:31:54.298  2143  2275 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x11 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
01-15 23:31:54.298 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/parser.py", line 508, in parse
01-15 23:31:54.298  2143  2275 D ActivityManager: Raise procstate to external provider: ProcessRecord{68484c8 4395:com.google.android.gms/u999a24}
01-15 23:31:54.298 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myappp/kivy/lang/parser.py", line 472, in execute_directives
01-15 23:31:54.298 14137 14265 I python  :    File "/home/purushottamdev/directory_env/f/ff/.buildozer/android/app/gpsblinker.py", line 10, in <module>
01-15 23:31:54.299 14137 14265 I python  :  TypeError: Cannot create a consistent method resolution
01-15 23:31:54.299 14137 14265 I python  :  order (MRO) for bases ButtonBehavior, MapMarker
01-15 23:31:54.299 14137 14265 I python  : Python for android ended.
01-15 23:31:54.308  2143  2722 D ActivityManager: Raise procstate to external provider: ProcessRecord{68484c8 4395:com.google.android.gms/u999a24}
01-15 23:31:54.310  2143  7672 D ActivityManager: Raise procstate to external provider: ProcessRecord{68484c8 4395:com.google.android.gms/u999a24}
01-15 23:31:54.315  2143  2722 D ActivityManager: Raise procstate to external provider: ProcessRecord{68484c8 4395:com.google.android.gms/u999a24}

Elliot Garbus

unread,
Jan 15, 2022, 1:31:54 PM1/15/22
to kivy-...@googlegroups.com

Looking at the source code for MapMarker it is already derived from ButtonBehavior. https://github.com/kivy-garden/garden.mapview/blob/8c4b838bcb41f0aa90cdee4066684949b2bcee20/mapview/view.py#L111

 

You should be able to use on_release or on_press.

purushottam yadav

unread,
Jan 15, 2022, 2:09:52 PM1/15/22
to Kivy users support
The   code I posted in this question  ,  why is it not working when touched on screen .   
What can potentially go wrong ? 

 how does the touch works , from parent to child   or , from child to parent  ?
How to control it ? 
 

Elliot Garbus

unread,
Jan 15, 2022, 6:43:11 PM1/15/22
to kivy-...@googlegroups.com

Read: https://kivy.org/doc/master/api-kivy.uix.widget.html?highlight=widget#widget-touch-event-bubbling

 

https://kivy.org/doc/master/gettingstarted/events.html

Another thing to note is that if you override an event, you become responsible for implementing all its behavior previously handled by the base class. The easiest way to do this is to call super():

 

Share a minimal executable example if you would like more help.

Robert

unread,
Jan 15, 2022, 7:40:45 PM1/15/22
to Kivy users support
One way this can happen is if a parent (or peer added before your widget) widget filters touch events by on_touch_* returning True.

Mapview has some custom event handling (which is a red flag for this sort of issue) See
Though I can't see anything that I know would filter a 'tap', ....?
So perhaps the filtering is due to another widget?

Generally the way around this is to disable the offending widget's touch behavior, by subclassing it and defining new on_touch_* in the sub class. You might want to keep some of the parent's behavior, add that to you new subclass on_touch_*

purushottam yadav

unread,
Jan 16, 2022, 4:59:28 AM1/16/22
to Kivy users support
 I am not understanding how to reduce  the code  , I will explain the required part   , mmaaiinn.py is main.py  . 
It has  hello screen which has 3 tabs , inside  3rd tab , there is   


                    HomeMapView:
                        #pos_hint: {"top": .795, "left": 1}
                        size_hint: 1, .695
                        id: mapview
  
to display map   , which is   imported using in builder string .

#:include homemapview.kv    . This comes along with GPSblinker in it  .

Other required files are attached  below . 

gpsblinker.kv
mmaaiinn.py
homemapview.kv
homemapview.py
gpsblinker.py

Elliot Garbus

unread,
Jan 16, 2022, 12:30:52 PM1/16/22
to kivy-...@googlegroups.com

The default size of the blinker appears to be  0, 0; Give the blinker a size, then you can use the on_release event.

 

<GpsBlinker>:
    default_blink_size:
25
   
blink_size: 25
   
source: 'resized_image.jpg'#'kivymd/images/transparent.png'
   
outer_opacity: 1
   
on_release: print('marker pressed')
   
size_hint: None, None
   
size: 25, 25
   
on_size: print(f'size of blinker is {self.size}')
    on_kv_post: print(f
'size of blinker is {self.size}')
Reply all
Reply to author
Forward
0 new messages