Esempio n. 1
0
 def _create_widgets(self):
   self._main = fbgui.VBox("main",
                     settings=fbgui.Settings({
                       'padding': 5
                     }),toplevel=True)
   fbgui.VGap("gap1",
              settings=fbgui.Settings({
                'width': 10,
                'weight': 1
              }),parent=self._main)
   self._dlabel = fbgui.Label("dlabel","Sa 04.05.2019",
                              settings=fbgui.Settings({
                                'font_size': self.theme.font_size_s,
                                'align': fbgui.CENTER
                              }),parent=self._main)
   self._tlabel = fbgui.Label("tlabel","14:23:12",
                              settings=fbgui.Settings({
                                'font_size': self.theme.font_size_xxl,
                                'align': fbgui.CENTER
                              }),parent=self._main)
   fbgui.VGap("gap2",
              settings=fbgui.Settings({
                'width': 10,
                'weight': 1
              }),parent=self._main)
Esempio n. 2
0
def get_widgets():
  """ create widget-tree """
    
  main = fbgui.Panel("main",
                      settings=fbgui.Settings({'margins': (10,10,10,10)}),
                      toplevel=True)
  # add VBox
  vbox = fbgui.VBox("vbox",
                      settings=fbgui.Settings({
                      'margins': 5,
                      'padding': 2,
                      'bg_color': fbgui.Color.SILVER,
                      'align':    (fbgui.LEFT,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.LEFT,
                      }),parent=vbox)
  txt2 = fbgui.Label("id_txt2","a small",
                      settings=fbgui.Settings({
                      'font_size': FONT_MEDIUM,
                      'bg_color' : fbgui.Color.GREEN080,
                      'align':     fbgui.CENTER,
                      }),parent=vbox)
  txt3 = fbgui.Label("id_txt1","and long text",
                      settings=fbgui.Settings({
                      'font_size': FONT_LARGE,
                      'align':     fbgui.RIGHT,
                      }),parent=vbox)
  return main
Esempio n. 3
0
  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
Esempio n. 4
0
    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
Esempio n. 5
0
  def _create_widgets(self):
    self._main = fbgui.Panel("main",
                             settings=fbgui.Settings({
                             }),toplevel=True)
    fbgui.Image("background",img=self._imgpath,parent=self._main)
    self._vbox = fbgui.VBox("vbox",
                            settings=fbgui.Settings({
                             'align': (fbgui.TOP,fbgui.LEFT),
                             'width': 1.0,
                             'height': 1.0,
                             'padding': 10
                            }),parent=self._main)
    self._header = fbgui.Panel("header",
                            settings=fbgui.Settings({
                             'width': 1.0,
                             'padding': 10
                            }),parent=self._vbox)
    self._dtlabel = fbgui.Label("datetime","Do 21.11.2019 16:41",
                                settings=fbgui.Settings({
                                  'align': fbgui.LEFT}),
                                parent=self._header)
    self._templabel = fbgui.Label("temp","22.5°C",
                                settings=fbgui.Settings({
                                  'align': fbgui.RIGHT}),
                                parent=self._header)
    self._wdata   = fbgui.Text("wdata","""Wetterbericht für: München

               leichter Nebel
  _ - _ - _ -  3..4 °C        
   _ - _ - _   ← 6 km/h       
  _ - _ - _ -  4 km           
               0.1 mm""",
                                parent=self._vbox)
Esempio n. 6
0
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)
Esempio n. 7
0
  def _set_text(self,text,refresh=True):
    """ set the text of the widget (internal method) """

    if text == self._text:
      return
    fbgui.App.logger.msg("TRACE","changing text of %s" % self._id)

    self._text = text
    if not text:
      self.clear(refresh=refresh)
      return
    
    # cleanup of old state
    if self._lines:
      del self._lines[:]
      self.remove_all()

    # split text and create labels
    self._lines = text.split('\n')
    n_labels = self._rows if self._rows > 0 else len(self._lines)

    settings = fbgui.Settings(self._settings)
    settings.width  = 0
    settings.height = 0
    settings.weight = 0
    settings.align  = fbgui.LEFT
    for n in range(n_labels):
      label = fbgui.Label("%s_line_%d" % (self._id,n),"",
                                  settings=settings,parent=self)
      label.set_text(self._lines[n],refresh=False)

    if refresh:
      self.post_layout()
Esempio n. 8
0
  def _add_date_box(self,main):
    """ add date-box """

    panel = fbgui.Panel("date_box",
                         settings=fbgui.Settings({
                          'bg_color': fbgui.Color.SILVER,
                          'radius': 0.9,
                          'margins': 20,
                          'width': 1.0,
                          'height': 0.093
                          }),parent=main)
    self._msg = fbgui.Label("msg_label","initializing...",
                            settings=fbgui.Settings({
                              'align': fbgui.LEFT
                           }),parent=panel)
    self._date = fbgui.Label("date_label","",
                            settings=fbgui.Settings({
                              'align': fbgui.RIGHT
                           }),parent=panel)
Esempio n. 9
0
  def _create_label(self):
    """ create label for widget """

    # label within outer-vbox
    self._widget_label = fbgui.Label(self._name+"_label",self._label,
                              settings=fbgui.Settings({
                                'font_name' : 'FreeSans',
                                'font_size' : fbgui.App.theme.font_size_s,
                                }),
                                parent=self)
Esempio n. 10
0
  def _create_childs(self):
    """ create widget-tree for self widget """
    
    self._weekday = fbgui.Label("dt_weekday","",
                                settings=fbgui.Settings({
                                  'font_name' : 'DSEG14Modern-Regular.ttf'
                                  }),
                                parent=self)
    fbgui.HGap("dt_gap1", settings=fbgui.Settings({
      'size': 10
      }), parent=self)
    self._day     = fbgui.Label("dt_day","",parent=self)
    self._month   = fbgui.Label("dt_month","",parent=self)
    self._year    = fbgui.Label("dt_year","",parent=self)
    fbgui.HGap("dt_gap2", settings=fbgui.Settings({
      'size': 10
      }), parent=self)
    self._time    = fbgui.Label("dt_time","",parent=self)
    if self._with_secs:
      self._secs    = fbgui.Label("dt_secs","",
                                settings=fbgui.Settings({
                                  'font_size': fbgui.App.theme.font_size_m
                                  }),
                                parent=self)

    self._set_time(refresh=False)
Esempio n. 11
0
 def _create_widgets(self):
     self._main = fbgui.Panel("main",
                              settings=fbgui.Settings({}),
                              toplevel=True)
     self._vbox = fbgui.VBox("vbox",
                             settings=fbgui.Settings({
                                 'margins':
                                 20,
                                 'radius':
                                 0.2,
                                 'align':
                                 fbgui.CENTER,
                                 'bg_color':
                                 fbgui.Color.SILVER,
                                 'padding':
                                 10
                             }),
                             parent=self._main)
     self._dlabel = fbgui.Label("dlabel",
                                "Sa 04.05.2019",
                                settings=fbgui.Settings({
                                    'font_size':
                                    self.theme.font_size_s,
                                    'align':
                                    fbgui.CENTER
                                }),
                                parent=self._vbox)
     self._tlabel = fbgui.Label("tlabel",
                                "14:23:12",
                                settings=fbgui.Settings({
                                    'font_name':
                                    "DSEG7Classic-Bold.ttf",
                                    'font_size':
                                    self.theme.font_size_xxl,
                                    'align':
                                    fbgui.CENTER
                                }),
                                parent=self._vbox)
Esempio n. 12
0
def get_widgets():
    """ create widget-tree """

    main = fbgui.Panel("main",
                       settings=fbgui.Settings({'margins': (10, 10, 10, 10)}),
                       toplevel=True)
    # add VBox
    vbox = fbgui.VBox("vbox",
                      settings=fbgui.Settings({
                          'margins':
                          20,
                          'padding':
                          2,
                          'align': (fbgui.CENTER, fbgui.TOP),
                      }),
                      parent=main)

    # add a label
    label = fbgui.Label("msg",
                        "",
                        settings=fbgui.Settings({
                            'align': (fbgui.CENTER, fbgui.BOTTOM),
                        }),
                        parent=main)

    # add four buttons
    colors = [
        fbgui.Color.RED075, fbgui.Color.GREEN075, fbgui.Color.YELLOW,
        fbgui.Color.BLUE075
    ]
    text = ["play", "pause", "stop", "record"]
    images = ["play.png", "pause.png", "stop.png", "record.png"]
    attribs = zip(colors, text, images)
    index = 1
    for color, text, image in attribs:
        image = os.path.join(PGM_DIR, image)
        btn = fbgui.Button("btn_%d" % index,
                           img=image,
                           text=text,
                           settings=fbgui.Settings({
                               'width': 150,
                               'font_size': FONT_MEDIUM,
                               'bg_color': color,
                               'align': fbgui.CENTER,
                           }),
                           parent=vbox)
        btn.on_click = lambda widget, event, text=text: set_msg(
            widget, event, text, label)
        index += 1
    return main
Esempio n. 13
0
  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
Esempio n. 14
0
def get_widgets():
    """ create widget-tree """

    colors = [
        fbgui.Color.RED, fbgui.Color.GREEN, fbgui.Color.BLUE,
        fbgui.Color.RED075, fbgui.Color.GREEN075, fbgui.Color.BLUE075,
        fbgui.Color.RED025, fbgui.Color.GREEN025, fbgui.Color.BLUE025
    ]

    labels = [
        "top-left", "top-center", "top-right", "center-left", "center-center",
        "center-right", "bottom-left", "bottom-center", "bottom-right"
    ]

    sizes = [
        FONT_SMALL, FONT_MEDIUM, FONT_LARGE, FONT_SMALL, FONT_MEDIUM,
        FONT_LARGE, FONT_SMALL, FONT_MEDIUM, FONT_LARGE
    ]

    main = fbgui.Panel("main",
                       settings=fbgui.Settings({'margins': (5, 5, 5, 5)}),
                       toplevel=True)
    # add child panels
    index = 0
    for valign in [fbgui.TOP, fbgui.CENTER, fbgui.BOTTOM]:
        for halign in [fbgui.LEFT, fbgui.CENTER, fbgui.RIGHT]:
            config = fbgui.Settings({
                'fg_color': colors[index],
                'font_size': sizes[index],
                'align': (halign, valign)
            })
            text = labels[index]
            if index == 1:
                # test background
                config.bg_color = fbgui.Color.GRAY090
            elif index == 4:
                # test empty label: fill with background
                text = ""
                config.bg_color = fbgui.Color.BLACK
                config.width = 80
                config.height = 40
            label = fbgui.Label("label-%d" % index,
                                text,
                                settings=config,
                                parent=main)
            index += 1

    return main
Esempio n. 15
0
    def set_text(self, text, refresh=True):
        """ set the text of the button """

        if text == self._text:
            return
        fbgui.App.logger.msg("TRACE", "changing image of Button %s" % self._id)

        if text:
            if self._Label:
                self._Label.set_text(refresh=refresh)
            else:
                settings = fbgui.Settings(self._settings)
                settings.width = 0
                settings.height = 0
                settings.weight = 0
                settings.align = fbgui.CENTER
                settings.bg_color = fbgui.Color.TRANSPARENT
                self._Label = fbgui.Label(self._id + "_text",
                                          text,
                                          settings=settings)
                self.add(self._Label, len(self._childs) - 1)
        self._text = text
Esempio n. 16
0
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
Esempio n. 17
0
#!/usr/bin/python3

import fbgui

if __name__ == '__main__':

  config            = fbgui.Settings()
  config.msg_level  = "DEBUG"
  config.font_size  = 40
  config.width      = 320
  config.height     = 240
  config.title      = "Hello World 1"

  app   = fbgui.App(config)
  label = fbgui.Label("id1","Hello World",toplevel=True)
  label.pack()
  app.set_widget(label)
  app.run()