Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
60429e05
Kaydet (Commit)
60429e05
authored
Ara 13, 1999
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed the password dialog to use a password control.
üst
a4deef82
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
50 deletions
+26
-50
EasyDialogs.py
Mac/Lib/EasyDialogs.py
+26
-50
No files found.
Mac/Lib/EasyDialogs.py
Dosyayı görüntüle @
60429e05
...
@@ -20,8 +20,10 @@ import QuickDraw
...
@@ -20,8 +20,10 @@ import QuickDraw
import
Dialogs
import
Dialogs
import
Windows
import
Windows
import
Dlg
,
Win
,
Evt
,
Events
# sdm7g
import
Dlg
,
Win
,
Evt
,
Events
# sdm7g
import
Ctl
import
MacOS
import
MacOS
import
string
import
string
from
ControlAccessor
import
*
# Also import Controls constants
def
cr2lf
(
text
):
def
cr2lf
(
text
):
if
'
\r
'
in
text
:
if
'
\r
'
in
text
:
...
@@ -97,7 +99,7 @@ def AskString(prompt, default = "", id=261, ok=None, cancel=None):
...
@@ -97,7 +99,7 @@ def AskString(prompt, default = "", id=261, ok=None, cancel=None):
return
cr2lf
(
GetDialogItemText
(
h
))
return
cr2lf
(
GetDialogItemText
(
h
))
if
n
==
2
:
return
None
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.
"""Display a PROMPT string and a text entry field with a DEFAULT string.
The string is displayed as bullets only.
The string is displayed as bullets only.
...
@@ -114,58 +116,28 @@ def AskPassword(prompt, default='', id=264):
...
@@ -114,58 +116,28 @@ def AskPassword(prompt, default='', id=264):
if
not
d
:
if
not
d
:
print
"Can't get DLOG resource with id ="
,
id
print
"Can't get DLOG resource with id ="
,
id
return
return
h
=
d
.
GetDialogItemAsControl
(
3
)
# STATIC TEXT ITEM <= prompt
h
=
d
.
GetDialogItemAsControl
(
3
)
SetDialogItemText
(
h
,
lf2cr
(
prompt
))
SetDialogItemText
(
h
,
lf2cr
(
prompt
))
h
=
d
.
GetDialogItemAsControl
(
4
)
# EDIT TEXT ITEM
pwd
=
d
.
GetDialogItemAsControl
(
4
)
bullets
=
'
\245
'
*
len
(
default
)
bullets
=
'
\245
'
*
len
(
default
)
SetDialogItemText
(
h
,
bullets
)
## SetControlData(pwd, kControlEditTextPart, kControlEditTextTextTag, bullets)
d
.
SelectDialogItemText
(
4
,
999
,
999
)
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
.
SetDialogDefaultItem
(
Dialogs
.
ok
)
d
.
SetDialogCancelItem
(
Dialogs
.
cancel
)
d
.
SetDialogCancelItem
(
Dialogs
.
cancel
)
string
=
default
oldschedparams
=
MacOS
.
SchedParams
(
0
,
0
)
while
1
:
while
1
:
ready
,
ev
=
Evt
.
WaitNextEvent
(
Events
.
everyEvent
,
6
)
n
=
ModalDialog
(
None
)
if
not
ready
:
continue
if
n
==
1
:
what
,
msg
,
when
,
where
,
mod
=
ev
h
=
d
.
GetDialogItemAsControl
(
4
)
if
what
==
0
:
Dlg
.
DialogSelect
(
ev
)
# for blinking caret
return
cr2lf
(
GetControlData
(
pwd
,
kControlEditTextPart
,
kControlEditTextPasswordTag
))
elif
Dlg
.
IsDialogEvent
(
ev
):
if
n
==
2
:
return
None
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
def
AskYesNoCancel
(
question
,
default
=
0
,
yes
=
None
,
no
=
None
,
cancel
=
None
,
id
=
262
):
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.
"""Display a QUESTION string which can be answered with Yes or No.
...
@@ -302,10 +274,14 @@ def test():
...
@@ -302,10 +274,14 @@ def test():
Message
(
"Testing EasyDialogs."
)
Message
(
"Testing EasyDialogs."
)
ok
=
AskYesNoCancel
(
"Do you want to proceed?"
)
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
:
if
ok
>
0
:
s
=
AskString
(
"Enter your first name"
,
"Joe"
)
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..."
,
text
=
(
"Working Hard..."
,
"Hardly Working..."
,
"So far, so good!"
,
"Keep on truckin'"
)
"So far, so good!"
,
"Keep on truckin'"
)
bar
=
ProgressBar
(
"Progress, progress..."
,
100
)
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