Raspberry Pi Window provider doesn't update the Mouse Position
Raspberry Pi Window provider doesn't update the mouse_pos. Tried it with this code:
Code
-- coding: utf-8 --
from kivy.app import App from kivy.uix.widget import Widget from kivy.core.window import Window from kivy.properties import ListProperty from kivy.lang import Builder
kv = """ BoxLayout: Button: Button: """ cursor = """ Image: size_hint: None, None size: '20pt', '20pt' source: 'cursor.jpeg' """
class MyPaintApp(App): mouse_pos = ListProperty([0,0]) def build(self): Window.bind(mouse_pos=self.my_callback) self.cursor = Builder.load_string(cursor) return Builder.load_string(kv)
def on_start(self):
Window.add_widget(self.cursor)
def my_callback(self, instance, value):
print 'test'
print 'position of mouse is: {pos}'.format(pos=value)
cursor = self.cursor
if Window.children[0] != cursor:
#bring it to top
cursor.parent.remove_widget(cursor)
Window.add_widget(cursor)
cursor.center = value
if name == 'main': MyPaintApp().run()
greets
Hi,
The mouse position is a "facility" that works only under a old window manager / old toolkit. You should avoid it and use on_touch_down/move/up instead. If you want to get all the input events in window, use on_motion event then.
On the Rpi, we read the event directly from the kernel. Ie, you can connect multiples mouse, it works. :)
But if there is still no cursor drawing, would the clicks still register? how would you know where your clicks are?
If you edit your ~/.kivy/config.ini file, and at the bottom in [modules] add in
[modules]
touchring = scale=0.3,alpha=0.7,show_cursor=1
you will see a cursor.