Keeyai.com

Pondering the un-ponderable...

Sprial - A fractal flame by Keeyai

DirTreeCtrl - wxPython tree widget for directories

February 18th, 2008 · 2 Comments · KRead This Article!

As I was writing Flame (a GUI for Wix) I really wanted to show the contents of a directory in a tree, JUST like the GenericDirCtrl in wxPython. I tried using the GenericDirCtrl initially, but you really can’t customize it at all, most importantly you cannot set the directory you want to use - it always shows everything from the base drives out. I need this tree control for selecting files that go into an installer, so showing files outside of the relevant directory will be annoying for the experienced users and disastrous for the inexperienced. After a LOT of looking and hacking I didn’t find or create a working solution to the problem, so I started over and wrote the DirTreeCtrl below. It is simply a wx.TreeCtrl with some extra functionality related to the filesystem. When you pass the tree a directory, it gets the directory contents and displays them, querying the OS to get any file extension icons available. The file structure is loaded virtually to minimize memory usage and there is an option in the widget to remove loaded directory data if memory use is critical for you. More features below:

DirTreeCtrl — wxPython widget for displaying directories
Features:

  • Automatically loads files in the given directory
  • File lists loaded on the fly when nodes are expanded so you only load what you need
  • Gets the OS icons used for files when it can to emulate file explorer as much as possible
  • Easily use your own icons for any file extension
  • Automatically loads the correct icon if file shown is a .ico file
  • Does NOT require win32 libraries or anything else outside of normal wxPython install

Check it out here: DirTreeCtrl - wxPython widget for displaying directories

Categories: SoftwareTags: , ,

2 responses so far ↓

  • 1 Alexei Vinidiktov // Feb 18, 2008 at 4:17 am

    I’d like to download DirTreeCtrl but the link http://keeyai.com/projects/dirtreectrl leads nowhere… I’m getting an “Ot ohs, 404″ error message.

  • 2 Keeyai // Feb 18, 2008 at 11:25 am

    You’re absolutely right — I was changing the structure of everything last night and botched that one. The post has been updated with the correct link, and I created a project page for it as well. Sorry!

    New Link

You must log in to post a comment.