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 (38 lines) | stat: -rwxr-xr-x 860 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
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from plyer import brightness

Builder.load_string('''
<BrightnessInterface>:
    orientation: 'vertical'
    Label:
        text: 'Adjust the slider to increase \\n or decrease the brightness'
    Slider:
        id: slider
        min: 0
        max: 100
        value: root.get_current_brightness()
        on_value: root.set_brightness(slider.value)
    Label:
        text: 'Current brightness = ' + str(slider.value)
''')


class BrightnessInterface(BoxLayout):

    def set_brightness(self, level):
        brightness.set_level(level)

    def get_current_brightness(self):
        return brightness.current_level()


class BrightnessApp(App):

    def build(self):
        return BrightnessInterface()


if __name__ == '__main__':
    BrightnessApp().run()