Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
dcdd1516
Commit
dcdd1516
authored
Dec 13, 1999
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the password dialog to use a password control.
parent
bf4c85c2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
50 deletions
+26
-50
Mac/Lib/EasyDialogs.py
Mac/Lib/EasyDialogs.py
+26
-50
No files found.
Mac/Lib/EasyDialogs.py
View file @
dcdd1516
...
...
@@ -20,8 +20,10 @@ import QuickDraw
import
Dialogs
import
Windows
import
Dlg
,
Win
,
Evt
,
Events
# sdm7g
import
Ctl
import
MacOS
import
string
from
ControlAccessor
import
*
# Also import Controls constants
def
cr2lf
(
text
):
if
'
\
r
'
in
text
:
...
...
@@ -97,7 +99,7 @@ def AskString(prompt, default = "", id=261, ok=None, cancel=None):
return
cr2lf
(
GetDialogItemText
(
h
))
if
n
==
2
:
return
None
def
AskPassword
(
prompt
,
default
=
''
,
id
=
264
):
def
AskPassword
(
prompt
,
default
=
''
,
id
=
264
,
ok
=
None
,
cancel
=
None
):
"""Display a PROMPT string and a text entry field with a DEFAULT string.
The string is displayed as bullets only.
...
...
@@ -114,58 +116,28 @@ def AskPassword(prompt, default='', id=264):
if
not
d
:
print
"Can't get DLOG resource with id ="
,
id
return
h
=
d
.
GetDialogItemAsControl
(
3
)
# STATIC TEXT ITEM <= prompt
h
=
d
.
GetDialogItemAsControl
(
3
)
SetDialogItemText
(
h
,
lf2cr
(
prompt
))
h
=
d
.
GetDialogItemAsControl
(
4
)
# EDIT TEXT ITEM
pwd
=
d
.
GetDialogItemAsControl
(
4
)
bullets
=
'
\
245
'
*
len
(
default
)
SetDialogItemText
(
h
,
bullets
)
d
.
SelectDialogItemText
(
4
,
999
,
999
)
## SetControlData(pwd, kControlEditTextPart, kControlEditTextTextTag, bullets)
SetControlData
(
pwd
,
kControlEditTextPart
,
kControlEditTextPasswordTag
,
default
)
d
.
SelectDialogItemText
(
4
,
0
,
999
)
Ctl
.
SetKeyboardFocus
(
d
,
pwd
,
kControlEditTextPart
)
if
ok
!=
None
:
h
=
d
.
GetDialogItemAsControl
(
1
)
h
.
SetControlTitle
(
ok
)
if
cancel
!=
None
:
h
=
d
.
GetDialogItemAsControl
(
2
)
h
.
SetControlTitle
(
cancel
)
d
.
SetDialogDefaultItem
(
Dialogs
.
ok
)
d
.
SetDialogCancelItem
(
Dialogs
.
cancel
)
string
=
default
oldschedparams
=
MacOS
.
SchedParams
(
0
,
0
)
while
1
:
ready
,
ev
=
Evt
.
WaitNextEvent
(
Events
.
everyEvent
,
6
)
if
not
ready
:
continue
what
,
msg
,
when
,
where
,
mod
=
ev
if
what
==
0
:
Dlg
.
DialogSelect
(
ev
)
# for blinking caret
elif
Dlg
.
IsDialogEvent
(
ev
):
if
what
in
(
Events
.
keyDown
,
Events
.
autoKey
):
charcode
=
msg
&
Events
.
charCodeMask
if
(
mod
&
Events
.
cmdKey
):
MacOS
.
SysBeep
()
continue
# don't do cut & paste commands
else
:
if
charcode
==
Events
.
kReturnCharCode
:
break
elif
charcode
==
Events
.
kEscapeCharCode
:
string
=
None
break
elif
charcode
in
(
Events
.
kLeftArrowCharCode
,
Events
.
kBackspaceCharCode
):
string
=
string
[:
-
1
]
else
:
string
=
string
+
chr
(
charcode
)
msg
=
0245
# Octal code for bullet
ev
=
(
what
,
msg
,
when
,
where
,
mod
)
rs
,
win
,
item
=
Dlg
.
DialogSelect
(
ev
)
if
item
==
Dialogs
.
ok
:
break
elif
item
==
Dialogs
.
cancel
:
string
=
None
break
elif
what
==
Events
.
mouseDown
:
part
,
win
=
Win
.
FindWindow
(
where
)
if
part
==
Windows
.
inDrag
and
win
:
win
.
DragWindow
(
where
,
screenbounds
)
elif
part
==
Windows
.
inMenuBar
:
MacOS
.
HandleEvent
(
ev
)
else
:
MacOS
.
SysBeep
()
# Cannot handle selections, unfortunately
elif
what
==
Events
.
updateEvt
:
MacOS
.
HandleEvent
(
ev
)
apply
(
MacOS
.
SchedParams
,
oldschedparams
)
return
string
n
=
ModalDialog
(
None
)
if
n
==
1
:
h
=
d
.
GetDialogItemAsControl
(
4
)
return
cr2lf
(
GetControlData
(
pwd
,
kControlEditTextPart
,
kControlEditTextPasswordTag
))
if
n
==
2
:
return
None
def
AskYesNoCancel
(
question
,
default
=
0
,
yes
=
None
,
no
=
None
,
cancel
=
None
,
id
=
262
):
"""Display a QUESTION string which can be answered with Yes or No.
...
...
@@ -302,10 +274,14 @@ def test():
Message
(
"Testing EasyDialogs."
)
ok
=
AskYesNoCancel
(
"Do you want to proceed?"
)
ok
=
AskYesNoCancel
(
"Do you want to identify?"
,
yes
=
"I
ndentify"
,
no
=
"Don't identify
"
)
ok
=
AskYesNoCancel
(
"Do you want to identify?"
,
yes
=
"I
dentify"
,
no
=
"No
"
)
if
ok
>
0
:
s
=
AskString
(
"Enter your first name"
,
"Joe"
)
Message
(
"Thank you,
\
n
%s"
%
`s`
)
s2
=
AskPassword
(
"Okay %s, tell us your nickname"
%
s
,
s
,
cancel
=
"None"
)
if
not
s2
:
Message
(
"%s has no secret nickname"
%
s
)
else
:
Message
(
"Hello everybody!!
\
n
The secret nickname of %s is %s!!!"
%
(
s
,
s2
))
text
=
(
"Working Hard..."
,
"Hardly Working..."
,
"So far, so good!"
,
"Keep on truckin'"
)
bar
=
ProgressBar
(
"Progress, progress..."
,
100
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment