[Spambayes-checkins] spambayes/Outlook2000/dialogs __init__.py, 1.5, 1.6 async_processor.py, 1.3, 1.4 dialog_map.py, 1.15, 1.16 dlgcore.py, 1.9, 1.10 processors.py, 1.6, 1.7 test_dialogs.py, 1.7, 1.8 wizard_processors.py, 1.4, 1.5

Mark Hammond mhammond at users.sourceforge.net
Sat Aug 23 21:05:18 EDT 2003


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

Modified Files:
	__init__.py async_processor.py dialog_map.py dlgcore.py 
	processors.py test_dialogs.py wizard_processors.py 
Log Message:
Explicitly pass the 'config' object around the dialogs, and lots
of Wizard work.  The wizard pretty much is now fully functional (but only
via test_dialogs.py)


Index: __init__.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/__init__.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** __init__.py	19 Aug 2003 01:33:50 -0000	1.5
--- __init__.py	24 Aug 2003 03:05:16 -0000	1.6
***************
*** 9,13 ****
      return rcparser.ParseDialogs(rc_file)
  
! def ShowDialog(parent, manager, idd):
      """Displays another dialog"""
      if manager.dialog_parser is None:
--- 9,13 ----
      return rcparser.ParseDialogs(rc_file)
  
! def ShowDialog(parent, manager, config, idd):
      """Displays another dialog"""
      if manager.dialog_parser is None:
***************
*** 23,30 ****
          
      import dlgcore
!     dlg = dlgcore.ProcessorDialog(parent, manager, idd, commands)
!     dlg.DoModal()
      
! def MakePropertyPage(parent, manager, idd, yoffset=24):
      """Creates a child dialog box to use as property page in a tab control"""
      if manager.dialog_parser is None:
--- 23,41 ----
          
      import dlgcore
!     dlg = dlgcore.ProcessorDialog(parent, manager, config, idd, commands)
!     return dlg.DoModal()
! 
! def ShowWizard(parent, manager, idd = "IDD_WIZARD", use_existing_config = True):
!     import config_wizard, win32con
!     config = config_wizard.CreateWizardConfig(manager, use_existing_config)
!     if ShowDialog(parent, manager, config, idd) == win32con.IDOK:
!         print "Saving wizard changes"
!         config_wizard.CommitWizardConfig(manager, config)
!         manager.SaveConfig()
!     else:
!         print "Cancelling wizard"
!         config_wizard.CancelWizardConfig(manager, config)
      
! def MakePropertyPage(parent, manager, config, idd, yoffset=24):
      """Creates a child dialog box to use as property page in a tab control"""
      if manager.dialog_parser is None:
***************
*** 36,40 ****
          
      import dlgcore
!     dlg = dlgcore.ProcessorPage(parent, manager, idd, commands, yoffset)
      return dlg
      
--- 47,51 ----
          
      import dlgcore
!     dlg = dlgcore.ProcessorPage(parent, manager, config, idd, commands, yoffset)
      return dlg
      

Index: async_processor.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/async_processor.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** async_processor.py	22 Aug 2003 06:13:30 -0000	1.3
--- async_processor.py	24 Aug 2003 03:05:16 -0000	1.4
***************
*** 223,227 ****
                      THREAD_PRIORITY_BELOW_NORMAL=-1
                      win32process.SetThreadPriority(win32api.GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL)
!                     self.func( self.window.manager, progress)
                  finally:
                      try:
--- 223,227 ----
                      THREAD_PRIORITY_BELOW_NORMAL=-1
                      win32process.SetThreadPriority(win32api.GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL)
!                     self.func( self.window.manager, self.window.config, progress)
                  finally:
                      try:

Index: dialog_map.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/dialog_map.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** dialog_map.py	22 Aug 2003 06:13:30 -0000	1.15
--- dialog_map.py	24 Aug 2003 03:05:16 -0000	1.16
***************
*** 195,199 ****
                  return 1
              win32gui.DestroyWindow(self.currentPageHwnd)
!         self.currentPage = MakePropertyPage(self.GetControl(), self.window.manager, self.pages[index])
          self.currentPageHwnd = self.currentPage.CreateWindow()
          self.currentPageIndex = index
--- 195,199 ----
                  return 1
              win32gui.DestroyWindow(self.currentPageHwnd)
!         self.currentPage = MakePropertyPage(self.GetControl(), self.window.manager, self.window.config, self.pages[index])
          self.currentPageHwnd = self.currentPage.CreateWindow()
          self.currentPageIndex = index
***************
*** 236,240 ****
          # form from the options object/
          self.window.SaveAllControls()
!         ShowDialog(parent, self.window.manager, self.idd)
          self.window.LoadAllControls()
          
--- 236,240 ----
          # form from the options object/
          self.window.SaveAllControls()
!         ShowDialog(parent, self.window.manager, self.window.config, self.idd)
          self.window.LoadAllControls()
          
***************
*** 257,269 ****
  
  def WizardFinish(mgr, window):
!     wiz_cd = mgr.wizard_classifier_data
!     mgr.wizard_classifier_data = None
!     mgr.classifier_data.Adopt(wiz_cd)
!     print "Done!"
!     
! def WizardTrainer(mgr, progress):
      import os, manager, train
      bayes_base = os.path.join(mgr.data_directory, "$sbwiz$default_bayes_database")
      mdb_base = os.path.join(mgr.data_directory, "$sbwiz$default_message_database")
      # determine which db manager to use, and create it.
      ManagerClass = manager.GetStorageManagerClass()
--- 257,271 ----
  
  def WizardFinish(mgr, window):
!     print "Wizard Done!"
! 
! def WizardTrainer(mgr, config, progress):
      import os, manager, train
      bayes_base = os.path.join(mgr.data_directory, "$sbwiz$default_bayes_database")
      mdb_base = os.path.join(mgr.data_directory, "$sbwiz$default_message_database")
+     fnames = []
+     for ext in ".pck", ".db":
+         fnames.append(bayes_base+ext)
+         fnames.append(mdb_base+ext)
+     config.wizard.temp_training_names = fnames
      # determine which db manager to use, and create it.
      ManagerClass = manager.GetStorageManagerClass()
***************
*** 272,276 ****
      classifier_data.InitNew()
  
!     rescore = mgr.config.training.rescore
  
      if rescore:
--- 274,278 ----
      classifier_data.InitNew()
  
!     rescore = config.training.rescore
  
      if rescore:
***************
*** 280,285 ****
      progress.set_stages(stages)
  
!     train.real_trainer(classifier_data, mgr.config, mgr.message_store, progress)
  
      orig_classifier_data = mgr.classifier_data
      mgr.classifier_data = classifier_data # temporary
--- 282,289 ----
      progress.set_stages(stages)
  
!     print "About to train with", config.training.spam_folder_ids
!     train.real_trainer(classifier_data, config, mgr.message_store, progress)
  
+     # xxx - more hacks - we should pass the classifier data in.
      orig_classifier_data = mgr.classifier_data
      mgr.classifier_data = classifier_data # temporary
***************
*** 289,303 ****
          if rescore:
              # Setup the "filter now" config to what we want.
!             config = mgr.config.filter_now
!             config.only_unread = False
!             config.only_unseen = False
!             config.action_all = False
!             config.folder_ids = mgr.config.training.ham_folder_ids + mgr.config.training.spam_folder_ids
!             config.include_sub = mgr.config.training.ham_include_sub or mgr.config.training.spam_include_sub
              import filter
!             filter.filterer(mgr, progress)
      
          bayes = classifier_data.bayes
!         progress.set_status("Completed training with %d spam and %d good messages" % (bayes.nspam, bayes.nham))
      finally:
          mgr.wizard_classifier_data = classifier_data
--- 293,310 ----
          if rescore:
              # Setup the "filter now" config to what we want.
!             now_config = config.filter_now
!             now_config.only_unread = False
!             now_config.only_unseen = False
!             now_config.action_all = False
!             now_config.folder_ids = config.training.ham_folder_ids + \
!                                     config.training.spam_folder_ids
!             now_config.include_sub = config.training.ham_include_sub or \
!                                      config.training.spam_include_sub
              import filter
!             filter.filterer(mgr, config, progress)
      
          bayes = classifier_data.bayes
!         progress.set_status("Completed training with %d spam and %d good messages" \
!                             % (bayes.nspam, bayes.nham))
      finally:
          mgr.wizard_classifier_data = classifier_data
***************
*** 340,346 ****
                                    "Filter_Now.include_sub"),
          (AsyncCommandProcessor,   "IDC_START IDC_PROGRESS IDC_PROGRESS_TEXT",
!                                   filter.filterer, "Start Filtering", "Stop Filtering",
!                                   "IDOK IDCANCEL IDC_TAB IDC_BUT_UNSEEN IDC_BUT_UNREAD IDC_BROWSE " \
!                                   "IDC_BUT_ACT_SCORE IDC_BUT_ACT_ALL"),
      ),
      "IDD_FILTER" : (
--- 347,355 ----
                                    "Filter_Now.include_sub"),
          (AsyncCommandProcessor,   "IDC_START IDC_PROGRESS IDC_PROGRESS_TEXT",
!                                   filter.filterer,
!                                   "Start Filtering", "Stop Filtering",
!                                   """IDOK IDCANCEL IDC_TAB IDC_BUT_UNSEEN
!                                   IDC_BUT_UNREAD IDC_BROWSE IDC_BUT_ACT_SCORE
!                                   IDC_BUT_ACT_ALL"""),
      ),
      "IDD_FILTER" : (
***************
*** 408,412 ****
      "IDD_WIZARD_FOLDERS_REST": (
          (wiz.EditableFolderIDProcessor,"IDC_FOLDER_CERTAIN IDC_BROWSE_SPAM",
!                                       "Filter.spam_folder_id", "Wizard.spam_folder_name"),
          (wiz.EditableFolderIDProcessor,"IDC_FOLDER_UNSURE IDC_BROWSE_UNSURE",
                                        "Filter.unsure_folder_id", "Wizard.unsure_folder_name"),
--- 417,422 ----
      "IDD_WIZARD_FOLDERS_REST": (
          (wiz.EditableFolderIDProcessor,"IDC_FOLDER_CERTAIN IDC_BROWSE_SPAM",
!                                       "Filter.spam_folder_id", "Wizard.spam_folder_name",
!                                       "Training.spam_folder_ids"),
          (wiz.EditableFolderIDProcessor,"IDC_FOLDER_UNSURE IDC_BROWSE_UNSURE",
                                        "Filter.unsure_folder_id", "Wizard.unsure_folder_name"),

Index: dlgcore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/dlgcore.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** dlgcore.py	22 Aug 2003 06:13:30 -0000	1.9
--- dlgcore.py	24 Aug 2003 03:05:16 -0000	1.10
***************
*** 177,185 ****
  # options with control IDS, giving a "data driven" dialog.
  class ProcessorDialog(TooltipDialog):
!     def __init__(self, parent, manager, idd, option_handlers):
          TooltipDialog.__init__(self, parent, manager.dialog_parser, idd)
          parser = manager.dialog_parser
          self.manager = manager
!         self.options = manager.options
          self.command_processors = {}
          self.processor_message_map = {} # WM_MESSAGE : [processors_who_want_it]
--- 177,185 ----
  # options with control IDS, giving a "data driven" dialog.
  class ProcessorDialog(TooltipDialog):
!     def __init__(self, parent, manager, config, idd, option_handlers):
          TooltipDialog.__init__(self, parent, manager.dialog_parser, idd)
          parser = manager.dialog_parser
          self.manager = manager
!         self.config = config
          self.command_processors = {}
          self.processor_message_map = {} # WM_MESSAGE : [processors_who_want_it]
***************
*** 299,304 ****
  
  class ProcessorPage(ProcessorDialog):
!     def __init__(self, parent, manager, idd, option_handlers, yoffset):
!         ProcessorDialog.__init__(self, parent, manager, idd,option_handlers)
          self.yoffset = yoffset
      def OnInitDialog(self, hwnd, msg, wparam, lparam):
--- 299,304 ----
  
  class ProcessorPage(ProcessorDialog):
!     def __init__(self, parent, manager, config, idd, option_handlers, yoffset):
!         ProcessorDialog.__init__(self, parent, manager, config, idd,option_handlers)
          self.yoffset = yoffset
      def OnInitDialog(self, hwnd, msg, wparam, lparam):

Index: processors.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/processors.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** processors.py	22 Aug 2003 06:13:30 -0000	1.6
--- processors.py	24 Aug 2003 03:05:16 -0000	1.7
***************
*** 72,77 ****
  class CloseButtonProcessor(ButtonProcessor):
      def OnClicked(self, id):
!         print "clicked"
!         win32gui.SendMessage(self.window.hwnd, win32con.WM_CLOSE, 0, 0)
      def GetPopupHelpText(self, ctrlid):
          return "Closes this dialog"
--- 72,76 ----
  class CloseButtonProcessor(ButtonProcessor):
      def OnClicked(self, id):
!         win32gui.EndDialog(self.window.hwnd, id)
      def GetPopupHelpText(self, ctrlid):
          return "Closes this dialog"

Index: test_dialogs.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/test_dialogs.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_dialogs.py	22 Aug 2003 06:13:30 -0000	1.7
--- test_dialogs.py	24 Aug 2003 03:05:16 -0000	1.8
***************
*** 12,25 ****
          sys.path.append(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")))
      
!     import manager
      mgr = manager.GetManager()
!     from dialogs import ShowDialog
      idd = "IDD_MANAGER"
      if len(sys.argv)>1:
          idd = sys.argv[1]
      if idd=='IDD_WIZARD':
!         # not sure where this should go yet.
!         import config_wizard
!         mgr.options, mgr.config = config_wizard.CreateWizardConfig(mgr)
! 
!     ShowDialog(0, mgr, idd)
--- 12,23 ----
          sys.path.append(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")))
      
!     import manager, win32con
      mgr = manager.GetManager()
!     from dialogs import ShowDialog, ShowWizard
      idd = "IDD_MANAGER"
      if len(sys.argv)>1:
          idd = sys.argv[1]
      if idd=='IDD_WIZARD':
!         ShowWizard(0, mgr, idd)
!     else:
!         ShowDialog(0, mgr, mgr.config, idd)

Index: wizard_processors.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/wizard_processors.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** wizard_processors.py	22 Aug 2003 06:13:30 -0000	1.4
--- wizard_processors.py	24 Aug 2003 03:05:16 -0000	1.5
***************
*** 34,38 ****
          self.finish_fn = finish_fn
          self.page_placeholder_id = self.other_ids[1]
-         self.timer_id = None
  
      def Init(self):
--- 34,37 ----
***************
*** 44,47 ****
--- 43,48 ----
          self.page_stack = []
          self.switchToPage(0)
+         # brute-force timer to check if we can move forward.
+         self.timer_id = timer.set_timer(800, self.OnCheckForwardTimer)
  
      def Done(self):
***************
*** 53,66 ****
      def changeControls(self):
          win32gui.EnableWindow(self.back_btn_hwnd,self.currentPageIndex!=0)
!         if self.window.manager.config.wizard.can_go_next:
!             win32gui.EnableWindow(self.forward_btn_hwnd,1)
!             if self.timer_id is not None:
!                 timer.kill_timer(self.timer_id)
!                 self.timer_id = None
          else:
!             win32gui.EnableWindow(self.forward_btn_hwnd,0)
!             if self.timer_id is None:
!                 self.timer_id = timer.set_timer(500, self.OnCheckForwardTimer)
! 
          index = 0
          if self.atFinish():
--- 54,62 ----
      def changeControls(self):
          win32gui.EnableWindow(self.back_btn_hwnd,self.currentPageIndex!=0)
!         if self.canGoNext():
!             enabled = 1
          else:
!             enabled = 0
!         win32gui.EnableWindow(self.forward_btn_hwnd,enabled)
          index = 0
          if self.atFinish():
***************
*** 71,81 ****
      # should be.  brute-force - check a config boolean on a timer.
      def OnCheckForwardTimer(self, event, time):
!         print "Timer fired"
!         if self.window.manager.config.wizard.can_go_next:
!             timer.kill_timer(self.timer_id)
!             self.timer_id = None
!             win32gui.EnableWindow(self.forward_btn_hwnd,1)
!         # else timer just continues on.
!             
      def OnClicked(self, id):
          if id == self.control_id:
--- 67,77 ----
      # should be.  brute-force - check a config boolean on a timer.
      def OnCheckForwardTimer(self, event, time):
!         #print "Timer fired"
!         if self.canGoNext():
!             enabled = 1
!         else:
!             enabled = 0
!         win32gui.EnableWindow(self.forward_btn_hwnd,enabled)
! 
      def OnClicked(self, id):
          if id == self.control_id:
***************
*** 94,101 ****
                          
                  self.finish_fn(self.window.manager, self.window)
!                 win32gui.SendMessage(self.window.hwnd, win32con.WM_CLOSE, 0, 0)
              else:
                  #forward
!                 if self.currentPage.SaveAllControls():
                      self.page_stack.append(self.currentPageIndex)
                      nextPage = self.getNextPageIndex()
--- 90,97 ----
                          
                  self.finish_fn(self.window.manager, self.window)
!                 win32gui.EndDialog(self.window.hwnd, win32con.IDOK)
              else:
                  #forward
!                 if self.canGoNext() and self.currentPage.SaveAllControls():
                      self.page_stack.append(self.currentPageIndex)
                      nextPage = self.getNextPageIndex()
***************
*** 117,120 ****
--- 113,117 ----
          self.currentPage = MakePropertyPage(self.page_placeholder_hwnd,
                                              self.window.manager,
+                                             self.window.config,
                                              self.page_ids[index],
                                              3)
***************
*** 138,141 ****
--- 135,140 ----
      def atFinish(self):
          return self.currentPageIndex==len(self.page_ids)-1
+     def canGoNext(self):
+         return True
  
  # An implementation with the logic specific to our configuration wizard.
***************
*** 153,165 ****
          index = self.currentPageIndex
          id = self.page_ids[index]
!         config = self.window.manager.config
          ok = True
          if id == 'IDD_WIZARD_FOLDERS_WATCH':
!             # todo - check the folder is valid.
!             pass
          elif id == 'IDD_WIZARD_FOLDERS_REST':
              # Check we have folders.
!             ok = (config.wizard.spam_folder_name or config.wizard.spam_folder_id) and \
!                (config.wizard.unsure_folder_name or config.wizard.unsure_folder_id)
          return ok
          
--- 152,170 ----
          index = self.currentPageIndex
          id = self.page_ids[index]
!         config = self.window.config
          ok = True
          if id == 'IDD_WIZARD_FOLDERS_WATCH':
!             ok = config.filter.watch_folder_ids
          elif id == 'IDD_WIZARD_FOLDERS_REST':
              # Check we have folders.
!             ok = (config.wizard.spam_folder_name or config.filter.spam_folder_id) and \
!                (config.wizard.unsure_folder_name or config.filter.unsure_folder_id)
!         elif id == 'IDD_WIZARD_FOLDERS_TRAIN':
!             ok = config.training.ham_folder_ids and \
!                  config.training.spam_folder_ids
!         elif id == 'IDD_WIZARD_TRAIN':
!             # magically set to False when training finished (and back to True
!             # if a folder ID is changed)
!             ok = not self.window.config.wizard.need_train
          return ok
          
***************
*** 167,171 ****
          index = self.currentPageIndex
          id = self.page_ids[index]
!         config = self.window.manager.config
          print "GetNextPage with current", index, id
          if id == 'IDD_WIZARD_WELCOME':
--- 172,176 ----
          index = self.currentPageIndex
          id = self.page_ids[index]
!         config = self.window.config
          print "GetNextPage with current", index, id
          if id == 'IDD_WIZARD_WELCOME':
***************
*** 180,184 ****
                  assert 0, "oops"
          elif id == 'IDD_WIZARD_FOLDERS_TRAIN':
-             self.window.manager.config.wizard.can_go_next = False
              return 'IDD_WIZARD_TRAIN'
          elif id == 'IDD_WIZARD_TRAIN':
--- 185,188 ----
***************
*** 206,210 ****
  class EditableFolderIDProcessor(opt_processors.FolderIDProcessor):
      def __init__(self, window, control_ids,
!                  option, option_folder_name,
                   use_fqn = False, name_joiner = "; "):
          self.button_id = control_ids[1]
--- 210,214 ----
  class EditableFolderIDProcessor(opt_processors.FolderIDProcessor):
      def __init__(self, window, control_ids,
!                  option, option_folder_name, option_override = None,
                   use_fqn = False, name_joiner = "; "):
          self.button_id = control_ids[1]
***************
*** 215,220 ****
          name_sect_name, name_sub_option_name = option_folder_name.split(".")
          
!         self.option_folder_name = window.options.get_option(name_sect_name,
                                                              name_sub_option_name)
  
          opt_processors.FolderIDProcessor.__init__(self, window, control_ids,
--- 219,230 ----
          name_sect_name, name_sub_option_name = option_folder_name.split(".")
          
!         self.option_folder_name = window.config.get_option(name_sect_name,
!                                                             name_sub_option_name)
!         if option_override:
!             name_sect_name, name_sub_option_name = option_override.split(".")
!             self.option_override = window.config.get_option(name_sect_name,
                                                              name_sub_option_name)
+         else:
+             self.option_override = None
  
          opt_processors.FolderIDProcessor.__init__(self, window, control_ids,
***************
*** 224,243 ****
          # bit of a hack - if "Spam" is default and we have a training folder
          # then use that
!         if self.GetOptionValue() is None and self.window.manager.config.wizard.train_spam_ids:
!             self.SetOptionValue(self.window.manager.config.wizard.train_spam_ids)
! 
  
      def OnCommand(self, wparam, lparam):
!         mgr = self.window.manager
!         code = win32api.HIWORD(wparam)
!         id = win32api.LOWORD(wparam)
!         if id == self.button_id:
!             if self.DoBrowse():
!                 # clobber the name
!                 self.SetOptionValue("", self.option_folder_name)
!         elif id == self.control_id:
              if code==win32con.EN_CHANGE:
!                 if not self.in_setting_name :
                      self.SetOptionValue(None) # reset the folder IDs.
  
      def UpdateControl_FromValue(self):
--- 234,251 ----
          # bit of a hack - if "Spam" is default and we have a training folder
          # then use that
!         if self.GetOptionValue() is None and self.option_override:
!             override = self.GetOptionValue(self.option_override)
!             if override:
!                 # override is a multi-id value, we are single.
!                 self.SetOptionValue(override[0])
!                 self.SetOptionValue("", self.option_folder_name)
  
      def OnCommand(self, wparam, lparam):
!         if id == self.control_id:
              if code==win32con.EN_CHANGE:
!                 print "got change", self.in_setting_name
!                 if not self.in_setting_name:
                      self.SetOptionValue(None) # reset the folder IDs.
+         return opt_processors.FolderIDProcessor.OnCommand(self, wparam, lparam)
  
      def UpdateControl_FromValue(self):
***************
*** 245,262 ****
          id_val = self.GetOptionValue()
          print "Got", name_val, id_val
!         if name_val:
!             assert not id_val, "Shouldn't have both name and id!"
!             self.in_setting_name = True
!             win32gui.SetWindowText(self.GetControl(), name_val)
!             self.in_setting_name = False
          else:
!             if id_val:
!                 self.in_setting_name = True
!                 opt_processors.FolderIDProcessor.UpdateControl_FromValue(self)
!                 self.in_setting_name = False
  
  class TrainFolderIDProcessor(opt_processors.FolderIDProcessor):
      def SetOptionValue(self, value, option = None):
!         self.window.manager.config.wizard.need_train = True
          return opt_processors.FolderIDProcessor.SetOptionValue(self, value, option)
  
--- 253,268 ----
          id_val = self.GetOptionValue()
          print "Got", name_val, id_val
!         self.in_setting_name = True
!         if id_val:
!             self.SetOptionValue("", self.option_folder_name)
!             opt_processors.FolderIDProcessor.UpdateControl_FromValue(self)
          else:
!             if name_val:
!                 win32gui.SetWindowText(self.GetControl(), name_val)
!         self.in_setting_name = False
  
  class TrainFolderIDProcessor(opt_processors.FolderIDProcessor):
      def SetOptionValue(self, value, option = None):
!         self.window.config.wizard.need_train = True
          return opt_processors.FolderIDProcessor.SetOptionValue(self, value, option)
  
***************
*** 267,279 ****
      def Init(self):
          async_processor.AsyncCommandProcessor.Init(self)
!         if self.window.manager.config.wizard.need_train:
              self.StartProcess()
          else:
!             self.window.manager.config.wizard.can_go_next = True
!             self.SetStatusText("Training has already been completed")
      def OnFinished(self, wparam, lparam):
          wasCancelled = wparam
          if not wasCancelled:
!             self.window.manager.config.wizard.can_go_next = True
!             self.window.manager.config.wizard.need_train = False
          return async_processor.AsyncCommandProcessor.OnFinished(self, wparam, lparam)
--- 273,283 ----
      def Init(self):
          async_processor.AsyncCommandProcessor.Init(self)
!         if self.window.config.wizard.need_train:
              self.StartProcess()
          else:
!             self.SetStatusText("Training has already been completed - click Next to move to the next step.")
      def OnFinished(self, wparam, lparam):
          wasCancelled = wparam
          if not wasCancelled:
!             self.window.config.wizard.need_train = False
          return async_processor.AsyncCommandProcessor.OnFinished(self, wparam, lparam)





More information about the Spambayes-checkins mailing list