From f78044e4c1329a0c78205265c5da66b4813b9864 Mon Sep 17 00:00:00 2001 From: lastpoet Date: Tue, 12 Oct 2010 22:20:26 +0100 Subject: [PATCH] calendar displays current entry value calendar inits from db if empty --- pyfpdb/Filters.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index a4660eb2..ac62988f 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -1014,6 +1014,25 @@ class Filters(threading.Thread): vb = gtk.VBox() cal = gtk.Calendar() + + if entry == self.start_date: + cal_date = self.start_date.get_text() + if cal_date == '': + self.cursor.execute(self.sql.query['get_first_date']) + result = self.db.cursor.fetchall() + cal_date = result[0][0].split()[0] + self.start_date.set_text(cal_date) + elif entry == self.end_date: + cal_date = self.end_date.get_text() + if cal_date == '': + self.cursor.execute(self.sql.query['get_last_date']) + result = self.db.cursor.fetchall() + cal_date = result[0][0].split()[0] + self.end_date.set_text(cal_date) + + (year,month,day)=cal_date.split('-') + cal.select_month(int(month)-1, int(year)) + cal.select_day(int(day)) vb.pack_start(cal, expand=False, padding=0) btn = gtk.Button(_('Done')) @@ -1039,9 +1058,15 @@ class Filters(threading.Thread): t2 = self.end_date.get_text() if t1 == '': - t1 = '1970-01-02' + self.cursor.execute(self.sql.query['get_first_date']) + result = self.db.cursor.fetchall() + t1 = result[0][0].split()[0] + self.start_date.set_text(t1) if t2 == '': - t2 = '2020-12-12' + self.cursor.execute(self.sql.query['get_last_date']) + result = self.db.cursor.fetchall() + t2 = result[0][0].split()[0] + self.end_date.set_text(t2) s1 = strptime(t1, "%Y-%m-%d") # make time_struct s2 = strptime(t2, "%Y-%m-%d")