コード例 #1
0
ファイル: app.py プロジェクト: niedbalski/glucose
    def on_save_clicked(self, widget, reading, from_date):
        (year, month, day) = self.date.get_date()

        formatted = "%d/%d/%d %d:%d:00" % (year, month, day,
                                           self.hour.get_value(),
                                           self.minutes.get_value())

        created = datetime.datetime.strptime(formatted, "%Y/%m/%d %H:%M:%S")
        reading.created = created

        buffer = self.notes.get_buffer()
        reading.notes = buffer.get_text(buffer.get_start_iter(),
                                        buffer.get_end_iter(), True)
        reading.save()

        if from_date:
            readings = Reading.select().where(Reading.created >= from_date)
        else:
            readings = Reading.select()

        self.emit('details-ready', readings)
        self.window.hide()
コード例 #2
0
ファイル: app.py プロジェクト: niedbalski/glucose
    def show(self, from_date=None):
        model = Gtk.ListStore(*([i.get("type", str)
                                 for i in self.COLUMNS] + [object]))

        if from_date:
            readings = Reading.select().where(Reading.created >= from_date)
        else:
            readings = Reading.select()

        for reading in readings:
            row = []
            for item in self.COLUMNS:
                if "transform" in item:
                    value = item["transform"](getattr(reading, item['field']))
                else:
                    value = str(getattr(reading, item["field"], "-"))

                row.append(value)

            row.append(reading)
            model.append(row)

        self.view.set_model(model)
        self.view.show_all()