summaryrefslogtreecommitdiff
path: root/voctogui/lib/uibuilder.py
diff options
context:
space:
mode:
authorMaZderMind <github@mazdermind.de>2015-06-17 12:18:32 +0200
committerMaZderMind <github@mazdermind.de>2015-06-17 12:18:32 +0200
commite78e24465bbe90150509946211148a364a75a115 (patch)
tree3c205708dfaa6edcd44a72af7212a5b99ed180a2 /voctogui/lib/uibuilder.py
parentce5c7ebd8b631386c0a9c911cb3ecb20c3f824dc (diff)
start filling the gui from code
Diffstat (limited to 'voctogui/lib/uibuilder.py')
-rw-r--r--voctogui/lib/uibuilder.py58
1 files changed, 50 insertions, 8 deletions
diff --git a/voctogui/lib/uibuilder.py b/voctogui/lib/uibuilder.py
index 8d8b245..4084bcf 100644
--- a/voctogui/lib/uibuilder.py
+++ b/voctogui/lib/uibuilder.py
@@ -2,24 +2,66 @@
import gi, logging
from gi.repository import Gtk, Gst
-class UiBuilder(Gtk.Builder):
- def __init__(self):
+class UiBuilder(object):
+ def __init__(self, uifile):
self.log = logging.getLogger('UiBuilder')
- super().__init__()
+ self.uifile = uifile
def setup(self):
+ self.builder = Gtk.Builder()
+ self.builder.add_from_file(self.uifile)
+
# Aquire the Main-Window from the UI-File
- self.log.debug('Loading Main-Window "window" from .ui-File')
- self.win = self.get_check_widget("window")
+ self.win = self.get_check_widget('window')
# Connect Close-Handler
- self.win.connect("delete-event", Gtk.main_quit)
+ self.win.connect('delete-event', Gtk.main_quit)
+
+ self.configure_video_previews()
+ self.configure_audio_selector()
+
+ def configure_video_previews(self):
+ sources = ['cam1', 'cam2', 'grabber']
+ box = self.get_check_widget('box_left')
+
+ for source in sources:
+ preview = self.get_check_widget('widget_preview', clone=True)
+ #box.add(preview)
+ box.pack_start(preview, fill=False, expand=False, padding=0)
+
+ # http://stackoverflow.com/questions/3489520/python-gtk-widget-name
+ preview.get_children()[0].get_children()[0].get_children()[1].get_children()[0].set_label(source)
+
+ def configure_audio_selector(self):
+ combo = self.get_check_widget('combo_audio')
+ combo.set_sensitive(True)
+
+ liststore = self.get_check_widget('liststore_audio')
+ liststore.clear()
+
+ row = liststore.append()
+ liststore.set(row, [0], ['foobar'])
+
+ row = liststore.append('')
+ liststore.set(row, [0], ['moofar'])
+
+ combo.set_active_id('moofar')
def show(self):
self.win.show_all()
- def get_check_widget(self, widget_id):
- widget = self.get_object(widget_id)
+ def find_widget_recursive(self, widget_id, clone=False):
+ pass
+
+ 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')