Skip to content

Commit 538c165

Browse files
committed
💄 Added the Treeview to the dialog, and added a test for when dialogs.py is run itself, but no functionality yet.
1 parent 3fcf254 commit 538c165

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

‎dialogs.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,50 @@ def __init__(self, master, *args, **kwargs):
1818
self.wm_attributes("-topmost", True)
1919
self.grab_set()
2020

21+
# Set the dialog's size
22+
self.wm_attributes("-zoomed", True)
23+
2124
# Create all the dialog's widgets, and set its theme
2225
self.search_button = ttk.Button(self, text="Search...")
23-
self.search_button.pack()
26+
self.search_button.grid(row=0, column=0, sticky="W")
2427
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

Comments
 (0)