[Spambayes-checkins]
spambayes/Outlook2000/dialogs __init__.py, 1.4,
1.5 dialog_map.py, 1.10, 1.11 dlgcore.py, 1.7, 1.8
Adam Walker
xenogeist at users.sourceforge.net
Mon Aug 18 19:33:53 EDT 2003
Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory sc8-pr-cvs1:/tmp/cvs-serv28413/Outlook2000/dialogs
Modified Files:
__init__.py dialog_map.py dlgcore.py
Log Message:
We have a wizard framework now ;) The wizard framework can be tested using "test_dialog.py IDD_WIZARD". Making the actual wizard will have to wait for other day.
Index: __init__.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/__init__.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** __init__.py 17 Aug 2003 21:15:25 -0000 1.4
--- __init__.py 19 Aug 2003 01:33:50 -0000 1.5
***************
*** 26,30 ****
dlg.DoModal()
! def MakePropertyPage(parent, manager, idd):
"""Creates a child dialog box to use as property page in a tab control"""
if manager.dialog_parser is None:
--- 26,30 ----
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:
***************
*** 36,40 ****
import dlgcore
! dlg = dlgcore.ProcessorPage(parent, manager, idd, commands)
return dlg
--- 36,40 ----
import dlgcore
! dlg = dlgcore.ProcessorPage(parent, manager, idd, commands, yoffset)
return dlg
Index: dialog_map.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/dialog_map.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** dialog_map.py 18 Aug 2003 20:00:53 -0000 1.10
--- dialog_map.py 19 Aug 2003 01:33:51 -0000 1.11
***************
*** 246,249 ****
--- 246,317 ----
return "Nothing to see here."
+ def WizardFinish(mgr, window):
+ print "Done!"
+
+ class WizardButtonProcessor(ButtonProcessor):
+ def __init__(self, window, control_ids, pages, finish_fn):
+ ButtonProcessor.__init__(self, window,control_ids)
+ self.back_btn_id = self.other_ids[0]
+ self.page_ids = pages.split()
+ self.currentPage = None
+ self.currentPageIndex = -1
+ self.currentPageHwnd = None
+ self.finish_fn = finish_fn
+ self.page_placeholder_id = self.other_ids[1]
+
+ def Init(self):
+ ButtonProcessor.Init(self)
+ self.back_btn_hwnd = self.GetControl(self.back_btn_id)
+ self.forward_btn_hwnd = self.GetControl()
+ self.forward_captions = win32gui.GetWindowText(self.forward_btn_hwnd).split(",")
+ self.page_placeholder_hwnd = self.GetControl(self.page_placeholder_id)
+ self.switchToPage(0)
+ def atFinish(self):
+ return self.currentPageIndex==len(self.page_ids)-1
+
+ def changeControls(self):
+ win32gui.EnableWindow(self.back_btn_hwnd,self.currentPageIndex!=0)
+ index = 0
+ if self.atFinish():
+ index = 1
+ win32gui.SetWindowText(self.forward_btn_hwnd, self.forward_captions[index])
+
+ def OnClicked(self, id):
+ if id == self.control_id:
+ if self.atFinish():
+ if not self.currentPage.SaveAllControls():
+ return
+ #finish
+ win32gui.EnableWindow(self.forward_btn_hwnd, False)
+ win32gui.EnableWindow(self.back_btn_hwnd, False)
+ try:
+ #optional
+ h = GetControl(self.window.manager.dialog_parser.ids["IDCANCEL"])
+ win32gui.EnableWindow(h, False)
+ except:
+ pass
+
+ self.finish_fn(self.window.manager, self.window)
+ win32gui.SendMessage(self.window.hwnd, win32con.WM_CLOSE, 0, 0)
+ else:
+ #forward
+ self.switchToPage(self.currentPageIndex+1)
+ elif id == self.back_btn_id:
+ #backward
+ self.switchToPage(self.currentPageIndex-1)
+
+ def switchToPage(self, index):
+ if self.currentPageHwnd is not None:
+ if not self.currentPage.SaveAllControls():
+ return 1
+ win32gui.DestroyWindow(self.currentPageHwnd)
+ #template = self.window.manager.dialog_parser.dialogs[self.page_ids[index]]
+ self.currentPage = MakePropertyPage(self.page_placeholder_hwnd, self.window.manager, self.page_ids[index],3)
+ self.currentPageHwnd = self.currentPage.CreateWindow()
+ self.currentPageIndex = index
+ self.changeControls()
+ return 0
+
+
from async_processor import AsyncCommandProcessor
import filter, train
***************
*** 332,335 ****
--- 400,408 ----
(IntProcessor, "IDC_VERBOSE_LOG", "General.verbose"),
(CloseButtonProcessor, "IDOK IDCANCEL"),
+ ),
+ "IDD_WIZARD": (
+ (CloseButtonProcessor, "IDCANCEL"),
+ (WizardButtonProcessor, "IDC_FORWARD_BTN IDC_BACK_BTN IDC_PAGE_PLACEHOLDER",
+ "IDD_GENERAL IDD_FILTER IDD_ADVANCED", WizardFinish),
)
}
Index: dlgcore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/dlgcore.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** dlgcore.py 18 Aug 2003 20:00:53 -0000 1.7
--- dlgcore.py 19 Aug 2003 01:33:51 -0000 1.8
***************
*** 301,310 ****
class ProcessorPage(ProcessorDialog):
! def __init__(self, parent, manager, idd, option_handlers):
ProcessorDialog.__init__(self, parent, manager, idd,option_handlers)
def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# The hardcoded values are a bit of a hack.
! win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOP, 1, 24, 0, 0, win32con.SWP_NOSIZE)
self.LoadAllControls()
def CreateWindow(self):
--- 301,311 ----
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):
self.hwnd = hwnd
# The hardcoded values are a bit of a hack.
! win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOP, 1, self.yoffset, 0, 0, win32con.SWP_NOSIZE)
self.LoadAllControls()
def CreateWindow(self):
More information about the Spambayes-checkins
mailing list