File: main.py

package info (click to toggle)
python-plyer 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,668 kB
  • sloc: python: 13,112; sh: 217; makefile: 177
file content (51 lines) | stat: -rw-r--r-- 1,125 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout

Builder.load_string('''
#:import vibrator plyer.vibrator
<VibrationInterface>:
    orientation: 'vertical'
    Label:
        size_hint_y: None
        height: sp(40)
        text: 'vibrator exists: ' + str(vibrator.exists())
    Button:
        text: 'vibrate 10s'
        on_release: vibrator.vibrate(10)
    Button:
        text: 'vibrate 1s'
        on_release: vibrator.vibrate(1)
    Button:
        text: 'vibrate 0.1s'
        on_release: vibrator.vibrate(0.1)
    Button:
        text: 'cancel vibration'
        on_release: vibrator.cancel()
    TextInput:
        id: ti
        text: '0.5,0.5,1,2,0.1,0.1,0.1,0.1,0.1,0.1'
    Button:
        text: 'vibrate pattern'
        on_release:
            vibrator.pattern([float(n) for n in ti.text.split(',')])

''')


class VibrationInterface(BoxLayout):
    '''Root Widget.'''
    pass


class VibrationApp(App):

    def build(self):
        return VibrationInterface()

    def on_pause(self):
        return True


if __name__ == "__main__":
    VibrationApp().run()