mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Patch #478654: Expose tk_chooseDirectory.
Also delegate kw arguments through ** calls.
This commit is contained in:
parent
c52d713b7a
commit
25ee87cc50
2 changed files with 14 additions and 4 deletions
|
@ -64,6 +64,10 @@ class SaveAs(_Dialog):
|
||||||
|
|
||||||
command = "tk_getSaveFile"
|
command = "tk_getSaveFile"
|
||||||
|
|
||||||
|
class Directory(_Dialog):
|
||||||
|
"Ask for a directory"
|
||||||
|
|
||||||
|
command = "tk_chooseDirectory"
|
||||||
|
|
||||||
#
|
#
|
||||||
# convenience stuff
|
# convenience stuff
|
||||||
|
@ -71,19 +75,19 @@ class SaveAs(_Dialog):
|
||||||
def askopenfilename(**options):
|
def askopenfilename(**options):
|
||||||
"Ask for a filename to open"
|
"Ask for a filename to open"
|
||||||
|
|
||||||
return apply(Open, (), options).show()
|
return Open(**options).show()
|
||||||
|
|
||||||
def asksaveasfilename(**options):
|
def asksaveasfilename(**options):
|
||||||
"Ask for a filename to save as"
|
"Ask for a filename to save as"
|
||||||
|
|
||||||
return apply(SaveAs, (), options).show()
|
return SaveAs(**options).show()
|
||||||
|
|
||||||
# FIXME: are the following two perhaps a bit too convenient?
|
# FIXME: are the following two perhaps a bit too convenient?
|
||||||
|
|
||||||
def askopenfile(mode = "r", **options):
|
def askopenfile(mode = "r", **options):
|
||||||
"Ask for a filename to open, and returned the opened file"
|
"Ask for a filename to open, and returned the opened file"
|
||||||
|
|
||||||
filename = apply(Open, (), options).show()
|
filename = Open(**options).show()
|
||||||
if filename:
|
if filename:
|
||||||
return open(filename, mode)
|
return open(filename, mode)
|
||||||
return None
|
return None
|
||||||
|
@ -91,11 +95,14 @@ def askopenfile(mode = "r", **options):
|
||||||
def asksaveasfile(mode = "w", **options):
|
def asksaveasfile(mode = "w", **options):
|
||||||
"Ask for a filename to save as, and returned the opened file"
|
"Ask for a filename to save as, and returned the opened file"
|
||||||
|
|
||||||
filename = apply(SaveAs, (), options).show()
|
filename = SaveAs(**options).show()
|
||||||
if filename:
|
if filename:
|
||||||
return open(filename, mode)
|
return open(filename, mode)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def askdirectory (**options):
|
||||||
|
"Ask for a directory, and return the file name"
|
||||||
|
return Directory(**options).show()
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# test stuff
|
# test stuff
|
||||||
|
|
|
@ -51,6 +51,9 @@ Extension modules
|
||||||
|
|
||||||
Library
|
Library
|
||||||
|
|
||||||
|
- tkFileDialog exposes a Directory class and askdirectory
|
||||||
|
convenience function.
|
||||||
|
|
||||||
- Symbolic group names in regular expressions must be unique. For
|
- Symbolic group names in regular expressions must be unique. For
|
||||||
example, the regexp r'(?P<abc>)(?P<abc>)' is not allowed, because a
|
example, the regexp r'(?P<abc>)(?P<abc>)' is not allowed, because a
|
||||||
single name can't mean both "group 1" and "group 2" simultaneously.
|
single name can't mean both "group 1" and "group 2" simultaneously.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue