Skip to content

Instantly share code, notes, and snippets.

@whosaysni
Created June 8, 2013 04:03
Show Gist options
  • Save whosaysni/5733994 to your computer and use it in GitHub Desktop.
Save whosaysni/5733994 to your computer and use it in GitHub Desktop.
wx.GenericDirCtrl usage
# coding: utf-8
import wx
class MyDirCtrl(wx.GenericDirCtrl):
def __init__(self, *args, **kwargs):
wx.GenericDirCtrl.__init__(self, *args, **kwargs)
tree = self.GetTreeCtrl()
tree.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnTreeExpanded)
tree.CollapseAll()
def OnTreeExpanded(self, evt):
print 'expanded', evt
class GdctrApp(wx.App):
def OnInit(self):
self.frame = wx.Frame(None, -1, 'GenedicDirCtrl demo')
self.panel = wx.Panel(self.frame)
self.root_sizer = wx.BoxSizer(wx.VERTICAL)
self.root_sizer.Add(self.panel, 1, wx.EXPAND|wx.ALL, 0)
self.panel_sizer = wx.BoxSizer(wx.VERTICAL)
self.gdctr = MyDirCtrl(self.panel, -1)
self.panel_sizer.Add(self.gdctr, 1, wx.EXPAND|wx.ALL, 5)
self.panel.SetSizer(self.panel_sizer)
self.frame.SetSizer(self.root_sizer)
self.SetTopWindow(self.frame)
self.frame.Show(True)
return True
if __name__=='__main__':
app = GdctrApp(0)
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment