Josh VanderLinden committed dee17e0

Updating images, made toolbar a little more friendly

Comments (0)

Files changed (5)

         self.toolbar = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT)
         self.toolbar.SetToolBitmapSize((24, 24))
-        save_img =  wx.Bitmap('res/save.jpg', wx.BITMAP_TYPE_JPEG)
+        save_img =  wx.Bitmap('res/save.png', wx.BITMAP_TYPE_PNG)
         add_img =  wx.Bitmap('res/add.png', wx.BITMAP_TYPE_PNG)
         add_sub_img =  wx.Bitmap('res/add_subtask.png', wx.BITMAP_TYPE_PNG)
         collapse_img =  wx.Bitmap('res/collapse.png', wx.BITMAP_TYPE_PNG)
         expand_img =  wx.Bitmap('res/expand.png', wx.BITMAP_TYPE_PNG)
+        delete_img =  wx.Bitmap('res/delete.png', wx.BITMAP_TYPE_PNG)
         self.toolbar.AddSimpleTool(wx.ID_SAVE, save_img, _('Save Task List'), _('Save the task list to the hard drive'))
         self.toolbar.AddSimpleTool(ID_ADD_TASK, add_img, _('Add Task'), _('Create a new task'))
         self.toolbar.AddSimpleTool(ID_ADD_SUBTASK, add_sub_img, _('Add Sub-Task'), _('Create a new subtask'))
         #self.toolbar.AddSimpleTool(ID_COLLAPSE, collapse_img, _('Collapse'), _('Collapse all tasks'))
         self.toolbar.AddSimpleTool(ID_EXPAND, expand_img, _('Expand'), _('Expand all tasks'))
-        self.toolbar.AddSimpleTool(wx.ID_DELETE, collapse_img, _('Delete'), _('Delete this task'))
+        self.toolbar.AddSimpleTool(wx.ID_DELETE, delete_img, _('Delete'), _('Delete this task'))
         self.Bind(wx.EVT_TOOL, self.OnToolClick)
         sizer.Add(self.tree, 1, wx.EXPAND)
         self.Bind(wx.EVT_SIZE, self.UpdateColumnWidths)
+        self.tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.ToggleToolbarButtons)
+        self.ToggleToolbarButtons()
     def UpdateColumnWidths(self, evt=None):
         width, height = self.GetSize()
+    def ToggleToolbarButtons(self, evt=None):
+        """Enable or disable certain toolbar buttons based on the selection"""
+        enable_sub_btns = (self.tree.GetSelection() != self.tree.root)
+        self.toolbar.EnableTool(ID_ADD_SUBTASK, enable_sub_btns)
+        self.toolbar.EnableTool(wx.ID_DELETE, enable_sub_btns)
+        if evt:
+            evt.Skip()
     def AddTask(self, parent=None):
         """Allows the user to add a new task"""
Add a comment to this file


Old image
New image
New image
Add a comment to this file


Old image
New image
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.