1
# This package defines dialog boxes used by the main
2
# SpamBayes Outlook 2k integration code.
5
def LoadDialogs(rc_name = "dialogs.rc"):
6
base_name = os.path.splitext(rc_name)[0]
7
mod_name = "dialogs.resources." + base_name
9
# If we are running from source code, check the .py file is up to date
10
# wrt the .rc file passed in.
11
# If we are running from binaries, the rc name is not used at all - we
12
# assume someone running from source previously generated the .py!
13
if not hasattr(sys, "frozen"):
14
from resources import rc2py
15
rc_path = os.path.dirname( rc2py.__file__ )
16
if not os.path.isabs(rc_name):
17
rc_name = os.path.join( rc_path, rc_name)
18
py_name = os.path.join(rc_path, base_name + ".py")
20
if os.path.exists(py_name):
22
mod = __import__(mod_name)
23
mod = sys.modules[mod_name]
24
mtime = mod._rc_mtime_
26
except (ImportError, AttributeError):
29
stat_data = os.stat(rc_name)
30
rc_mtime = stat_data[stat.ST_MTIME]
31
rc_size = stat_data[stat.ST_SIZE]
33
rc_mtime = rc_size = None
34
if rc_mtime!=mtime or rc_size!=size:
35
# Need to generate the dialog.
36
print "Generating %s from %s" % (py_name, rc_name)
37
rc2py.convert(rc_name, py_name)
41
mod = __import__(mod_name)
42
mod = sys.modules[mod_name]
43
return mod.FakeParser()
45
def ShowDialog(parent, manager, config, idd):
46
"""Displays another dialog"""
47
if manager.dialog_parser is None:
48
manager.dialog_parser = LoadDialogs()
50
commands = dialog_map.dialog_map[idd]
54
parent = win32gui.GetActiveWindow()
55
except win32gui.error:
59
dlg = dlgcore.ProcessorDialog(parent, manager, config, idd, commands)
62
#def ShowWizard(parent, manager, idd = "IDD_WIZARD", use_existing_config = True):
63
# import config_wizard, win32con
64
# config = config_wizard.CreateWizardConfig(manager, use_existing_config)
65
# if ShowDialog(parent, manager, config, idd) == win32con.IDOK:
66
# print "Saving wizard changes"
67
# config_wizard.CommitWizardConfig(manager, config)
69
# print "Cancelling wizard"
70
# config_wizard.CancelWizardConfig(manager, config)
72
def MakePropertyPage(parent, manager, config, idd, yoffset=24):
73
"""Creates a child dialog box to use as property page in a tab control"""
74
if manager.dialog_parser is None:
75
manager.dialog_parser = LoadDialogs()
77
commands = dialog_map.dialog_map[idd]
79
raise "Parent must be the tab control"
82
dlg = dlgcore.ProcessorPage(parent, manager, config, idd, commands, yoffset)
86
SetWaitCursor = dlgutils.SetWaitCursor