From: <cl...@us...> - 2002-05-24 12:21:52
|
Update of /cvsroot/todo-manager/todo-manager In directory usw-pr-cvs1:/tmp/cvs-serv1363 Modified Files: Tag: dev-bronze tdm_calendar.py Log Message: * GetDay has been changed to SelDay since it is called when a day is selected * Drawing of the calendar has been reworked * The current day will be red when the calendar first draws Index: tdm_calendar.py =================================================================== RCS file: /cvsroot/todo-manager/todo-manager/Attic/tdm_calendar.py,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- tdm_calendar.py 24 May 2002 04:25:54 -0000 1.1.2.9 +++ tdm_calendar.py 24 May 2002 12:21:49 -0000 1.1.2.10 @@ -9,8 +9,8 @@ # $Revision$ from Tkinter import * -from time import * from calendar import monthrange +import time # Class Calendar # @@ -27,6 +27,7 @@ # 3. The calendar date can be changed to any mounth with function ChangeTime(year,month). # 4. The current calendar date can be obtained with function GetDate(). # The integers year and month will be returned. + class Calendar(Frame): def __init__(self,master,command=None,**kw): Frame.__init__(self, master, kw) @@ -65,30 +66,26 @@ for i in range(1,8): # Column loop DayCount=DayCount+1 - if DayCount >0 and DayCount<=DaysInMonth: - if DayCount==self.day: #Current day in red - Button(self,text=str(DayCount),bd=0,width=1,height=1,relief=FLAT, - fg='darkred',bg=self.__bgcolor, - command= lambda s=self, p=DayCount: s.GetDay(p)).grid(row=j,column=i) - else: - if i==1 or i==7: # Saturdays and sundays in gray + if DayCount > 0 and DayCount <= DaysInMonth: + fg = 'black' # The default color + if DayCount == self.day: + fg = 'darkred' # The current day in red + elif i == 1 or i == 7: + fg = 'gray40' # The weekend should be gray - Button(self,text=str(DayCount),bd=0,width=1,height=1,relief=FLAT, - fg='gray40',bg=self.__bgcolor, - command= lambda s=self, p=DayCount: s.GetDay(p)).grid(row=j,column=i) - else: - Button(self,text=str(DayCount),bd=0,width=1,height=1,relief=FLAT, - fg='black',bg=self.__bgcolor, - command= lambda s=self, p=DayCount: s.GetDay(p)).grid(row=j,column=i) + Button(self,text=str(DayCount),bd=0,width=1,height=1,relief=FLAT, + fg=fg,bg=self.__bgcolor, + command= lambda s=self, p=DayCount: s.SelDay(p)).grid(row=j,column=i) else: - # Required to make shore their are the right number of rows + # Required to make sure there are the right number of rows Label(self,text='',bd=0,width=1,height=1,relief=FLAT,bg=self.__bgcolor).grid( row=j,column=i) i=i+1 # Returns the day the user has selected with the mouse - def GetDay(self): + def SelDay(self, p): + self.day = p if self.__LeftClickDateCommand: self.__LeftClickDateCommand(p) @@ -125,9 +122,9 @@ def SetCurrentDate(self): # Obtaining the current locale time - temptime=localtime(time()) + temptime=time.localtime(time.time()) - self.month = int(strftime('%m',temptime)) - self.year = int(strftime('%Y',temptime)) - self.day = int(strftime('%j',temptime)) + self.year = temptime[0] + self.month = temptime[1] + self.day = temptime[2] self.Draw() |