From: <sv...@ww...> - 2008-01-20 17:16:48
|
Author: nsmoooose Date: 2008-01-20 09:16:39 -0800 (Sun, 20 Jan 2008) New Revision: 2208 Added: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/controls/ProjectTree.py Modified: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/MainFrame.py Log: All project files is now display in a tree control within the layout tool. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2208 Modified: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/MainFrame.py =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/MainFrame.py 2008-01-14 21:38:24 UTC (rev 2207) +++ branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/MainFrame.py 2008-01-20 17:16:39 UTC (rev 2208) @@ -2,9 +2,10 @@ import wx import wx.richtext -from csp.tools.layout2.scripts.ui.ControlIdGenerator import ControlIdGenerator -from csp.tools.layout2.scripts.ui.CommandControlFactory import CommandControlFactory -from csp.tools.layout2.scripts.ui.controls.SceneWindow import SceneWindow +from ControlIdGenerator import ControlIdGenerator +from CommandControlFactory import CommandControlFactory +from controls.ProjectTree import ProjectTree +from controls.SceneWindow import SceneWindow from commands.MoveCameraToHomeCommand import MoveCameraToHomeCommand from commands.OpenCustomLayoutModelFileCommand import OpenCustomLayoutModelFileCommand @@ -21,6 +22,11 @@ # First, call the base class' __init__ method to create the frame wx.Frame.__init__(self, parent, id, title) + # Get the application object. This object is used to retreive the + # configuration object. + application = wx.GetApp() + + # Create a control id generator. This is used by all helper classes # to actualy define an unique id for each control (menu, toolbar button) # etc. @@ -75,7 +81,9 @@ self.scene = scenePage # Display the tree control with all files in this project. - projectTreePage = wx.TreeCtrl(propertyNotebook, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TR_HAS_BUTTONS | wx.BORDER_NONE) + projectTreePage = ProjectTree(propertyNotebook) + projectTreePage.SetRootDirectory(application.Configuration['LayoutApplication.DataDirectory']) + propertyNotebook.AddPage(projectTreePage, "Project") # Connect idle event. Added: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/controls/ProjectTree.py =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/controls/ProjectTree.py (rev 0) +++ branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/controls/ProjectTree.py 2008-01-20 17:16:39 UTC (rev 2208) @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import os +import wx + +from csp.tools.layout2.layout_module import * + +class ProjectTree(wx.TreeCtrl): + def __init__(self, parent): + wx.TreeCtrl.__init__(self, parent, style=wx.TR_HIDE_ROOT|wx.TR_HAS_BUTTONS|wx.TR_LINES_AT_ROOT) + + def SetRootDirectory(self, directory): + self.DeleteAllItems() + + # Remember the base directory so we can return + # the selected file or folder. + self.baseDirectory = directory + + self.nodeDictionary = {} + # Add the base node that is the parent to all + # nodes. + self.nodeDictionary[self.baseDirectory] = self.AddRoot('CSP') + + for root, dirs, files in os.walk(directory): + # print(root) + parentNode = self.nodeDictionary[root] + if '.svn' in dirs: + dirs.remove('.svn') + if '_svn' in dirs: + dirs.remove('_svn') + for subDirectory in dirs: + newNode = self.AppendItem(parentNode, subDirectory) + self.nodeDictionary[os.path.join(root, subDirectory)] = newNode + for file in files: + if file.lower().endswith('.pyc'): + continue + self.AppendItem(newNode, file) + + def GetSelectedFile(self): + return None \ No newline at end of file |