本文整理汇总了Python中notifier.Notifier.brightness方法的典型用法代码示例。如果您正苦于以下问题:Python Notifier.brightness方法的具体用法?Python Notifier.brightness怎么用?Python Notifier.brightness使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifier.Notifier
的用法示例。
在下文中一共展示了Notifier.brightness方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AutoBrightnessService
# 需要导入模块: from notifier import Notifier [as 别名]
# 或者: from notifier.Notifier import brightness [as 别名]
class AutoBrightnessService(dbus.service.Object):
def __init__(self):
path = '/com/github/sheinz/autobrightness'
bus_loop = DBusQtMainLoop(set_as_default=True)
self._bus = dbus.SessionBus(mainloop=bus_loop)
name = dbus.service.BusName('com.github.sheinz.autobrightness',
bus=self._bus)
dbus.service.Object.__init__(self, name, path)
self.notifier = Notifier(self._bus)
self._auto = False
self._als = AmbientLightSensor()
self._br_ctrl = BrightnessCtrl(self._bus)
self._process_timer = QtCore.QTimer()
self._process_timer.timeout.connect(self.process)
@property
def auto(self):
return self._auto
@auto.setter
def auto(self, value):
self._auto = value
self.notifier.auto_brightness(self._auto)
if self._auto:
self._als.start()
self._br_ctrl.start()
self._process_timer.start(1000)
else:
self._als.stop()
self._br_ctrl.stop()
self._process_timer.stop()
def process(self):
value = self._als.get_value()
print('Light sensor: %d' % value)
if value == 0:
value = 1
self._br_ctrl.set_screen_brightness(value)
if value < 5:
self._br_ctrl.set_keyboard_light(True)
else:
self._br_ctrl.set_keyboard_light(False)
def stop(self):
self._process_timer.stop()
self._als.stop()
self._br_ctrl.stop()
@dbus.service.method(dbus_interface='com.github.sheinz.autobrightness')
def up(self):
value = self._br_ctrl.screen_brightness_up()
self.notifier.brightness(value)
@dbus.service.method(dbus_interface='com.github.sheinz.autobrightness')
def down(self):
value = self._br_ctrl.screen_brightness_down()
self.notifier.brightness(value)
@dbus.service.method(dbus_interface='com.github.sheinz.autobrightness')
def auto_toggle(self):
self.auto = not self.auto
@dbus.service.method(dbus_interface='com.github.sheinz.autobrightness')
def exit(self):
sys.exit()