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
a5a49818
Commit
a5a49818
authored
Jul 01, 1998
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert \n to \r in strings that are displayed in the dialogs.
parent
8e54abe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
Mac/Lib/EasyDialogs.py
Mac/Lib/EasyDialogs.py
+19
-8
No files found.
Mac/Lib/EasyDialogs.py
View file @
a5a49818
...
@@ -17,6 +17,18 @@ from Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
...
@@ -17,6 +17,18 @@ from Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
import
Qd
import
Qd
import
QuickDraw
import
QuickDraw
import
Dlg
,
Win
,
Evt
,
Events
# sdm7g
import
Dlg
,
Win
,
Evt
,
Events
# sdm7g
import
MacOS
import
string
def
cr2lf
(
text
):
if
'
\
r
'
in
text
:
text
=
string
.
join
(
string
.
split
(
text
,
'
\
r
'
),
'
\
n
'
)
return
text
def
lf2cr
(
text
):
if
'
\
n
'
in
text
:
text
=
string
.
join
(
string
.
split
(
text
,
'
\
n
'
),
'
\
r
'
)
return
text
def
Message
(
msg
,
id
=
256
):
def
Message
(
msg
,
id
=
256
):
"""Display a MESSAGE string.
"""Display a MESSAGE string.
...
@@ -31,7 +43,7 @@ def Message(msg, id=256):
...
@@ -31,7 +43,7 @@ def Message(msg, id=256):
print
"Can't get DLOG resource with id ="
,
id
print
"Can't get DLOG resource with id ="
,
id
return
return
tp
,
h
,
rect
=
d
.
GetDialogItem
(
2
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
2
)
SetDialogItemText
(
h
,
msg
)
SetDialogItemText
(
h
,
lf2cr
(
msg
)
)
d
.
SetDialogDefaultItem
(
1
)
d
.
SetDialogDefaultItem
(
1
)
while
1
:
while
1
:
n
=
ModalDialog
(
None
)
n
=
ModalDialog
(
None
)
...
@@ -58,9 +70,9 @@ def AskString(prompt, default = "", id=257):
...
@@ -58,9 +70,9 @@ def AskString(prompt, default = "", id=257):
print
"Can't get DLOG resource with id ="
,
id
print
"Can't get DLOG resource with id ="
,
id
return
return
tp
,
h
,
rect
=
d
.
GetDialogItem
(
3
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
3
)
SetDialogItemText
(
h
,
prompt
)
SetDialogItemText
(
h
,
lf2cr
(
prompt
)
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
4
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
4
)
SetDialogItemText
(
h
,
default
)
SetDialogItemText
(
h
,
lf2cr
(
default
)
)
# d.SetDialogItem(4, 0, 255)
# d.SetDialogItem(4, 0, 255)
d
.
SetDialogDefaultItem
(
1
)
d
.
SetDialogDefaultItem
(
1
)
d
.
SetDialogCancelItem
(
2
)
d
.
SetDialogCancelItem
(
2
)
...
@@ -68,7 +80,7 @@ def AskString(prompt, default = "", id=257):
...
@@ -68,7 +80,7 @@ def AskString(prompt, default = "", id=257):
n
=
ModalDialog
(
None
)
n
=
ModalDialog
(
None
)
if
n
==
1
:
if
n
==
1
:
tp
,
h
,
rect
=
d
.
GetDialogItem
(
4
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
4
)
return
GetDialogItemText
(
h
)
return
cr2lf
(
GetDialogItemText
(
h
)
)
if
n
==
2
:
return
None
if
n
==
2
:
return
None
...
@@ -96,7 +108,7 @@ def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=258
...
@@ -96,7 +108,7 @@ def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=258
# 4 = Cancel
# 4 = Cancel
# The question string is item 5
# The question string is item 5
tp
,
h
,
rect
=
d
.
GetDialogItem
(
5
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
5
)
SetDialogItemText
(
h
,
question
)
SetDialogItemText
(
h
,
lf2cr
(
question
)
)
if
yes
!=
None
:
if
yes
!=
None
:
tp
,
h
,
rect
=
d
.
GetDialogItem
(
2
)
tp
,
h
,
rect
=
d
.
GetDialogItem
(
2
)
h
.
as_Control
().
SetControlTitle
(
yes
)
h
.
as_Control
().
SetControlTitle
(
yes
)
...
@@ -152,7 +164,7 @@ class ProgressBar:
...
@@ -152,7 +164,7 @@ class ProgressBar:
"""label(text) - Set text in progress box"""
"""label(text) - Set text in progress box"""
self
.
d
.
BringToFront
()
self
.
d
.
BringToFront
()
if
newstr
:
if
newstr
:
self
.
_label
=
newstr
[
0
]
self
.
_label
=
lf2cr
(
newstr
[
0
])
tp
,
text_h
,
rect
=
self
.
d
.
GetDialogItem
(
2
)
tp
,
text_h
,
rect
=
self
.
d
.
GetDialogItem
(
2
)
SetDialogItemText
(
text_h
,
self
.
_label
)
SetDialogItemText
(
text_h
,
self
.
_label
)
...
@@ -209,14 +221,13 @@ class ProgressBar:
...
@@ -209,14 +221,13 @@ class ProgressBar:
def
test
():
def
test
():
import
time
import
time
import
MacOS
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
=
"Indentify"
,
no
=
"Don't identify"
)
ok
=
AskYesNoCancel
(
"Do you want to identify?"
,
yes
=
"Indentify"
,
no
=
"Don't identify"
)
if
ok
>
0
:
if
ok
>
0
:
s
=
AskString
(
"Enter your first name"
)
s
=
AskString
(
"Enter your first name"
)
Message
(
"Thank you,
\
015
%s"
%
`s`
)
Message
(
"Thank you,
\
n
%s"
%
`s`
)
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