Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4639/Outlook2000/dialogs
Modified Files:
dialog_map.py
Log Message:
Add a button on the Statistics tab to reset the Outlook statistics. Also
display the date when the statistics were last reset.
Index: dialog_map.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/dialog_map.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** dialog_map.py 5 Dec 2004 23:28:50 -0000 1.42
--- dialog_map.py 22 Dec 2004 18:55:54 -0000 1.43
***************
*** 17,26 ****
# "dialog specific" processors:
class StatsProcessor(ControlProcessor):
def Init(self):
! text = "\n".join(self.window.manager.stats.GetStats())
win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0, text)
! def GetPopupHelpText(self, cid):
! return "Displays statistics on mail processed by SpamBayes"
class VersionStringProcessor(ControlProcessor):
--- 17,61 ----
# "dialog specific" processors:
class StatsProcessor(ControlProcessor):
+ def __init__(self, window, control_ids):
+ self.button_id = control_ids[1]
+ self.reset_date_id = control_ids[2]
+ ControlProcessor.__init__(self, window, control_ids)
+ self.stats = self.window.manager.stats
+
def Init(self):
! text = "\n".join(self.stats.GetStats())
win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0, text)
! date_label = self.GetControl(self.reset_date_id)
! if self.stats.from_date:
! from time import localtime, strftime
! reset_date = localtime(self.stats.from_date)
! date_string = strftime("%a, %d %b %Y %I:%M:%S %p", reset_date)
! else:
! date_string = "None"
! win32gui.SendMessage(date_label, win32con.WM_SETTEXT, 0, date_string)
!
! def OnCommand(self, wparam, lparam):
! id = win32api.LOWORD(wparam)
! if id == self.button_id:
! self.ResetStatistics()
!
! def GetPopupHelpText(self, idFrom):
! if idFrom == self.control_id:
! return "Displays statistics on mail processed by SpamBayes"
! elif idFrom == self.button_id:
! return "Resets all SpamBayes statistics to zero"
! elif idFrom == self.reset_date_id:
! return "The date and time when the SpamBayes statistics were last
reset"
!
! def ResetStatistics(self):
! question = "This will reset all your saved statistics to
zero.\r\n\r\n" \
! "Are you sure you wish to reset the statistics?"
! flags = win32con.MB_ICONQUESTION | win32con.MB_YESNO |
win32con.MB_DEFBUTTON2
! if win32gui.MessageBox(self.window.hwnd,
! question, "SpamBayes", flags) ==
win32con.IDYES:
! self.stats.Reset()
! self.stats.ResetTotal(True)
! self.Init() # update the statistics display
class VersionStringProcessor(ControlProcessor):
***************
*** 476,480 ****
),
"IDD_STATISTICS" : (
! (StatsProcessor, "IDC_STATISTICS"),
),
"IDD_ADVANCED" : (
--- 511,516 ----
),
"IDD_STATISTICS" : (
! (StatsProcessor, "IDC_STATISTICS IDC_BUT_RESET_STATS " \
! "IDC_LAST_RESET_DATE"),
),
"IDD_ADVANCED" : (
_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins