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
3032fe6b
Kaydet (Commit)
3032fe6b
authored
Ock 21, 2003
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Spell out the arguments to AskFileForOpen and friends, so help() gives useful
help.
üst
38752819
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
45 deletions
+100
-45
EasyDialogs.py
Lib/plat-mac/EasyDialogs.py
+100
-45
No files found.
Lib/plat-mac/EasyDialogs.py
Dosyayı görüntüle @
3032fe6b
...
@@ -4,6 +4,10 @@ Message(msg) -- display a message and an OK button.
...
@@ -4,6 +4,10 @@ Message(msg) -- display a message and an OK button.
AskString(prompt, default) -- ask for a string, display OK and Cancel buttons.
AskString(prompt, default) -- ask for a string, display OK and Cancel buttons.
AskPassword(prompt, default) -- like AskString(), but shows text as bullets.
AskPassword(prompt, default) -- like AskString(), but shows text as bullets.
AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
GetArgv(optionlist, commandlist) -- fill a sys.argv-like list using a dialog
AskFileForOpen(...) -- Ask the user for an existing file
AskFileForSave(...) -- Ask the user for an output file
AskFolder(...) -- Ask the user to select a folder
bar = Progress(label, maxvalue) -- Display a progress bar
bar = Progress(label, maxvalue) -- Display a progress bar
bar.set(value) -- Set value
bar.set(value) -- Set value
bar.inc( *amount ) -- increment value by amount (default=1)
bar.inc( *amount ) -- increment value by amount (default=1)
...
@@ -31,6 +35,10 @@ import Carbon.File
...
@@ -31,6 +35,10 @@ import Carbon.File
import
macresource
import
macresource
import
os
import
os
__all__
=
[
'Message'
,
'AskString'
,
'AskPassword'
,
'AskYesNoCancel'
,
'GetArgv'
,
'AskFileForOpen'
,
'AskFileForSave'
,
'AskFolder'
,
'Progress'
]
_initialized
=
0
_initialized
=
0
def
_initialize
():
def
_initialize
():
...
@@ -549,49 +557,13 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
...
@@ -549,49 +557,13 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
apply
(
MacOS
.
SchedParams
,
appsw
)
apply
(
MacOS
.
SchedParams
,
appsw
)
del
d
del
d
def
_mktypelist
(
typelist
):
def
_process_Nav_args
(
dftflags
,
**
args
):
# Workaround for OSX typeless files:
if
'TEXT'
in
typelist
and
not
'
\0\0\0\0
'
in
typelist
:
typelist
=
typelist
+
(
'
\0\0\0\0
'
,)
if
not
typelist
:
return
None
data
=
'Pyth'
+
struct
.
pack
(
"hh"
,
0
,
len
(
typelist
))
for
type
in
typelist
:
data
=
data
+
type
return
Carbon
.
Res
.
Handle
(
data
)
_ALLOWED_KEYS
=
{
'version'
:
1
,
'defaultLocation'
:
1
,
'dialogOptionFlags'
:
1
,
'location'
:
1
,
'clientName'
:
1
,
'windowTitle'
:
1
,
'actionButtonLabel'
:
1
,
'cancelButtonLabel'
:
1
,
'savedFileName'
:
1
,
'message'
:
1
,
'preferenceKey'
:
1
,
'popupExtension'
:
1
,
'eventProc'
:
1
,
'previewProc'
:
1
,
'filterProc'
:
1
,
'typeList'
:
1
,
'fileType'
:
1
,
'fileCreator'
:
1
,
# Our extension:
'wanted'
:
1
,
'multiple'
:
1
,
}
def
_process_Nav_args
(
argsargs
,
allowed
,
dftflags
):
import
aepack
import
aepack
import
Carbon.AE
import
Carbon.AE
import
Carbon.File
import
Carbon.File
args
=
argsargs
.
copy
()
for
k
in
args
.
keys
():
for
k
in
args
.
keys
():
if
not
allowed
.
has_key
(
k
)
:
if
args
[
k
]
is
None
:
raise
TypeError
,
"Unknown keyword argument:
%
s"
%
repr
(
k
)
del
args
[
k
]
# Set some defaults, and modify some arguments
# Set some defaults, and modify some arguments
if
not
args
.
has_key
(
'dialogOptionFlags'
):
if
not
args
.
has_key
(
'dialogOptionFlags'
):
args
[
'dialogOptionFlags'
]
=
dftflags
args
[
'dialogOptionFlags'
]
=
dftflags
...
@@ -618,9 +590,37 @@ def _process_Nav_args(argsargs, allowed, dftflags):
...
@@ -618,9 +590,37 @@ def _process_Nav_args(argsargs, allowed, dftflags):
del
args
[
'wanted'
]
del
args
[
'wanted'
]
return
args
,
tpwanted
return
args
,
tpwanted
def
AskFileForOpen
(
**
args
):
def
AskFileForOpen
(
version
=
None
,
defaultLocation
=
None
,
dialogOptionFlags
=
None
,
location
=
None
,
clientName
=
None
,
windowTitle
=
None
,
actionButtonLabel
=
None
,
cancelButtonLabel
=
None
,
message
=
None
,
preferenceKey
=
None
,
popupExtension
=
None
,
eventProc
=
None
,
previewProc
=
None
,
filterProc
=
None
,
typeList
=
None
,
wanted
=
None
,
multiple
=
None
):
"""Display a dialog asking the user for a file to open.
wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
the other arguments can be looked up in Apple's Navigation Services documentation"""
default_flags
=
0x56
# Or 0xe4?
default_flags
=
0x56
# Or 0xe4?
args
,
tpwanted
=
_process_Nav_args
(
args
,
_ALLOWED_KEYS
,
default_flags
)
args
,
tpwanted
=
_process_Nav_args
(
default_flags
,
version
=
version
,
defaultLocation
=
defaultLocation
,
dialogOptionFlags
=
dialogOptionFlags
,
location
=
location
,
clientName
=
clientName
,
windowTitle
=
windowTitle
,
actionButtonLabel
=
actionButtonLabel
,
cancelButtonLabel
=
cancelButtonLabel
,
message
=
message
,
preferenceKey
=
preferenceKey
,
popupExtension
=
popupExtension
,
eventProc
=
eventProc
,
previewProc
=
previewProc
,
filterProc
=
filterProc
,
typeList
=
typeList
,
wanted
=
wanted
,
multiple
=
multiple
)
try
:
try
:
rr
=
Nav
.
NavChooseFile
(
args
)
rr
=
Nav
.
NavChooseFile
(
args
)
good
=
1
good
=
1
...
@@ -640,9 +640,38 @@ def AskFileForOpen(**args):
...
@@ -640,9 +640,38 @@ def AskFileForOpen(**args):
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
FSRefMakePath
(),
'utf8'
)
return
tpwanted
(
rr
.
selection_fsr
[
0
]
.
FSRefMakePath
(),
'utf8'
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
def
AskFileForSave
(
**
args
):
def
AskFileForSave
(
version
=
None
,
defaultLocation
=
None
,
dialogOptionFlags
=
None
,
location
=
None
,
clientName
=
None
,
windowTitle
=
None
,
actionButtonLabel
=
None
,
cancelButtonLabel
=
None
,
savedFileName
=
None
,
message
=
None
,
preferenceKey
=
None
,
popupExtension
=
None
,
eventProc
=
None
,
fileType
=
None
,
fileCreator
=
None
,
wanted
=
None
,
multiple
=
None
):
"""Display a dialog asking the user for a filename to save to.
wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
the other arguments can be looked up in Apple's Navigation Services documentation"""
default_flags
=
0x07
default_flags
=
0x07
args
,
tpwanted
=
_process_Nav_args
(
args
,
_ALLOWED_KEYS
,
default_flags
)
args
,
tpwanted
=
_process_Nav_args
(
default_flags
,
version
=
version
,
defaultLocation
=
defaultLocation
,
dialogOptionFlags
=
dialogOptionFlags
,
location
=
location
,
clientName
=
clientName
,
windowTitle
=
windowTitle
,
actionButtonLabel
=
actionButtonLabel
,
cancelButtonLabel
=
cancelButtonLabel
,
savedFileName
=
savedFileName
,
message
=
message
,
preferenceKey
=
preferenceKey
,
popupExtension
=
popupExtension
,
fileType
=
fileType
,
fileCreator
=
fileCreator
,
wanted
=
wanted
,
multiple
=
multiple
)
try
:
try
:
rr
=
Nav
.
NavPutFile
(
args
)
rr
=
Nav
.
NavPutFile
(
args
)
good
=
1
good
=
1
...
@@ -669,9 +698,35 @@ def AskFileForSave(**args):
...
@@ -669,9 +698,35 @@ def AskFileForSave(**args):
return
tpwanted
(
fullpath
)
return
tpwanted
(
fullpath
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
raise
TypeError
,
"Unknown value for argument 'wanted':
%
s"
%
repr
(
tpwanted
)
def
AskFolder
(
**
args
):
def
AskFolder
(
version
=
None
,
defaultLocation
=
None
,
dialogOptionFlags
=
None
,
location
=
None
,
clientName
=
None
,
windowTitle
=
None
,
actionButtonLabel
=
None
,
cancelButtonLabel
=
None
,
message
=
None
,
preferenceKey
=
None
,
popupExtension
=
None
,
eventProc
=
None
,
filterProc
=
None
,
wanted
=
None
,
multiple
=
None
):
"""Display a dialog asking the user for select a folder.
wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
the other arguments can be looked up in Apple's Navigation Services documentation"""
default_flags
=
0x17
default_flags
=
0x17
args
,
tpwanted
=
_process_Nav_args
(
args
,
_ALLOWED_KEYS
,
default_flags
)
args
,
tpwanted
=
_process_Nav_args
(
default_flags
,
version
=
version
,
defaultLocation
=
defaultLocation
,
dialogOptionFlags
=
dialogOptionFlags
,
location
=
location
,
clientName
=
clientName
,
windowTitle
=
windowTitle
,
actionButtonLabel
=
actionButtonLabel
,
cancelButtonLabel
=
cancelButtonLabel
,
message
=
message
,
preferenceKey
=
preferenceKey
,
popupExtension
=
popupExtension
,
eventProc
=
eventProc
,
filterProc
=
filterProc
,
wanted
=
wanted
,
multiple
=
multiple
)
try
:
try
:
rr
=
Nav
.
NavChooseFolder
(
args
)
rr
=
Nav
.
NavChooseFolder
(
args
)
good
=
1
good
=
1
...
...
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