summaryrefslogtreecommitdiff
path: root/voctogui/lib/uibuilder.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/uibuilder.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/uibuilder.py')
-rw-r--r--voctogui/lib/uibuilder.py96
1 files changed, 53 insertions, 43 deletions
diff --git a/voctogui/lib/uibuilder.py b/voctogui/lib/uibuilder.py
index 2a6b00e..8776480 100644
--- a/voctogui/lib/uibuilder.py
+++ b/voctogui/lib/uibuilder.py
@@ -1,47 +1,57 @@
-import gi, logging
+import gi
+import logging
from gi.repository import Gtk, Gst
-class UiBuilder(object):
- def __init__(self, uifile):
- if not self.log:
- self.log = logging.getLogger('UiBuilder')
-
- self.uifile = uifile
-
- self.builder = Gtk.Builder()
- self.builder.add_from_file(self.uifile)
-
- def find_widget_recursive(self, widget, name):
- widget = self._find_widget_recursive(widget, name)
- if not widget:
- self.log.error('could find required widget "%s" by ID inside the parent %s', name, str(widget))
- raise Exception('Widget not found in parent')
-
- return widget
- def _find_widget_recursive(self, widget, name):
- if Gtk.Buildable.get_name(widget) == name:
- return widget
-
- if hasattr(widget, 'get_children'):
- for child in widget.get_children():
- widget = self._find_widget_recursive(child, name)
- if widget:
- return widget
-
- return None
-
- def get_check_widget(self, widget_id, clone=False):
- if clone:
- builder = Gtk.Builder()
- builder.add_from_file(self.uifile)
- else:
- builder = self.builder
-
- self.log.debug('loading widget "%s" from the .ui-File', widget_id)
- widget = builder.get_object(widget_id)
- if not widget:
- self.log.error('could not load required widget "%s" from the .ui-File', widget_id)
- raise Exception('Widget not found in .ui-File')
+class UiBuilder(object):
- return widget
+ def __init__(self, uifile):
+ if not self.log:
+ self.log = logging.getLogger('UiBuilder')
+
+ self.uifile = uifile
+
+ self.builder = Gtk.Builder()
+ self.builder.add_from_file(self.uifile)
+
+ def find_widget_recursive(self, widget, name):
+ widget = self._find_widget_recursive(widget, name)
+ if not widget:
+ self.log.error(
+ 'could find required widget "%s" by ID inside the parent %s',
+ name,
+ str(widget)
+ )
+ raise Exception('Widget not found in parent')
+
+ return widget
+
+ def _find_widget_recursive(self, widget, name):
+ if Gtk.Buildable.get_name(widget) == name:
+ return widget
+
+ if hasattr(widget, 'get_children'):
+ for child in widget.get_children():
+ widget = self._find_widget_recursive(child, name)
+ if widget:
+ return widget
+
+ return None
+
+ def get_check_widget(self, widget_id, clone=False):
+ if clone:
+ builder = Gtk.Builder()
+ builder.add_from_file(self.uifile)
+ else:
+ builder = self.builder
+
+ self.log.debug('loading widget "%s" from the .ui-File', widget_id)
+ widget = builder.get_object(widget_id)
+ if not widget:
+ self.log.error(
+ 'could not load required widget "%s" from the .ui-File',
+ widget_id
+ )
+ raise Exception('Widget not found in .ui-File')
+
+ return widget