Exemplo n.º 1
0
    def build_label(self, node, label):
        widget = g.Label(self._(data(node)))
        help = int(node.getAttribute('help') or '0')
        if help:
            widget.set_alignment(0, 0.5)
        else:
            widget.set_alignment(0, 1)
        widget.set_justify(g.JUSTIFY_LEFT)
        widget.set_line_wrap(True)

        if help:
            hbox = g.HBox(False, 4)
            image = g.Image()
            image.set_from_stock(g.STOCK_DIALOG_INFO, g.ICON_SIZE_BUTTON)
            align = g.Alignment(0, 0, 0, 0)

            align.add(image)
            hbox.pack_start(align, False, True, 0)
            hbox.pack_start(widget, False, True, 0)

            spacer = g.EventBox()
            spacer.set_size_request(6, 6)

            return [hbox, spacer]
        return [widget]
Exemplo n.º 2
0
    def build_filechooser(self, node, label, option):
        """<filechooser name='...' label='...'/>Tooltip</filechooser>.
		Lets the user choose a file (using a GtkFileChooser or by drag-and-drop).
		Note: requires GTK >= 2.6
		"""
        filebutton = g.FileChooserButton(label)
        eb = g.EventBox()
        eb.add(filebutton)
        self.may_add_tip(eb, node)

        clearbutton = g.Button(stock=g.STOCK_CLEAR)
        hbox = g.HBox(False, 4)
        if label:
            hbox.pack_start(g.Label(label + ":"), False, True, 0)
        hbox.pack_start(eb, True, True, 0)
        hbox.pack_start(clearbutton, False, True, 0)

        self.handlers[option] = (lambda: filebutton.get_filename(),
                                 lambda: filebutton.set_filename(option.value))
        filebutton.connect('selection-changed',
                           lambda w: self.check_widget(option))

        def clear(w):
            filebutton.set_filename("")
            self.check_widget(option)

        clearbutton.connect('clicked', clear)

        return [hbox or eb]
Exemplo n.º 3
0
 def __init__(self, option_box, option, title):
     g.Button.__init__(self)
     self.c_box = g.EventBox()
     self.add(self.c_box)
     self.option_box = option_box
     self.option = option
     self.title = title
     self.set_size_request(64, 14)
     self.dialog = None
     self.connect('clicked', self.clicked)
     self.connect('expose-event', self.expose)
Exemplo n.º 4
0
    def _create_drag_area(self, type):
        align = g.Alignment()
        align.set(.5, .5, 0, 0)

        self.drag_box = g.EventBox()
        self.drag_box.set_border_width(4)
        self.drag_box.add_events(gdk.BUTTON_PRESS_MASK)
        align.add(self.drag_box)

        self.icon = g.Image()
        self._set_icon(type)

        self._set_drag_source(type)
        self.drag_box.connect('drag_begin', self.drag_begin)
        self.drag_box.connect('drag_end', self.drag_end)
        self.drag_box.connect('drag_data_get', self.drag_data_get)
        self.drag_in_progress = 0

        self.drag_box.add(self.icon)

        return align
Exemplo n.º 5
0
    def set_weather(self, weather):
        if self.table:
            self.box.remove(self.table)
        self.table = g.Table(8, self.ndays * 2)
        self.box.add(self.table)

        self.weather = weather

        self.set_title(
            (_("Weather Forecast for ") + self.weather.info.location))

        nday = 0
        for forecast in self.weather.forecasts[:self.ndays]:

            label = g.Label()
            label.set_markup("<b>" + _(forecast.day) + "</b>")
            self.table.attach(label, nday * 2, nday * 2 + 2, 0, 1)

            label = g.Label()
            label.set_markup("<b>" + _(forecast.date) + "</b>")
            self.table.attach(label, nday * 2, nday * 2 + 2, 1, 2)

            label = g.Label(forecast.low + " - " + forecast.hi + " °" +
                            self.weather.units.temperature)
            self.table.attach(label, nday * 2, nday * 2 + 2, 2, 3)

            image = g.Image()
            pixbuf = get_weather_icon(forecast.day_info.icon)
            image.set_from_pixbuf(pixbuf)
            event_box = g.EventBox()
            event_box.add(image)
            tooltips.set_tip(event_box, _(forecast.day_info.description))
            self.table.attach(event_box, nday * 2, nday * 2 + 1, 3, 4)

            label = g.Label(_(forecast.day_info.wind_dir))
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Wind direction"))
            self.table.attach(event_box, nday * 2, nday * 2 + 1, 4, 5)

            label = g.Label(
                "%s %s" %
                (forecast.day_info.wind_speed, self.weather.units.speed))
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Wind speed"))
            self.table.attach(event_box, nday * 2, nday * 2 + 1, 5, 6)

            label = g.Label(forecast.day_info.humidity + "%")
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Humidity"))
            self.table.attach(event_box, nday * 2, nday * 2 + 1, 6, 7)

            label = g.Label(forecast.day_info.rain + " %")
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Rain"))
            self.table.attach(event_box, nday * 2, nday * 2 + 1, 7, 8)

            image = g.Image()
            pixbuf = get_weather_icon(forecast.night_info.icon)
            image.set_from_pixbuf(pixbuf)
            event_box = g.EventBox()
            event_box.add(image)
            tooltips.set_tip(event_box, _(forecast.night_info.description))
            self.table.attach(event_box, nday * 2 + 1, nday * 2 + 2, 3, 4)

            label = g.Label(_(forecast.night_info.wind_dir))
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Wind direction"))
            self.table.attach(event_box, nday * 2 + 1, nday * 2 + 2, 4, 5)

            label = g.Label(
                "%s %s" %
                (forecast.night_info.wind_speed, self.weather.units.speed))
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Wind speed"))
            self.table.attach(event_box, nday * 2 + 1, nday * 2 + 2, 5, 6)

            label = g.Label(forecast.night_info.humidity + "%")
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Humidity"))
            self.table.attach(event_box, nday * 2 + 1, nday * 2 + 2, 6, 7)

            label = g.Label(forecast.night_info.rain + " %")
            event_box = g.EventBox()
            event_box.add(label)
            tooltips.set_tip(event_box, _("Rain"))
            self.table.attach(event_box, nday * 2 + 1, nday * 2 + 2, 7, 8)

            nday += 1
        self.box.show_all()
Exemplo n.º 6
0
 def build_spacer(self, node, label):
     """<spacer/>"""
     eb = g.EventBox()
     eb.set_size_request(8, 8)
     return [eb]