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
3a87f5bb
Commit
3a87f5bb
authored
Nov 14, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a ProgressBar() class (which shows a progress bar). Needs new
resource.
parent
e48aa966
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
Mac/Lib/EasyDialogs.py
Mac/Lib/EasyDialogs.py
+63
-0
No files found.
Mac/Lib/EasyDialogs.py
View file @
3a87f5bb
...
...
@@ -3,6 +3,8 @@
Message(msg) -- display a message and an OK button.
AskString(prompt, default) -- ask for a string, display OK and Cancel buttons.
AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
bar = Progress(label, maxvalue) -- Display a progress bar
bar.set(value) -- Set value
More documentation in each function.
This module uses DLOG resources 256, 257 and 258.
...
...
@@ -10,6 +12,12 @@ Based upon STDWIN dialogs with the same names and functions.
"""
from
Dlg
import
GetNewDialog
,
SetDialogItemText
,
GetDialogItemText
,
ModalDialog
import
Qd
import
addpack
addpack
.
addpack
(
'Tools'
)
addpack
.
addpack
(
'bgen'
)
addpack
.
addpack
(
'qd'
)
import
QuickDraw
def
Message
(
msg
):
...
...
@@ -27,6 +35,7 @@ def Message(msg):
return
tp
,
h
,
rect
=
d
.
GetDialogItem
(
2
)
SetDialogItemText
(
h
,
msg
)
d
.
SetDialogDefaultItem
(
1
)
while
1
:
n
=
ModalDialog
(
None
)
if
n
==
1
:
...
...
@@ -56,6 +65,8 @@ def AskString(prompt, default = ""):
tp
,
h
,
rect
=
d
.
GetDialogItem
(
4
)
SetDialogItemText
(
h
,
default
)
# d.SetDialogItem(4, 0, 255)
d
.
SetDialogDefaultItem
(
1
)
d
.
SetDialogCancelItem
(
2
)
while
1
:
n
=
ModalDialog
(
None
)
if
n
==
1
:
...
...
@@ -90,12 +101,60 @@ def AskYesNoCancel(question, default = 0):
# The question string is item 5
tp
,
h
,
rect
=
d
.
GetDialogItem
(
5
)
SetDialogItemText
(
h
,
question
)
d
.
SetDialogCancelItem
(
4
)
if
default
in
(
2
,
3
,
4
):
d
.
SetDialogDefaultItem
(
default
)
while
1
:
n
=
ModalDialog
(
None
)
if
n
==
1
:
return
default
if
n
==
2
:
return
1
if
n
==
3
:
return
0
if
n
==
4
:
return
-
1
class
ProgressBar
:
def
__init__
(
self
,
label
=
"Working..."
,
maxval
=
100
):
self
.
label
=
label
self
.
maxval
=
maxval
self
.
curval
=
-
1
self
.
d
=
GetNewDialog
(
259
,
-
1
)
tp
,
text_h
,
rect
=
self
.
d
.
GetDialogItem
(
2
)
SetDialogItemText
(
text_h
,
"Progress..."
)
self
.
_update
(
0
)
def
_update
(
self
,
value
):
tp
,
h
,
bar_rect
=
self
.
d
.
GetDialogItem
(
3
)
Qd
.
SetPort
(
self
.
d
)
Qd
.
FrameRect
(
bar_rect
)
# Draw outline
inner_rect
=
Qd
.
InsetRect
(
bar_rect
,
1
,
1
)
Qd
.
ForeColor
(
QuickDraw
.
whiteColor
)
Qd
.
BackColor
(
QuickDraw
.
whiteColor
)
Qd
.
PaintRect
(
inner_rect
)
# Clear internal
l
,
t
,
r
,
b
=
inner_rect
r
=
int
(
l
+
(
r
-
l
)
*
value
/
self
.
maxval
)
inner_rect
=
l
,
t
,
r
,
b
Qd
.
ForeColor
(
QuickDraw
.
blackColor
)
Qd
.
BackColor
(
QuickDraw
.
blackColor
)
Qd
.
PaintRect
(
inner_rect
)
# Draw bar
# Restore settings
Qd
.
ForeColor
(
QuickDraw
.
blackColor
)
Qd
.
BackColor
(
QuickDraw
.
whiteColor
)
# Test for cancel button
if
ModalDialog
(
self
.
_filterfunc
)
==
1
:
raise
KeyboardInterrupt
def
_filterfunc
(
self
,
d
,
e
,
*
more
):
return
2
# XXXX For now, this disables the cancel button
def
set
(
self
,
value
):
if
value
<
0
:
value
=
0
if
value
>
self
.
maxval
:
value
=
self
.
maxval
self
.
_update
(
value
)
def
test
():
...
...
@@ -104,6 +163,10 @@ def test():
if
ok
>
0
:
s
=
AskString
(
"Enter your first name"
)
Message
(
"Thank you,
\
015
%s"
%
`s`
)
bar
=
ProgressBar
(
"Counting..."
,
100
)
for
i
in
range
(
100
):
bar
.
set
(
i
)
del
bar
if
__name__
==
'__main__'
:
...
...
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