]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/tree.py
toolbars can be added inside windows, fix for relative pathnames
[wxWidgets.git] / wxPython / wx / tools / XRCed / tree.py
index c3df6a0ee123c6a6cfb7aea4f6d03192e300ad72..a917f133adfb81e155c6df9e58ca9914fcb550ec 100644 (file)
@@ -19,7 +19,15 @@ class MemoryFile:
         self.name = name
         self.buffer = ''
     def write(self, data):
-        self.buffer += data.encode(g.currentEncoding)
+        if g.currentEncoding:
+            encoding = g.currentEncoding
+        else:
+            encoding = wxGetDefaultPyEncoding()
+        try:
+            self.buffer += data.encode(encoding)
+        except UnicodeEncodeError:
+            self.buffer += data.encode(encoding, 'xmlcharrefreplace')
+            
     def close(self):
         wxMemoryFSHandler_AddFile(self.name, self.buffer)
 
@@ -355,6 +363,8 @@ class HighLightBox:
     def Remove(self):
         map(wxWindow.Destroy, self.lines)
         g.testWin.highLight = None
+    def Refresh(self):
+        map(wxWindow.Refresh, self.lines)
 
 ################################################################################
 
@@ -617,7 +627,7 @@ class XML_Tree(wxTreeCtrl):
         g.panel.SetData(xxx)
         # Update tools
         g.tools.UpdateUI()
-        # Hightlighting is done in OnIdle
+        # Highlighting is done in OnIdle
         self.pendingHighLight = self.selection
 
     # Check if item is in testWin subtree
@@ -643,11 +653,12 @@ class XML_Tree(wxTreeCtrl):
         obj, pos = self.FindNodeObject(item), self.FindNodePos(item)
         size = obj.GetSize()
         # Highlight
-        # Nagative positions are not working wuite well
+        # Negative positions are not working quite well
         if g.testWin.highLight:
             g.testWin.highLight.Replace(pos, size)
         else:
             g.testWin.highLight = HighLightBox(pos, size)
+        g.testWin.highLight.Refresh()
         g.testWin.highLight.item = item
 
     def ShowTestWindow(self, item):
@@ -664,7 +675,7 @@ class XML_Tree(wxTreeCtrl):
         if g.testWin:     # Reset old
             self.SetItemBold(g.testWin.item, False)
         self.CreateTestWin(item)
-        # Maybe an error occured, so we need to test
+        # Maybe an error occurred, so we need to test
         if g.testWin: self.SetItemBold(g.testWin.item)
 
     # Double-click on Linux
@@ -769,7 +780,7 @@ class XML_Tree(wxTreeCtrl):
         memFile.close()                 # write to wxMemoryFS
         xmlFlags = wxXRC_NO_SUBCLASSING
         # Use translations if encoding is not specified
-        if g.currentEncoding == 'ascii':
+        if not g.currentEncoding:
             xmlFlags != wxXRC_USE_LOCALE
         res = wxXmlResource('', xmlFlags)
         res.Load('memory:xxx.xrc')