diff --git a/wxPython/wx/tools/XRCed/CHANGES.txt b/wxPython/wx/tools/XRCed/CHANGES.txt index 743ae3640a..8f9a6e04f2 100644 --- a/wxPython/wx/tools/XRCed/CHANGES.txt +++ b/wxPython/wx/tools/XRCed/CHANGES.txt @@ -5,6 +5,12 @@ Using wx.GetDefaultPyEncoding/wx.SetDefaultPyEncoding for changing active encodi Fixed pasting siblings (Ctrl key pressed while pasting). +Dealed with ascii build (Python does not recognize 'ascii' as valid encoding). +If encoding is not specified it is not written in XRC. Will add more +customization in the future. + +Changed to use SimpleTool instead or Toggle tool (does not work on Win32). + 0.1.5-1 ------- diff --git a/wxPython/wx/tools/XRCed/globals.py b/wxPython/wx/tools/XRCed/globals.py index 18dae74e4a..6ab35862d9 100644 --- a/wxPython/wx/tools/XRCed/globals.py +++ b/wxPython/wx/tools/XRCed/globals.py @@ -4,7 +4,6 @@ # Created: 02.12.2002 # RCS-ID: $Id$ -import wx from wxPython.wx import * from wxPython.xrc import * try: @@ -18,8 +17,10 @@ import sys progname = 'XRCed' version = '0.1.5-2' # Can be changed to set other default encoding different -#defaultEncoding = sys.getdefaultencoding() -defaultEncoding = wx.GetDefaultPyEncoding() +defaultEncoding = '' +# you comment above and can uncomment this: +#import wx +#defaultEncoding = wx.GetDefaultPyEncoding() try: True diff --git a/wxPython/wx/tools/XRCed/panel.py b/wxPython/wx/tools/XRCed/panel.py index 902c0612f5..063061e703 100644 --- a/wxPython/wx/tools/XRCed/panel.py +++ b/wxPython/wx/tools/XRCed/panel.py @@ -13,6 +13,7 @@ class Panel(wxNotebook): def __init__(self, parent, id = -1): if wxPlatform != '__WXMAC__': # some problems with this style on macs wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM) + self.SetBackgroundColour(parent.GetBackgroundColour()) else: wxNotebook.__init__(self, parent, id) global panel diff --git a/wxPython/wx/tools/XRCed/tree.py b/wxPython/wx/tools/XRCed/tree.py index c3df6a0ee1..95fa519d1e 100644 --- a/wxPython/wx/tools/XRCed/tree.py +++ b/wxPython/wx/tools/XRCed/tree.py @@ -19,7 +19,10 @@ class MemoryFile: self.name = name self.buffer = '' def write(self, data): - self.buffer += data.encode(g.currentEncoding) + if g.currentEncoding: + self.buffer += data.encode(g.currentEncoding) + else: + self.buffer += data.encode() def close(self): wxMemoryFSHandler_AddFile(self.name, self.buffer) @@ -355,6 +358,8 @@ class HighLightBox: def Remove(self): map(wxWindow.Destroy, self.lines) g.testWin.highLight = None + def Refresh(self): + map(wxWindow.Refresh, self.lines) ################################################################################ @@ -648,6 +653,7 @@ class XML_Tree(wxTreeCtrl): 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): @@ -769,7 +775,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') diff --git a/wxPython/wx/tools/XRCed/xrced.py b/wxPython/wx/tools/XRCed/xrced.py index fed12e47c4..721198dd7a 100644 --- a/wxPython/wx/tools/XRCed/xrced.py +++ b/wxPython/wx/tools/XRCed/xrced.py @@ -198,9 +198,9 @@ class Frame(wxFrame): tb.AddSimpleTool(wxID_COPY, copy_bmp, 'Copy', 'Copy') tb.AddSimpleTool(self.ID_TOOL_PASTE, paste_bmp, 'Paste', 'Paste') tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL)) - tb.AddCheckTool(self.ID_TOOL_LOCATE, - images.getLocateBitmap(), images.getLocateArmedBitmap(), - 'Locate', 'Locate control in test window and select it') + tb.AddSimpleTool(self.ID_TOOL_LOCATE, + images.getLocateBitmap(), #images.getLocateArmedBitmap(), + 'Locate', 'Locate control in test window and select it', True) tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL)) tb.AddSimpleTool(self.ID_TEST, images.getTestBitmap(), 'Test', 'Test window') tb.AddSimpleTool(self.ID_REFRESH, images.getRefreshBitmap(), @@ -977,6 +977,8 @@ Homepage: http://xrced.sourceforge.net\ if dom.encoding: g.currentEncoding = dom.encoding wx.SetDefaultPyEncoding(g.currentEncoding.encode()) + else: + g.currentEncoding = '' # Change dir self.dataFile = path = os.path.abspath(path) dir = os.path.dirname(path) @@ -1016,9 +1018,9 @@ Homepage: http://xrced.sourceforge.net\ if tree.selection and panel.IsModified(): self.OnRefresh(wxCommandEvent()) if g.currentEncoding: - f = codecs.open(path, 'w', g.currentEncoding) + f = codecs.open(path, 'wt', g.currentEncoding) else: - f = codecs.open(path, 'w') + f = codecs.open(path, 'wt') # Make temporary copy for formatting it # !!! We can't clone dom node, it works only once #self.domCopy = tree.dom.cloneNode(True) diff --git a/wxPython/wx/tools/XRCed/xrced.xrc b/wxPython/wx/tools/XRCed/xrced.xrc index 7af376ede4..f7da582ef8 100644 --- a/wxPython/wx/tools/XRCed/xrced.xrc +++ b/wxPython/wx/tools/XRCed/xrced.xrc @@ -11,34 +11,26 @@ - 250,100 - - - wxALL|wxEXPAND - 5 - - wxEXPAND - wxEXPAND @@ -47,32 +39,25 @@ - - 1 - wxRIGHT - 10 - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 @@ -90,17 +75,13 @@ - - - wxTOP|wxBOTTOM|wxLEFT|wxEXPAND - 5 @@ -109,77 +90,60 @@ - - wxBOTTOM|wxEXPAND - 5 - - wxEXPAND - 10,20 - - - wxBOTTOM|wxEXPAND - 5 - - wxEXPAND - wxALL|wxEXPAND - 5 - - wxEXPAND - wxEXPAND @@ -188,32 +152,25 @@ - - 1 - wxRIGHT - 10 - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 @@ -231,17 +188,13 @@ - - - wxTOP|wxBOTTOM|wxLEFT|wxEXPAND - 5 @@ -250,77 +203,60 @@ - - wxBOTTOM|wxEXPAND - 5 - - wxEXPAND - 10,20 - - - wxBOTTOM|wxEXPAND - 5 - - wxEXPAND - wxALL|wxEXPAND - 5 - - wxEXPAND - wxEXPAND @@ -329,32 +265,25 @@ - - 1 - wxRIGHT - 10 - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 @@ -368,29 +297,22 @@ - - 250,250 - - - wxALL|wxEXPAND - 5 - wxEXPAND @@ -399,32 +321,25 @@ - - 1 - wxRIGHT - 10 - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 @@ -442,23 +357,17 @@ - - 80,100 - - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 @@ -467,43 +376,34 @@ - - wxBOTTOM - 3 - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 5 - - wxEXPAND - wxEXPAND @@ -512,32 +412,25 @@ - - 1 - wxBOTTOM - 5 - - wxALL|wxALIGN_CENTRE_HORIZONTAL - 10 @@ -554,17 +447,14 @@ - - wxALIGN_CENTRE_VERTICAL - wxART_ADD_BOOKMARK wxART_DEL_BOOKMARK @@ -616,20 +506,16 @@ - wxRIGHT|wxEXPAND - 5 - - wxALIGN_CENTRE_VERTICAL @@ -638,38 +524,30 @@ - - wxRIGHT|wxEXPAND - 5 - - 40,-1d - wxRIGHT|wxEXPAND - 5 2 1 - wxEXPAND diff --git a/wxPython/wx/tools/XRCed/xxx.py b/wxPython/wx/tools/XRCed/xxx.py index 03bb4f70bc..32636a5565 100644 --- a/wxPython/wx/tools/XRCed/xxx.py +++ b/wxPython/wx/tools/XRCed/xxx.py @@ -47,12 +47,16 @@ class xxxParam(xxxNode): self.textNode.data = value else: def value(self): - return self.textNode.data.encode(g.currentEncoding) + try: + return self.textNode.data.encode(g.currentEncoding) + except LookupError: + return self.textNode.data.encode() def update(self, value): try: # handle exception if encoding is wrong self.textNode.data = unicode(value, g.currentEncoding) except UnicodeDecodeError: - wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate") + self.textNode.data = unicode(value) + #wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate") # Integer parameter class xxxParamInt(xxxParam):