ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Tool_Box/tkDirectoryChooser.py
Revision: 744
Committed: Tue Apr 13 21:40:41 2021 UTC (4 years, 11 months ago) by nino.borges
Content type: text/x-python
File size: 1132 byte(s)
Log Message:
Updated all tools libs to be python 3 compatible. 

File Contents

# User Rev Content
1 ninoborges 8 #
2     # tkDirectoryChooser.py
3     # $Id$
4     #
5     # tk common directory dialogue
6     #
7     # this module provides interfaces to the native directory dialogue
8     # available in Tk 8.3 and newer.
9     #
10     # written by Fredrik Lundh, November 2000.
11     #
12    
13     #
14     # options (all have default values):
15     #
16     # - initialdir: initial directory. preserved by dialog instance.
17     #
18     # - mustexist: if true, user must pick an existing directory
19     #
20     # - parent: which window to place the dialog on top of
21     #
22     # - title: dialog title
23     #
24    
25 nino.borges 744 from tkinter.commondialog import Dialog
26 ninoborges 8
27     class Chooser(Dialog):
28    
29     command = "tk_chooseDirectory"
30    
31     def _fixresult(self, widget, result):
32     if result:
33     # keep directory until next time
34     self.options["initialdir"] = result
35     self.directory = result # compatibility
36     return result
37    
38     #
39     # convenience stuff
40    
41     def askdirectory(**options):
42     "Ask for a directory name"
43    
44     return apply(Chooser, (), options).show()
45    
46     # --------------------------------------------------------------------
47     # test stuff
48    
49     if __name__ == "__main__":
50    
51 nino.borges 744 print("directory", askdirectory())