summaryrefslogtreecommitdiff
path: root/voctogui/lib/warningoverlay.py
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2016-09-15 09:08:36 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2016-09-15 22:55:24 +0200
commit746d75dee7fb6291a900e0162345354e6eb41c13 (patch)
tree8837a57482ccecebb44a4e9030804654c9526a92 /voctogui/lib/warningoverlay.py
parent27f9bb1c2aeebae5c1482d9b5f33e990f6cfb68b (diff)
voctogui: pep8ify
* Indent by 4 spaces * Use spaces around infix operators * Reformat some argument lists * One import per line * Start line comments with '# ' * Two newlines before free functions * One newline before methods
Diffstat (limited to 'voctogui/lib/warningoverlay.py')
-rw-r--r--voctogui/lib/warningoverlay.py85
1 files changed, 45 insertions, 40 deletions
diff --git a/voctogui/lib/warningoverlay.py b/voctogui/lib/warningoverlay.py
index bf2c2cd..f4f7f24 100644
--- a/voctogui/lib/warningoverlay.py
+++ b/voctogui/lib/warningoverlay.py
@@ -3,59 +3,64 @@ from gi.repository import GLib, Gst, cairo
from lib.config import Config
+
class VideoWarningOverlay(object):
- """ Displays a Warning-Overlay above the Video-Feed of another VideoDisplay """
+ """Displays a Warning-Overlay above the Video-Feed
+ of another VideoDisplay"""
- def __init__(self, drawing_area):
- self.log = logging.getLogger('VideoWarningOverlay')
+ def __init__(self, drawing_area):
+ self.log = logging.getLogger('VideoWarningOverlay')
- self.drawing_area = drawing_area
- self.drawing_area.connect("draw", self.draw_callback)
+ self.drawing_area = drawing_area
+ self.drawing_area.connect("draw", self.draw_callback)
- self.text = None
- self.blink_state = False
+ self.text = None
+ self.blink_state = False
- GLib.timeout_add_seconds(1, self.on_blink_callback)
+ GLib.timeout_add_seconds(1, self.on_blink_callback)
- def on_blink_callback(self):
- self.blink_state = not self.blink_state
- self.drawing_area.queue_draw()
- return True
+ def on_blink_callback(self):
+ self.blink_state = not self.blink_state
+ self.drawing_area.queue_draw()
+ return True
- def enable(self, text=None):
- self.text = text
- self.drawing_area.show()
- self.drawing_area.queue_draw()
+ def enable(self, text=None):
+ self.text = text
+ self.drawing_area.show()
+ self.drawing_area.queue_draw()
- def set_text(self, text=None):
- self.text = text
- self.drawing_area.queue_draw()
+ def set_text(self, text=None):
+ self.text = text
+ self.drawing_area.queue_draw()
- def disable(self):
- self.drawing_area.hide()
- self.drawing_area.queue_draw()
+ def disable(self):
+ self.drawing_area.hide()
+ self.drawing_area.queue_draw()
- def draw_callback(self, area, cr):
- w = self.drawing_area.get_allocated_width();
- h = self.drawing_area.get_allocated_height();
+ def draw_callback(self, area, cr):
+ w = self.drawing_area.get_allocated_width()
+ h = self.drawing_area.get_allocated_height()
- self.log.debug('draw_callback: w/h=%u/%u, blink_state=%u', w, h, self.blink_state)
+ self.log.debug('draw_callback: w/h=%u/%u, blink_state=%u',
+ w, h, self.blink_state)
- if self.blink_state:
- cr.set_source_rgba(1.0, 0.0, 0.0, 0.8)
- else:
- cr.set_source_rgba(1.0, 0.5, 0.0, 0.8)
+ if self.blink_state:
+ cr.set_source_rgba(1.0, 0.0, 0.0, 0.8)
+ else:
+ cr.set_source_rgba(1.0, 0.5, 0.0, 0.8)
- cr.rectangle(0, 0, w, h)
- cr.fill()
+ cr.rectangle(0, 0, w, h)
+ cr.fill()
- text = "Stream is Blanked"
- if self.text:
- text += ": "+self.text
+ text = "Stream is Blanked"
+ if self.text:
+ text += ": " + self.text
- cr.set_font_size(h*0.75)
- xbearing, ybearing, txtwidth, txtheight, xadvance, yadvance = cr.text_extents(text)
+ cr.set_font_size(h * 0.75)
+ (xbearing, ybearing,
+ txtwidth, txtheight,
+ xadvance, yadvance) = cr.text_extents(text)
- cr.move_to(w/2 - txtwidth/2, h*0.75)
- cr.set_source_rgba(1.0, 1.0, 1.0, 1.0)
- cr.show_text(text)
+ cr.move_to(w / 2 - txtwidth / 2, h * 0.75)
+ cr.set_source_rgba(1.0, 1.0, 1.0, 1.0)
+ cr.show_text(text)