Created
June 8, 2013 04:03
-
-
Save whosaysni/5733994 to your computer and use it in GitHub Desktop.
wx.GenericDirCtrl usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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