calendar displays current entry value

calendar inits from db if empty
This commit is contained in:
lastpoet 2010-10-12 22:20:26 +01:00 committed by Worros
parent 970b88349b
commit f78044e4c1

View File

@ -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")