Adding support for defining user icons on VariableLocationTree
authorlaurent
Sun, 29 Nov 2009 16:34:02 +0100
changeset 439 aa7266534461
parent 438 6d73b097efb5
child 440 f122eb4248b6
Adding support for defining user icons on VariableLocationTree
Beremiz.py
--- a/Beremiz.py	Sun Nov 29 16:32:52 2009 +0100
+++ b/Beremiz.py	Sun Nov 29 16:34:02 2009 +0100
@@ -1006,9 +1006,13 @@
             locations_infos[location_name] = {"expanded" : False}
         
         if location["type"] in [LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP]:
-            leftwindow.SetBackgroundColour(WINDOW_COLOUR)
-            rightwindow.SetBackgroundColour(WINDOW_COLOUR)
-                    
+            if location["type"] == LOCATION_GROUP:
+                leftwindow.SetBackgroundColour(wx.WHITE)
+                rightwindow.SetBackgroundColour(wx.WHITE)
+            else:
+                leftwindow.SetBackgroundColour(WINDOW_COLOUR)
+                rightwindow.SetBackgroundColour(WINDOW_COLOUR)
+            
             st = wx.StaticText(leftwindow, -1)
             st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
             st.SetLabel(location["location"])
@@ -1046,7 +1050,10 @@
             leftwindowsizer.Add(wx.Size(20, 16), 0)
             
         sb = wx.StaticBitmap(leftwindow, -1)
-        sb.SetBitmap(wx.Bitmap(os.path.join(base_folder, "plcopeneditor", 'Images', '%s.png' % self.LOCATION_BITMAP[location["type"]])))
+        icon = location.get("icon")
+        if icon is None:
+            icon = os.path.join(base_folder, "plcopeneditor", 'Images', '%s.png' % self.LOCATION_BITMAP[location["type"]])
+        sb.SetBitmap(wx.Bitmap(icon))
         leftwindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
         
         st_id = wx.NewId()
@@ -1058,6 +1065,8 @@
             infos.pop("children")
             st.SetFont(wx.Font(faces["size"] * 0.5, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]))
             st.Bind(wx.EVT_LEFT_DOWN, self.GenerateLocationLeftDownFunction(infos))
+        elif location["type"] == LOCATION_GROUP:
+            st.SetFont(wx.Font(faces["size"] * 0.6, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]))
         else:
             st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
         st.SetLabel(label)