Search code examples
tkintertk-toolkitdirectory-structure

Display directories in tkinter


I am developing a program which has it's own special folder with sub folders and I want to know if there is a way of displaying all the folders and files in my window like my own custom file browser but I don't mean like the tkinter filedialog.


Solution

  • Don't want to use the built-in versions of things and instead desire to build it yourself to get extra control? Consider using the Treeview; you'll have to provide code to populate the contents, but you can do a multi-column view easily with it where the first column is a hierarchic tree. That's the sort of thing you want when doing an Explorer-like interface. (If you were using the Tcl bindings to Tk, I'd point you to a specific script of interest in the standard widget demonstrator that shows the basics of doing this sort of thing — the “directory browser tree” under “Listboxes and Trees” — but I don't know the Python equivalents well enough to do the same.)