@@ -18,8 +18,50 @@ def __init__(self, master, *args, **kwargs):
18
18
self .wm_attributes ("-topmost" , True )
19
19
self .grab_set ()
20
20
21
+ # Set the dialog's size
22
+ self .wm_attributes ("-zoomed" , True )
23
+
21
24
# Create all the dialog's widgets, and set its theme
22
25
self .search_button = ttk .Button (self , text = "Search..." )
23
- self .search_button .pack ( )
26
+ self .search_button .grid ( row = 0 , column = 0 , sticky = "W" )
24
27
style = ttk .Style ()
25
- style .theme_use ("clam" )
28
+ style .theme_use ("clam" )
29
+ self .__create_widgets ()
30
+
31
+ def __create_widgets (self ):
32
+ """Create all the widgets for the file dialog."""
33
+
34
+ # The treeview for the files
35
+ self .treeview = ttk .Treeview (self , columns = ("size" , "modified" ))
36
+ self .treeview .grid (row = 1 , column = 0 , sticky = "NSEW" )
37
+
38
+ # The name column
39
+ self .treeview .heading ("#0" , text = "Name" )
40
+ self .treeview .column ("#0" , anchor = "w" , minwidth = 200 )
41
+
42
+ # The size column
43
+ self .treeview .heading ("size" , text = "Size" )
44
+ self .treeview .column ("size" , anchor = "w" , minwidth = 100 )
45
+
46
+ # The modified column
47
+ self .treeview .heading ("modified" , text = "Modified" )
48
+ self .treeview .column ("modified" , anchor = "w" , minwidth = 300 )
49
+
50
+ # Set the rows' and columns' stretchability
51
+ self .columnconfigure (0 , weight = 1 )
52
+ self .rowconfigure (1 , weight = 1 )
53
+
54
+ def __open_dir (self , dir ):
55
+ """Display the contents of directory DIR."""
56
+
57
+ # Delete all the old rows
58
+ for i in self .treeview .get_children ():
59
+ self .treeview .delete (i )
60
+
61
+ if __name__ == "__main__" :
62
+ # Testing
63
+ root = tkinter .Tk ()
64
+ button = tkinter .Button (root , text = "_FileDialog" , command = lambda : _FileDialog (root ))
65
+ button .pack ()
66
+ ttk .Style ().theme_use ("classic" )
67
+ root .mainloop ()
0 commit comments