def _create_list_entry(self,entry,nr): """ create a HBox for the info-box """ fbgui.App.logger.msg("DEBUG","creating entry for %r" % (entry,)) text = "%s %s %s %s %s" % (entry['status'], entry['channel'], entry['title'], entry['date'], entry['time']) prefix = "entry_%d" % nr hbox = fbgui.HBox(prefix+"_hbox", settings=fbgui.Settings({ 'bg_color': fbgui.Color.SILVER, 'padding': 10, 'width': 1.0 })) settings = fbgui.Settings({ 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.LEFT,fbgui.BOTTOM), 'font_size': FONT_MEDIUM, }) fbgui.Label(prefix+"_status",entry['status'], settings=settings,parent=hbox) settings.width=0.15 fbgui.Label(prefix+"_channel",entry['channel'], settings=settings,parent=hbox) fbgui.Label(prefix+"_date",entry['date'], settings=settings,parent=hbox) fbgui.Label(prefix+"_time",entry['time'], settings=settings,parent=hbox) settings.width=0.5 fbgui.Label(prefix+"_title",entry['title'], settings=settings,parent=hbox) return hbox
def add_images(parent): """ add images """ # add HBox hbox = fbgui.HBox("hbox_images", settings=fbgui.Settings({ 'margins': 5, 'padding': 30, 'width': 1.0, 'height': 80, 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.CENTER, fbgui.TOP), }), parent=parent) images = glob.glob(os.path.join(os.path.dirname(sys.argv[0]), "*.png")) index = 0 for img in images: settings = fbgui.Settings({ 'width': 40, 'height': 40, 'scale': False, 'weight': 1, 'align': (fbgui.CENTER, fbgui.CENTER), }) if index % 2: settings.scale = True fbgui.Image("img_%d" % index, img=img, settings=settings, parent=hbox) index += 1
def _add_button_box(self,main): """ add button-box """ box = fbgui.HBox("button_box", settings=fbgui.Settings({ 'width': 1.0, 'uniform': True, 'height': 0.093, 'padding': 12, }),parent=main) fbgui.Button("btn_red",None,"Off", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.RED }),parent=box) fbgui.Button("btn_green",None,"Standby", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.GREEN }),parent=box) fbgui.Button("btn_yellow",None,"Kodi", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.YELLOW }),parent=box) fbgui.Button("btn_blue",None,"Off-mode", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.BLUE }),parent=box)
def get_widgets(self): """ create widget-tree """ main = fbgui.Panel("main", settings=fbgui.Settings( {'margins': (10, 10, 10, 10)}), toplevel=True) # add HBox hbox = fbgui.HBox("hbox", settings=fbgui.Settings({ 'margins': 5, 'padding': 30, 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.CENTER, fbgui.CENTER), }), parent=main) main.add(hbox) # and text label = fbgui.Label("id_label", "Number:", settings=fbgui.Settings({ 'font_size': FONT_LARGE, }), parent=hbox) number = fbgui.Label("id_number", "x", settings=fbgui.Settings({ 'font_size': FONT_LARGE, }), parent=hbox) return main, number
def _create_group_box(self): """ create sensor display-box """ return fbgui.HBox(self._name+"_hbox", settings=fbgui.Settings({ 'width': 1.0, 'align': fbgui.CENTER, 'margins': (25,25,0,0) }), parent=self)
def get_widgets(): """ create widget-tree """ main = fbgui.Panel("main", settings=fbgui.Settings({ 'bg_color': fbgui.Color.GRAY090, 'margins': (10, 10, 10, 10) }), toplevel=True) box = fbgui.HBox("button_box", settings=fbgui.Settings({ 'bg_color': fbgui.Color.SILVER, 'uniform': True, 'width': 1.0, 'padding': 10, 'align': fbgui.CENTER }), parent=main) fbgui.Button("btn_red", None, "Off", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.RED }), parent=box) fbgui.Button("btn_green", None, "Standby", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.GREEN }), parent=box) fbgui.Button("btn_yellow", None, "Kodi", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.YELLOW }), parent=box) fbgui.Button("btn_blue", None, "Switch mode", settings=fbgui.Settings({ 'weight': 1, 'bg_color': fbgui.Color.BLUE }), parent=box) return main
def add_labels(parent): """ add HBox with labels """ # add HBox hbox = fbgui.HBox("hbox_labels", settings=fbgui.Settings({ 'margins': 5, 'padding': 30, 'width': 1.0, 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.CENTER, fbgui.TOP), }), parent=parent) # add three texts txt1 = fbgui.Label("id_txt1", "this is", settings=fbgui.Settings({ 'width': 0.25, 'font_size': FONT_SMALL, 'bg_color': fbgui.Color.RED080, 'align': (fbgui.CENTER, fbgui.BOTTOM), }), parent=hbox) txt2 = fbgui.Label("id_txt2", "a small", settings=fbgui.Settings({ 'width': 0.25, 'font_size': FONT_MEDIUM, 'bg_color': fbgui.Color.GREEN080, 'align': (fbgui.RIGHT, fbgui.CENTER), }), parent=hbox) txt3 = fbgui.Label("id_txt3", "and long text", settings=fbgui.Settings({ 'weight': 2, 'bg_color': fbgui.Color.BLUE080, 'font_size': FONT_LARGE, }), parent=hbox)
def add_panels(parent): """ add HBox with panels """ # add a full-size HBox hbox = fbgui.HBox("hbox_panels", settings=fbgui.Settings({ 'margins': 5, 'padding': 30, 'width': 1.0, 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.CENTER, fbgui.TOP), }), parent=parent) # add three panels panel1 = fbgui.Panel("id_panel1", settings=fbgui.Settings({ 'height': 20, 'weight': 1, 'bg_color': fbgui.Color.RED080, 'align': fbgui.BOTTOM, }), parent=hbox) panel2 = fbgui.Panel("id_panel2", settings=fbgui.Settings({ 'height': 30, 'weight': 1, 'bg_color': fbgui.Color.GREEN080, 'align': fbgui.CENTER, }), parent=hbox) panel3 = fbgui.Panel("id_panel3", settings=fbgui.Settings({ 'height': 40, 'weight': 2, 'bg_color': fbgui.Color.BLUE080, }), parent=hbox)
def get_widgets(): """ create widget-tree """ main = fbgui.Panel("main", settings=fbgui.Settings({'margins': (10, 10, 10, 10)}), toplevel=True) # add HBox hbox = fbgui.HBox("hbox", settings=fbgui.Settings({ 'margins': 5, 'padding': 30, 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.CENTER, fbgui.TOP), }), parent=main) # add three texts txt1 = fbgui.Label("id_txt1", "this is", settings=fbgui.Settings({ 'font_size': FONT_SMALL, 'bg_color': fbgui.Color.RED080, 'align': fbgui.BOTTOM, }), parent=hbox) txt2 = fbgui.Label("id_txt2", "a small", settings=fbgui.Settings({ 'font_size': FONT_MEDIUM, 'bg_color': fbgui.Color.GREEN080, 'align': fbgui.CENTER, }), parent=hbox) txt3 = fbgui.Label("id_txt3", "and long text", settings=fbgui.Settings({ 'bg_color': fbgui.Color.BLUE080, 'font_size': FONT_LARGE, }), parent=hbox) return main
def _create_sensor_box(self,parent,sensor,unit): """ create sensor display-box """ sensor_hbox = fbgui.HBox(self._name+"_"+sensor+"_box", settings=fbgui.Settings({ 'padding': 2 }), parent=parent) self._sensor_values[sensor] = ( fbgui.Label(self._name+"_"+sensor+"_value","", settings=fbgui.Settings({ 'font_name' : 'DSEG7Modern-Regular.ttf', }), parent=sensor_hbox)) if unit != 'None': # yes: 'None' not None fbgui.Label(self._name+"_"+sensor+"_unit",unit, settings=fbgui.Settings({ 'align': fbgui.TOP, 'font_name' : 'FreeSans', }), parent=sensor_hbox) return sensor_hbox
def add_lines(parent): """ add HBox with lines """ # add HBox hbox = fbgui.HBox("hbox_lines", settings=fbgui.Settings({ 'margins': 5, 'padding': 30, 'width': 1.0, 'height': 30, 'bg_color': fbgui.Color.SILVER, 'align': (fbgui.CENTER, fbgui.TOP), }), parent=parent) # add two lines line1 = fbgui.Line("id_line1", settings=fbgui.Settings({ 'width': 0.25, 'weight': 1, 'fg_color': fbgui.Color.RED, 'align': fbgui.CENTER, }), parent=hbox) line2 = fbgui.Line("id_line2", settings=fbgui.Settings({ 'width': 0.25, 'weight': 2, 'fg_color': fbgui.Color.BLUE, 'align': fbgui.CENTER, }), parent=hbox)
def get_gui(): """ create GUI-elements """ vbox = fbgui.VBox("main", settings=fbgui.Settings({ 'margins': 10, 'padding': 2 }), toplevel=True) # first HBox zeile1 = fbgui.HBox( "img_and_title", settings=fbgui.Settings({ 'bg_color': fbgui.Color.CORNFLOWERBLUE, 'radius': 0.1, 'margins': 5, 'padding': 5, 'width': 1.0, # 100% 'weight': (0, 1), 'align': fbgui.LEFT, }), parent=vbox) # elements of the first HBox bild = fbgui.Image("cover", img="music.png", settings=fbgui.Settings({ 'align': fbgui.CENTER, 'min_size': (50, 50), 'scale': True, }), parent=zeile1) titel = fbgui.Label("title", "Money for Nothing ...", settings=fbgui.Settings({ 'weight': 1, 'align': (fbgui.LEFT, fbgui.CENTER), }), parent=zeile1) # second HBox zeile2 = fbgui.HBox( "buttons1", settings=fbgui.Settings({ 'margins': 2, 'padding': 1, 'uniform': True, 'width': 1.0, # 100% 'align': fbgui.CENTER, }), parent=vbox) # add buttons liste = [("pause.png", do_pause), ("start.png", do_start), ("stop.png", do_stop)] for icon, methode in liste: btn = fbgui.Button("%s" % icon, img=icon, settings=fbgui.Settings({ 'margins': 5, 'padding': 1, 'bg_color': fbgui.Color.CORNFLOWERBLUE }), parent=zeile2) btn.on_click = methode # third HBox zeile3 = fbgui.HBox( "buttons2", settings=fbgui.Settings({ 'margins': 2, 'padding': 1, 'uniform': True, 'width': 1.0, # 100% 'align': fbgui.CENTER, }), parent=vbox) # add buttons liste = [("skip-backward.png", do_skip_back), ("seek-backward.png", do_seek_back), ("seek-forward.png", do_seek_fwd), ("skip-forward.png", do_skip_fwd)] for icon, methode in liste: btn = fbgui.Button("%s" % icon, img=icon, settings=fbgui.Settings({ 'margins': 5, 'padding': 1, 'bg_color': fbgui.Color.CORNFLOWERBLUE, 'weight': 1 }), parent=zeile3) btn.on_click = methode # return toplevel-element return vbox