comparison Mac/scripts/EditPythonPrefs.py @ 11624:3c213e372b22 legacy-trunk

Partially converted to Appearance, the dialog still has the old ugly layout and interaction.
author Jack Jansen <jack.jansen@cwi.nl>
date Thu, 23 Dec 1999 14:34:07 +0000
parents 71281ff8c6a2
children 99c9b126690d
comparison
equal deleted inserted replaced
11623:6f2119cd99d2 11624:3c213e372b22
4 # be rewritten in a modeless way some time soon. 4 # be rewritten in a modeless way some time soon.
5 5
6 from Dlg import * 6 from Dlg import *
7 from Events import * 7 from Events import *
8 from Res import * 8 from Res import *
9 import Controls
9 import string 10 import string
10 import struct 11 import struct
11 import macfs 12 import macfs
12 import MacOS 13 import MacOS
13 import os 14 import os
62 OD_HELP_ITEM = 22 63 OD_HELP_ITEM = 22
63 64
64 def optinteract(options): 65 def optinteract(options):
65 """Let the user interact with the options dialog""" 66 """Let the user interact with the options dialog"""
66 d = GetNewDialog(OPT_DIALOG_ID, -1) 67 d = GetNewDialog(OPT_DIALOG_ID, -1)
67 tp, h, rect = d.GetDialogItem(OD_CREATOR_ITEM) 68 htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM)
68 SetDialogItemText(h, options['creator']) 69 SetDialogItemText(htext, options['creator'])
69 tp, h, rect = d.GetDialogItem(OD_TYPE_ITEM) 70 htext = d.GetDialogItemAsControl(OD_TYPE_ITEM)
70 SetDialogItemText(h, options['type']) 71 SetDialogItemText(htext, options['type'])
71 d.SetDialogDefaultItem(OD_OK_ITEM) 72 d.SetDialogDefaultItem(OD_OK_ITEM)
72 d.SetDialogCancelItem(OD_CANCEL_ITEM) 73 d.SetDialogCancelItem(OD_CANCEL_ITEM)
73 74
74 while 1: 75 while 1:
75 for name in opt_dialog_dict.keys(): 76 for name in opt_dialog_dict.keys():
76 num = opt_dialog_dict[name] 77 num = opt_dialog_dict[name]
77 tp, h, rect = d.GetDialogItem(num) 78 ctl = d.GetDialogItemAsControl(num)
78 h.as_Control().SetControlValue(options[name]) 79 ctl.SetControlValue(options[name])
79 n = ModalDialog(None) 80 n = ModalDialog(None)
80 if n == OD_OK_ITEM: 81 if n == OD_OK_ITEM:
81 tp, h, rect = d.GetDialogItem(OD_CREATOR_ITEM) 82 htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM)
82 ncreator = GetDialogItemText(h) 83 ncreator = GetDialogItemText(htext)
83 tp, h, rect = d.GetDialogItem(OD_TYPE_ITEM) 84 htext = d.GetDialogItemAsControl(OD_TYPE_ITEM)
84 ntype = GetDialogItemText(h) 85 ntype = GetDialogItemText(htext)
85 if len(ncreator) == 4 and len(ntype) == 4: 86 if len(ncreator) == 4 and len(ntype) == 4:
86 options['creator'] = ncreator 87 options['creator'] = ncreator
87 options['type'] = ntype 88 options['type'] = ntype
88 return options 89 return options
89 else: 90 else:
105 # Try to go to the "correct" dir for GetDirectory 106 # Try to go to the "correct" dir for GetDirectory
106 os.chdir(options['dir'].as_pathname()) 107 os.chdir(options['dir'].as_pathname())
107 except os.error: 108 except os.error:
108 pass 109 pass
109 d = GetNewDialog(DIALOG_ID, -1) 110 d = GetNewDialog(DIALOG_ID, -1)
110 tp, h, rect = d.GetDialogItem(TITLE_ITEM) 111 htext = d.GetDialogItemAsControl(TITLE_ITEM)
111 SetDialogItemText(h, title) 112 SetDialogItemText(htext, title)
112 tp, h, rect = d.GetDialogItem(TEXT_ITEM) 113 ctl = d.GetDialogItemAsControl(TEXT_ITEM)
113 ## SetDialogItemText(h, string.joinfields(list, '\r')) 114 data = string.joinfields(options['path'], '\r')
114 h.data = string.joinfields(options['path'], '\r') 115 ctl.SetControlData(Controls.kControlEditTextPart, Controls.kControlEditTextTextTag, data)
116
115 d.SelectDialogItemText(TEXT_ITEM, 0, 32767) 117 d.SelectDialogItemText(TEXT_ITEM, 0, 32767)
116 d.SelectDialogItemText(TEXT_ITEM, 0, 0) 118 d.SelectDialogItemText(TEXT_ITEM, 0, 0)
117 ## d.SetDialogDefaultItem(OK_ITEM) 119 ## d.SetDialogDefaultItem(OK_ITEM)
118 d.SetDialogCancelItem(CANCEL_ITEM) 120 d.SetDialogCancelItem(CANCEL_ITEM)
119 d.GetDialogWindow().ShowWindow() 121 d.GetDialogWindow().ShowWindow()