Ejemplo n.º 1
0
    def _populate_category(self, categoryname=None):
        """ Populates combobox with existing categories """
        # Connects to the database
        actions = Actions()

        # List of categories from database
        categories = []
        records = actions.get_categories()

        ret = 0
        empty_color = create_pixbuf()
        for rec in records:
            #if [rec['categoryname'], rec['id']] not in categories:
            #TODO: Better put color creation in a function
            color = rec.color and rec.color or '#000'

            categories.append(
                [create_pixbuf(color=color), rec.name,
                 int(rec.id)])
            if categoryname and categoryname == rec.name:
                ret = len(categories) + 1

        store = gtk.ListStore(gtk.gdk.Pixbuf, str, int)

        self.category.set_model(store)
        store.append([empty_color, _("None"), 0])
        store.append([None, "---", -1])

        for category in categories:
            store.append(category)
        store.append([None, "---", -1])
        store.append([empty_color, _("New Category"), -2])
        self.category.set_active(ret)

        return ret
Ejemplo n.º 2
0
    def _populate_category(self, categoryname=None):
        """ Populates combobox with existing categories """
        # Connects to the database
        actions = Actions()

        # List of categories from database
        categories = []
        records = actions.get_categories()

        ret = 0
        empty_color = create_pixbuf()
        for rec in records:
            #if [rec['categoryname'], rec['id']] not in categories:
            #TODO: Better put color creation in a function
            color = rec.color and rec.color or '#000'

            categories.append([create_pixbuf(color=color), rec.name, int(rec.id)])
            if categoryname and categoryname == rec.name:
                ret = len(categories) + 1

        store = gtk.ListStore(gtk.gdk.Pixbuf, str, int)

        self.category.set_model(store)
        store.append([empty_color, _("None"), 0])
        store.append([None, "---", -1])

        for category in categories:
            store.append(category)
        store.append([None, "---", -1])
        store.append([empty_color, _("New Category"), -2])
        self.category.set_active(ret)

        return ret
Ejemplo n.º 3
0
    def _formated_row(self, row):
        """ Formats a bill to be displayed as a row. """
        color = row.color and row.color or '#d3d7cf'

        formated = []
        formated.append(row.id)
        formated.append(create_pixbuf(color=color))
        formated.append(row.name)
        formated.append(row.color)

        return formated
Ejemplo n.º 4
0
    def format_row(self, row):
        """ Formats a bill to be displayed as a row. """

        categoryName = row.category.name if row.category else _('None')
        categoryColor = row.category.color if row.category else '#d3d7cf'
        formatted = [
            row.id,
            create_pixbuf(color=categoryColor), categoryName, row.payee,
            row.dueDate.strftime(_('%m/%d').encode('ASCII')), row.amount,
            row.notes,
            int(row.paid), None
        ]

        return formatted
Ejemplo n.º 5
0
    def format_row(self, row):
        """ Formats a bill to be displayed as a row. """

        categoryName = row.category.name if row.category else _("None")
        categoryColor = row.category.color if row.category else "#d3d7cf"
        formatted = [
            row.id,
            create_pixbuf(color=categoryColor),
            categoryName,
            row.payee,
            row.dueDate.strftime(_("%m/%d").encode("ASCII")),
            row.amount,
            row.notes,
            int(row.paid),
            None,
        ]

        return formatted