annotate Mac/scripts/EditPythonPrefs.py @ 12626:a6c8413b3c4f legacy-trunk

Selecting the macfsn option didn't work, fixed. Fixed the help strings. Swapped the macfsn and help button numbers.
author Jack Jansen <jack.jansen@cwi.nl>
date Tue, 09 May 2000 10:01:52 +0000
parents eaee924efb19
children fc77e34ef274
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 """Edit the Python Preferences file."""
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
2 #
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
3 # This program is getting more and more clunky. It should really
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
4 # be rewritten in a modeless way some time soon.
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 from Dlg import *
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 from Events import *
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8 from Res import *
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
9 import Controls
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 import string
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 import struct
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
12 import macfs
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13 import MacOS
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 import os
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 import sys
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 import Res # For Res.Error
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
17 import pythonprefs
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
18 import EasyDialogs
6298
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
19 import Help
4448
85d38456adf0 Get preference file name from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 4398
diff changeset
20
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21 # resource IDs in our own resources (dialogs, etc)
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 MESSAGE_ID = 256
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23
4398
ec4c42bea69d Moved resources to 510/511: the numbers above 512 gave problems when
Jack Jansen <jack.jansen@cwi.nl>
parents: 4235
diff changeset
24 DIALOG_ID = 511
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 TEXT_ITEM = 1
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 OK_ITEM = 2
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27 CANCEL_ITEM = 3
3484
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
28 DIR_ITEM = 4
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
29 TITLE_ITEM = 5
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
30 OPTIONS_ITEM = 7
6298
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
31 HELP_ITEM = 9
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
32
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
33 # The options dialog. There is a correspondence between
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
34 # the dialog item numbers and the option.
4398
ec4c42bea69d Moved resources to 510/511: the numbers above 512 gave problems when
Jack Jansen <jack.jansen@cwi.nl>
parents: 4235
diff changeset
35 OPT_DIALOG_ID = 510
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
36
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
37 # Map dialog item numbers to option names (and the reverse)
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
38 opt_dialog_map = [
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
39 None,
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
40 "inspect",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
41 "verbose",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
42 "optimize",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
43 "unbuffered",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
44 "debugging",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
45 "keepopen",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
46 "keeperror",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
47 "nointopt",
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
48 "noargs",
6298
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
49 "delayconsole",
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
50 None, None, None, None, None, None, None, None, # 11-18 are different
12593
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11652
diff changeset
51 "tabwarn",
eaee924efb19 Removed string-exception preference, added tabcheck and NavService preference, upped version number.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11652
diff changeset
52 "nosite",
12626
a6c8413b3c4f Selecting the macfsn option didn't work, fixed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12593
diff changeset
53 "nonavservice"]
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
54 opt_dialog_dict = {}
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
55 for i in range(len(opt_dialog_map)):
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
56 if opt_dialog_map[i]:
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
57 opt_dialog_dict[opt_dialog_map[i]] = i
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
58 # 1 thru 10 are the options
4230
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
59 # The GUSI creator/type and delay-console
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
60 OD_CREATOR_ITEM = 11
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
61 OD_TYPE_ITEM = 12
4230
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
62 OD_OK_ITEM = 13
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
63 OD_CANCEL_ITEM = 14
6298
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
64 OD_HELP_ITEM = 22
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
65
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
66 def optinteract(options):
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
67 """Let the user interact with the options dialog"""
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
68 d = GetNewDialog(OPT_DIALOG_ID, -1)
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
69 htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
70 SetDialogItemText(htext, options['creator'])
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
71 htext = d.GetDialogItemAsControl(OD_TYPE_ITEM)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
72 SetDialogItemText(htext, options['type'])
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
73 d.SetDialogDefaultItem(OD_OK_ITEM)
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
74 d.SetDialogCancelItem(OD_CANCEL_ITEM)
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
75
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
76 while 1:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
77 for name in opt_dialog_dict.keys():
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
78 num = opt_dialog_dict[name]
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
79 ctl = d.GetDialogItemAsControl(num)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
80 ctl.SetControlValue(options[name])
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
81 n = ModalDialog(None)
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
82 if n == OD_OK_ITEM:
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
83 htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
84 ncreator = GetDialogItemText(htext)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
85 htext = d.GetDialogItemAsControl(OD_TYPE_ITEM)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
86 ntype = GetDialogItemText(htext)
4230
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
87 if len(ncreator) == 4 and len(ntype) == 4:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
88 options['creator'] = ncreator
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
89 options['type'] = ntype
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
90 return options
4230
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
91 else:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
92 MacOS.SysBeep()
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
93 elif n == OD_CANCEL_ITEM:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
94 return
4230
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
95 elif n in (OD_CREATOR_ITEM, OD_TYPE_ITEM):
41a52ab263da Allow editing selected bits of the GUSI preferences (creator, type and
Jack Jansen <jack.jansen@cwi.nl>
parents: 3504
diff changeset
96 pass
6298
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
97 elif n == OD_HELP_ITEM:
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
98 onoff = Help.HMGetBalloons()
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
99 Help.HMSetBalloons(not onoff)
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
100 elif 1 <= n <= len(opt_dialog_map):
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
101 options[opt_dialog_map[n]] = (not options[opt_dialog_map[n]])
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
102
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
103
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
104 def interact(options, title):
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
105 """Let the user interact with the dialog"""
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
106 try:
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
107 # Try to go to the "correct" dir for GetDirectory
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
108 os.chdir(options['dir'].as_pathname())
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
109 except os.error:
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
110 pass
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
111 d = GetNewDialog(DIALOG_ID, -1)
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
112 htext = d.GetDialogItemAsControl(TITLE_ITEM)
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
113 SetDialogItemText(htext, title)
11652
99c9b126690d Get/set sys.path initializer in new appearance way.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11624
diff changeset
114 path_ctl = d.GetDialogItemAsControl(TEXT_ITEM)
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
115 data = string.joinfields(options['path'], '\r')
11652
99c9b126690d Get/set sys.path initializer in new appearance way.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11624
diff changeset
116 path_ctl.SetControlData(Controls.kControlEditTextPart, Controls.kControlEditTextTextTag, data)
11624
3c213e372b22 Partially converted to Appearance, the dialog still has the old ugly layout and
Jack Jansen <jack.jansen@cwi.nl>
parents: 11517
diff changeset
117
4550
f1244036ebab Fixed to allow sys.path initializer to be longer than 255 chars.
Jack Jansen <jack.jansen@cwi.nl>
parents: 4448
diff changeset
118 d.SelectDialogItemText(TEXT_ITEM, 0, 32767)
f1244036ebab Fixed to allow sys.path initializer to be longer than 255 chars.
Jack Jansen <jack.jansen@cwi.nl>
parents: 4448
diff changeset
119 d.SelectDialogItemText(TEXT_ITEM, 0, 0)
3484
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
120 ## d.SetDialogDefaultItem(OK_ITEM)
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
121 d.SetDialogCancelItem(CANCEL_ITEM)
4550
f1244036ebab Fixed to allow sys.path initializer to be longer than 255 chars.
Jack Jansen <jack.jansen@cwi.nl>
parents: 4448
diff changeset
122 d.GetDialogWindow().ShowWindow()
f1244036ebab Fixed to allow sys.path initializer to be longer than 255 chars.
Jack Jansen <jack.jansen@cwi.nl>
parents: 4448
diff changeset
123 d.DrawDialog()
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
124 while 1:
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
125 n = ModalDialog(None)
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
126 if n == OK_ITEM:
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
127 break
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
128 if n == CANCEL_ITEM:
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
129 return None
3484
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
130 ## if n == REVERT_ITEM:
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
131 ## return [], pythondir
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
132 if n == DIR_ITEM:
2979
7eea9b426802 Added prompts to various file-select dialogs
Jack Jansen <jack.jansen@cwi.nl>
parents: 2873
diff changeset
133 fss, ok = macfs.GetDirectory('Select python home folder:')
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
134 if ok:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
135 options['dir'] = fss
6298
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
136 elif n == HELP_ITEM:
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
137 onoff = Help.HMGetBalloons()
ebd099889721 Implemented balloon help for EditPythonPrefs
Jack Jansen <jack.jansen@cwi.nl>
parents: 6275
diff changeset
138 Help.HMSetBalloons(not onoff)
3504
e8d501c88a3e Added region arg to update calls. And binhex files rebinhexed.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3484
diff changeset
139 if n == OPTIONS_ITEM:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
140 noptions = options
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
141 for k in options.keys():
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
142 noptions[k] = options[k]
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
143 noptions = optinteract(noptions)
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
144 if noptions:
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
145 options = noptions
11652
99c9b126690d Get/set sys.path initializer in new appearance way.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11624
diff changeset
146 data = path_ctl.GetControlData(Controls.kControlEditTextPart, Controls.kControlEditTextTextTag)
99c9b126690d Get/set sys.path initializer in new appearance way.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11624
diff changeset
147 tmp = string.splitfields(data, '\r')
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
148 newpath = []
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
149 for i in tmp:
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
150 if i:
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
151 newpath.append(i)
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
152 options['path'] = newpath
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
153 return options
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
154
3484
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
155
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
156 def edit_preferences():
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
157 handler = pythonprefs.PythonOptions()
11517
71281ff8c6a2 Give a warning if system-wide sys.argv processing is off (because then we
Jack Jansen <jack.jansen@cwi.nl>
parents: 6298
diff changeset
158 options = handler.load()
71281ff8c6a2 Give a warning if system-wide sys.argv processing is off (because then we
Jack Jansen <jack.jansen@cwi.nl>
parents: 6298
diff changeset
159 if options['noargs']:
71281ff8c6a2 Give a warning if system-wide sys.argv processing is off (because then we
Jack Jansen <jack.jansen@cwi.nl>
parents: 6298
diff changeset
160 EasyDialogs.Message('Warning: system-wide sys.argv processing is off.\nIf you dropped an applet I have not seen it.')
71281ff8c6a2 Give a warning if system-wide sys.argv processing is off (because then we
Jack Jansen <jack.jansen@cwi.nl>
parents: 6298
diff changeset
161 result = interact(options, 'System-wide preferences')
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
162 if result:
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
163 handler.save(result)
3484
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
164
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
165 def edit_applet(name):
6275
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
166 handler = pythonprefs.AppletOptions(name)
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
167 result = interact(handler.load(), os.path.split(name)[1])
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
168 if result:
f9fbde75c536 Major overhaul: this is now little more than a user interface, the
Jack Jansen <jack.jansen@cwi.nl>
parents: 6174
diff changeset
169 handler.save(result)
3484
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
170
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
171 def main():
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
172 try:
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
173 h = OpenResFile('EditPythonPrefs.rsrc')
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
174 except Res.Error:
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
175 pass # Assume we already have acces to our own resource
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
176
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
177 if len(sys.argv) <= 1:
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
178 edit_preferences()
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
179 else:
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
180 for appl in sys.argv[1:]:
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
181 edit_applet(appl)
ce27e0328462 Added support for editing override preferences in applets
Jack Jansen <jack.jansen@cwi.nl>
parents: 3462
diff changeset
182
2873
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
183
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
184 if __name__ == '__main__':
315760ba0041 A new home for scripts/applets
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
185 main()