Can I see a file being dragged through a window in Kivy, Python?

What I want to achieve:

I want to identify a situation where a user drags a file through the Kivy application window.

What I already know:

I know how to detect a hovering mouse cursor over widgets (using on_mouse_pos), I also know how to determine if a file has been reset to a window (using on_file_drop).

So, is it possible to see that the cursor is hovering over the window and holding the “ file? Because then I want to display some hint (for example,“ Drop HERE ”). I hope you understand :)

+4
source share
1 answer

, SDL2 (, , pygame), Window ( - ), , . (, _ O X). , - Window .

, Window , ( ), ( examples/animation/animate.py), , + mouse_pos.

mouse_pos , Window ( , Window Button , ).

animate.py:

class TestApp(App):

    def on_mouse_pos(self, win, args):
        print args
    ...    
    def build(self):
        ...
        from kivy.core.window import Window
        Window.bind(mouse_pos=self.on_mouse_pos)
        return button

, , , . , , (, ), , - .

: Kivy Cython (SDL2) SDL2 SDL2, , SDL2, , , kivy/kivy .

+2

Source: https://habr.com/ru/post/1662573/


All Articles