[Spambayes-checkins] spambayes/Outlook2000 addin.py, 1.95, 1.96 manager.py, 1.76, 1.77 tester.py, 1.13, 1.14

Mark Hammond mhammond at users.sourceforge.net
Sun Aug 24 17:51:35 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv28755

Modified Files:
	addin.py manager.py tester.py 
Log Message:
Final nuke of win32ui functions!


Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -d -r1.95 -r1.96
*** addin.py	24 Aug 2003 13:26:28 -0000	1.95
--- addin.py	24 Aug 2003 23:51:32 -0000	1.96
***************
*** 43,47 ****
  import pythoncom
  from win32com.client import constants, getevents
- import win32ui
  
  import win32gui, win32con, win32clipboard # for button images!
--- 43,46 ----
***************
*** 49,52 ****
--- 48,53 ----
  import timer, thread
  
+ from dialogs.dlgutils import SetWaitCursor
+ 
  toolbar_name = "SpamBayes"
  
***************
*** 537,543 ****
  
      try:
!         win32ui.DoWaitCursor(1)
          latest = fetch_latest_dict()
!         win32ui.DoWaitCursor(0)
          latest_ver_string = get_version_string(app_name, version_string_key,
                                                 version_dict=latest)
--- 538,544 ----
  
      try:
!         SetWaitCursor(1)
          latest = fetch_latest_dict()
!         SetWaitCursor(0)
          latest_ver_string = get_version_string(app_name, version_string_key,
                                                 version_dict=latest)
***************
*** 561,566 ****
                "\r\n\r\nWould you like to visit this page now?" \
                % (cur_ver_string, latest_ver_string, url)
!         rc = win32ui.MessageBox(msg, "SpamBayes", win32con.MB_YESNO)
!         if rc == win32con.IDYES:
              print "Opening browser page", url
              os.startfile(url)
--- 562,566 ----
                "\r\n\r\nWould you like to visit this page now?" \
                % (cur_ver_string, latest_ver_string, url)
!         if manager.AskQuestion(msg):
              print "Opening browser page", url
              os.startfile(url)
***************
*** 568,572 ****
          msg = "The latest available version is %s\r\n\r\n" \
                "No later version is available." % latest_ver_string
!         win32ui.MessageBox(msg, "SpamBayes")
  
  # A hook for whatever tests we have setup
--- 568,572 ----
          msg = "The latest available version is %s\r\n\r\n" \
                "No later version is available." % latest_ver_string
!         manager.ReportInformation(msg)
  
  # A hook for whatever tests we have setup
***************
*** 609,613 ****
                  "You must enable SpamBayes before you can delete as spam")
              return
!         win32ui.DoWaitCursor(1)
          # Delete this item as spam.
          spam_folder = None
--- 609,613 ----
                  "You must enable SpamBayes before you can delete as spam")
              return
!         SetWaitCursor(1)
          # Delete this item as spam.
          spam_folder = None
***************
*** 643,647 ****
          # And if the DB can save itself incrementally, do it now
          self.manager.SaveBayesPostIncrementalTrain()
!         win32ui.DoWaitCursor(0)
  
  class ButtonRecoverFromSpamEvent(ButtonDeleteAsEventBase):
--- 643,647 ----
          # And if the DB can save itself incrementally, do it now
          self.manager.SaveBayesPostIncrementalTrain()
!         SetWaitCursor(0)
  
  class ButtonRecoverFromSpamEvent(ButtonDeleteAsEventBase):
***************
*** 659,663 ****
                  "You must enable SpamBayes before you can recover spam")
              return
!         win32ui.DoWaitCursor(1)
          # Get the inbox as the default place to restore to
          # (incase we dont know (early code) or folder removed etc
--- 659,663 ----
                  "You must enable SpamBayes before you can recover spam")
              return
!         SetWaitCursor(1)
          # Get the inbox as the default place to restore to
          # (incase we dont know (early code) or folder removed etc
***************
*** 698,702 ****
          # And if the DB can save itself incrementally, do it now
          self.manager.SaveBayesPostIncrementalTrain()
!         win32ui.DoWaitCursor(0)
  
  # Helpers to work with images on buttons/toolbars.
--- 698,702 ----
          # And if the DB can save itself incrementally, do it now
          self.manager.SaveBayesPostIncrementalTrain()
!         SetWaitCursor(0)
  
  # Helpers to work with images on buttons/toolbars.

Index: manager.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/manager.py,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** manager.py	24 Aug 2003 13:25:53 -0000	1.76
--- manager.py	24 Aug 2003 23:51:32 -0000	1.77
***************
*** 8,12 ****
  import traceback
  import operator
! import win32api, win32con, win32ui
  
  import win32com.client
--- 8,12 ----
  import traceback
  import operator
! import win32api, win32con, win32gui
  
  import win32com.client
***************
*** 22,25 ****
--- 22,55 ----
      True, False = 1, 0
  
+ # Report a message to the user - should only be used for pretty serious errors
+ # hence we also print a traceback.
+ # Module level function so we can report errors creating the manager
+ def _GetParent():
+     try:
+         return win32gui.GetActiveWindow()
+     except win32gui.error:
+         pass
+     return 0
+ 
+ def _DoMessage(message, title, flags):
+     return win32gui.MessageBox(_GetParent(), message, title, flags)
+ 
+ def ReportError(message, title = None):
+     import traceback
+     print "ERROR:", repr(message)
+     if sys.exc_info()[0] is not None:
+         traceback.print_exc()
+     if title is None: title = "SpamBayes"
+     _DoMessage(message, title, win32con.MB_ICONEXCLAMATION)
+ 
+ def ReportInformtation(message, title = None):
+     if title is None: title = "SpamBayes"
+     _DoMessage(message, title, win32con.MB_ICONINFORMATION)
+ 
+ def AskQuestion(message, title = None):
+     if title is None: title = "SpamBayes"
+     return _DoMessage(message, title, win32con.MB_YESNO | \
+                                       win32con.MB_ICONQUESTION) == win32con.IDYES
+ 
  # Notes on Unicode directory names
  # You will have much more success with extended characters in
***************
*** 100,115 ****
          self.num_seen = self.num_spam = self.num_unsure = 0
  
- # Report a message to the user - should only be used for pretty serious errors
- # hence we also print a traceback.
- # Module level function so we can report errors creating the manager
- def ReportError(message, title = None):
-     import traceback
-     print "ERROR:", repr(message)
-     if sys.exc_info()[0] is not None:
-         traceback.print_exc()
-     if title is None:
-         title = "SpamBayes Anti-Spam plugin"
-     win32ui.MessageBox(message, title)
- 
  # Function to "safely" save a pickle, only overwriting
  # the existing file after a successful write.
--- 130,133 ----
***************
*** 387,390 ****
--- 405,412 ----
      def ReportError(self, message, title = None):
          ReportError(message, title)
+     def ReportInformation(self, message, title=None):
+         ReportInformation(message, title)
+     def AskQuestion(self, message, title=None):
+         return AskQuestion(message, title)
  
      # Report a super-serious startup error to the user.

Index: tester.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/tester.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** tester.py	22 Aug 2003 06:12:20 -0000	1.13
--- tester.py	24 Aug 2003 23:51:32 -0000	1.14
***************
*** 423,428 ****
  
  def test(manager):
!     import msgstore, win32ui
!     win32ui.DoWaitCursor(1)
      try: # restore the plugin config at exit.
          msgstore.test_suite_running = True
--- 423,429 ----
  
  def test(manager):
!     import msgstore
!     from dialogs import SetWaitCursor
!     SetWaitCursor(1)
      try: # restore the plugin config at exit.
          msgstore.test_suite_running = True
***************
*** 434,438 ****
          manager.LoadConfig()
          manager.addin.FiltersChanged() # restore original filters.
!         win32ui.DoWaitCursor(0)
  
  if __name__=='__main__':
--- 435,439 ----
          manager.LoadConfig()
          manager.addin.FiltersChanged() # restore original filters.
!         SetWaitCursor(0)
  
  if __name__=='__main__':





More information about the Spambayes-checkins mailing list