Skip to content

Commit 34695a9

Browse files
authored
Merge pull request #13 from j4321/docs
Improve docs
2 parents 0d7d8f3 + 7fbbc52 commit 34695a9

4 files changed

Lines changed: 215 additions & 168 deletions

File tree

docs/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# add these directories to sys.path here. If the directory is relative to the
1313
# documentation root, use os.path.abspath to make it absolute, like shown here.
1414
#
15-
# import os
16-
# import sys
17-
# sys.path.insert(0, os.path.abspath('.'))
15+
import os
16+
import sys
17+
sys.path.insert(0, os.path.abspath('..'))
1818

1919

2020
# -- Project information -----------------------------------------------------
@@ -39,6 +39,8 @@
3939
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4040
# ones.
4141
extensions = [
42+
'sphinx.ext.autodoc',
43+
'sphinx.ext.viewcode',
4244
]
4345

4446
# Add any paths that contain templates here, relative to this directory.

docs/documentation.rst

Lines changed: 20 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,31 @@
11
Documentation
22
=============
33

4-
Functions
5-
---------
4+
askopendirname
5+
--------------
6+
.. autofunction:: tkfilebrowser.askopendirname
67

7-
- *askopendirname*
8+
askopendirnames
9+
---------------
10+
.. autofunction:: tkfilebrowser.askopendirnames
811

9-
Allow the user to choose a single directory. The absolute path of the
10-
chosen directory is returned. If the user cancels, an empty string is
11-
returned.
12-
13-
Syntax:
14-
15-
::
16-
17-
askopendirname(parent=None, title=_("Open"), **kwargs)
18-
19-
- *askopendirnames*
20-
21-
Allow the user to choose multiple directories. A tuple containing the absolute
22-
path of the chosen directories is returned. If the user cancels,
23-
an empty tuple is returned.
24-
25-
Syntax:
26-
27-
::
28-
29-
askopendirnames(parent=None, title=_("Open"), **kwargs)
30-
31-
- *skopenfilename*
12+
askopenfilename
13+
---------------
14+
.. autofunction:: tkfilebrowser.askopenfilename
3215

33-
Allow the user to choose a single file. The absolute path of the
34-
chosen file is returned. If the user cancels, an empty string is
35-
returned.
36-
37-
Syntax:
38-
39-
::
40-
41-
askopenfilename(parent=None, title=_("Open"), **kwargs)
42-
43-
- *askopenfilenames*
16+
askopenfilenames
17+
----------------
18+
.. autofunction:: tkfilebrowser.askopenfilenames
4419

45-
Allow the user to choose multiple files. A tuple containing the absolute
46-
path of the chosen files is returned. If the user cancels,
47-
an empty tuple is returned.
48-
49-
Syntax:
50-
51-
::
52-
53-
askopenfilenames(parent=None, title=_("Open"), **kwargs)
20+
asksaveasfilename
21+
-----------------
22+
.. autofunction:: tkfilebrowser.asksaveasfilename
5423

55-
- *asksaveasfilename*
5624

57-
Allow the user to choose a file path. The file may not exist but
58-
the path to its directory does. If the file already exists, the user
59-
is asked to confirm its replacement.
25+
FileBrowser
26+
-----------
6027

61-
Additional option:
28+
.. autoclass:: tkfilebrowser.FileBrowser
29+
:members:
6230

63-
defaultext : str (e.g. .png)
64-
extension added to filename if none is given (default is none)
65-
66-
Syntax:
67-
68-
::
69-
70-
asksaveasfilename(parent=None, title=_("Save As"), **kwargs)
71-
72-
73-
Optional keywords arguments common to all functions
74-
---------------------------------------------------
75-
76-
parent : Tk or Toplevel instance
77-
parent window
78-
79-
title : str
80-
the title of the filebrowser window
81-
82-
initialdir : str
83-
directory whose content is initially displayed
84-
85-
initialfile : str
86-
initially selected item (just the name, not the full path)
87-
88-
filetypes : list ``[("name", "*.ext1|*.ext2|.."), ...]``
89-
only the files of given filetype will be displayed,
90-
e.g. to allow the user to switch between displaying only PNG or JPG
91-
pictures or dispalying all files:
92-
filtypes=[("Pictures", "\*.png|\*.PNG|\*.jpg|\*.JPG'), ("All files", "\*")]
93-
94-
okbuttontext : str
95-
text displayed on the validate button, if None, the
96-
default text corresponding to the mode is used (either "Open" or "Save")
97-
98-
cancelbuttontext : str
99-
text displayed on the button that cancels the selection.
100-
101-
foldercreation : bool
102-
enable the user to create new folders if True (default)
31+
.. automethod:: __init__

tkfilebrowser/filebrowser.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,44 @@ def __init__(self, parent, initialdir="", initialfile="", mode="openfile",
5252
foldercreation=True, **kw):
5353
"""
5454
Create a filebrowser dialog.
55-
55+
5656
Arguments:
57-
* initialdir: initial folder whose content is displayed
58-
* initialfile: initial selected item (just the name, not the full path)
59-
* mode: openfile, opendir or save
60-
* multiple_selection (open modes only): boolean, allow to select multiple files,
61-
* defaultext (save mode only): extension added to filename if none is given
62-
* filetypes: [('name', '*.ext1|*.ext2|..'), ...]
63-
show only files of given filetype ("*" for all files)
64-
* okbuttontext: text displayed on the validate button, if None, the
65-
default text corresponding to the mode is used (either Open or Save)
66-
* cancelbuttontext: text displayed on the button that cancels the
67-
selection.
68-
* foldercreation: enable the user to create new folders if True (default)
57+
58+
parent : Tk or Toplevel instance
59+
parent window
60+
61+
title : str
62+
the title of the filebrowser window
63+
64+
initialdir : str
65+
directory whose content is initially displayed
66+
67+
initialfile : str
68+
initially selected item (just the name, not the full path)
69+
70+
mode : str
71+
kind of dialog: "openfile", "opendir" or "save"
72+
73+
multiple_selection : bool
74+
whether to allow multiple items selection (open modes only)
75+
76+
defaultext : str (e.g. '.png')
77+
extension added to filename if none is given (default is none)
78+
79+
filetypes : list ``[("name", "*.ext1|*.ext2|.."), ...]``
80+
only the files of given filetype will be displayed,
81+
e.g. to allow the user to switch between displaying only PNG or JPG
82+
pictures or dispalying all files:
83+
``filtypes=[("Pictures", "\*.png|\*.PNG|\*.jpg|\*.JPG'), ("All files", "\*")]``
84+
85+
okbuttontext : str
86+
text displayed on the validate button, default is "Open".
87+
88+
cancelbuttontext : str
89+
text displayed on the button that cancels the selection, default is "Cancel".
90+
91+
foldercreation : bool
92+
enable the user to create new folders if True (default)
6993
"""
7094
# compatibility with tkinter.filedialog arguments: the parent window is called 'master'
7195
if 'master' in kw and parent is None:

0 commit comments

Comments
 (0)