Exemple #1
0
    def add_reading(self, widget):
        value = self.value.get_value_as_int()
        tree_iter = self.categories_combo.get_active_iter()

        if not tree_iter:
            return

        model = self.categories_combo.get_model()
        row_id, name = model[tree_iter][:2]

        self.emit("reading-added", Reading(
            value=float(value),
            category=Category.get(name=name)))
Exemple #2
0
    def show(self):
        category_store = Gtk.ListStore(str, str)
        categories = Category.select().distinct(Category.name)

        for category in categories:
            category_store.append([category.name, category.name])

        self.categories_combo = self.view.get_object("categories")
        model = self.categories_combo.get_model()

        if model is not None:
            model.clear()

        self.categories_combo.set_model(category_store)
        self.categories_combo.set_active(0)
        self.signals()