Index: Thuban/UI/__init__.py
===================================================================
--- Thuban/UI/__init__.py	(Revision 2758)
+++ Thuban/UI/__init__.py	(Arbeitskopie)
@@ -1,11 +1,15 @@
-# Copyright (c) 2001, 2002, 2003, 2005 by Intevation GmbH
+# Copyright (c) 2001, 2002, 2003, 2005, 2007 by Intevation GmbH
 # Authors:
-# Bernhard Herzog <bh@intevation.de>
+# Bernhard Herzog <bh@intevation.de>  2001, 2002, 2003, 2005
+# Bernhard Reiter <bernhard@intevation.de> 2007
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with Thuban for details.
 
 
+
+_wx_can_be_imported = False
+
 _locale = None
 def install_wx_translation():
     """Install the wx translation function in Thuban.
@@ -14,10 +18,12 @@
     Thuban/__init__.py
     """
     global _locale
+    global _wx_can_be_imported
     import Thuban
     if not Thuban.translation_function_installed():
         # Only import wx modules when we actually can install the
         # function so that the test suite can inhibit this
+        _wx_can_be_imported = True
         import wx
         wx.Locale_AddCatalogLookupPathPrefix(Thuban._message_dir)
         _locale = wx.Locale(wx.LANGUAGE_DEFAULT)
@@ -75,3 +81,29 @@
 
 
 install_wx_translation()
+
+# We define a function that will return the internal representation
+# for a value returned from wxString.
+# This depends on if we have a unicode build and which encoding we run.
+internal_from_wxstring = lambda x: x  # identity
+
+def install_internal_from_wxstring():
+    """Install the needed internal_from_wxstring() function.
+
+    For unicode builds wxString will return a unicode object according to
+    the wxPython documentation (looked up in changelog coming with 2.6.3)
+    we need to convert this back to internal, unless we use unicode objects
+    internally already.
+
+    Otherwise no conversion will need to be done.
+    """
+    global _wx_can_be_imported
+    global internal_from_wxstring
+
+    if _wx_can_be_imported:
+        import Thuban
+        import wx
+        if wx.USE_UNICODE == 1 and Thuban.get_internal_encoding != "unicode":
+            internal_from_wxstring = lambda x : Thuban.internal_from_unicode(x)
+
+install_internal_from_wxstring()
Index: Thuban/UI/classgen.py
===================================================================
--- Thuban/UI/classgen.py	(Revision 2758)
+++ Thuban/UI/classgen.py	(Arbeitskopie)
@@ -25,6 +25,7 @@
 
 from Thuban.Model.layer import SHAPETYPE_ARC
 from Thuban.Model.range import Range
+from Thuban.UI import internal_from_wxstring
 from Thuban.UI.common import ThubanBeginBusyCursor, ThubanEndBusyCursor
 
 import classifier, resource
@@ -213,7 +214,7 @@
 
         assert index != -1, "button should be disabled!"
 
-        genSel = self.genChoice.GetString(index)
+        genSel = internal_from_wxstring(self.genChoice.GetString(index))
         clazz, genPanel = self.genChoice.GetClientData(index)
 
         propPanel = self.propPanel
Index: Thuban/UI/mainwindow.py
===================================================================
--- Thuban/UI/mainwindow.py	(Revision 2758)
+++ Thuban/UI/mainwindow.py	(Arbeitskopie)
@@ -29,6 +29,7 @@
 from Thuban.Model.session import create_empty_session
 from Thuban.Model.layer import Layer, RasterLayer
 from Thuban.Model.postgisdb import PostGISShapeStore, has_postgis_support
+from Thuban.UI import internal_from_wxstring
 from wx.lib.dialogs import MultipleChoiceDialog
 
 import view
@@ -514,8 +515,8 @@
             self.canvas.Destroy()
             self.Destroy()
 
-    def SetMap(self, map):
-        self.canvas.SetMap(map)
+    def SetMap(self, mymap):
+        self.canvas.SetMap(mymap)
         self.update_title()
 
         dialog = self.FindRegisteredDock("legend")
@@ -551,7 +552,6 @@
         name = "dbmanagement"
         dialog = self.get_open_dialog(name)
         if dialog is None:
-            map = self.canvas.Map()
             dialog = DBFrame(self, name, self.application.Session())
             self.add_dialog(name, dialog)
             dialog.Show()
@@ -564,11 +564,11 @@
                            _("All Files (*.*)") + "|*.*",
                            wx.OPEN | wx.MULTIPLE)
         if dlg.ShowModal() == wx.ID_OK:
-            filenames = dlg.GetPaths()
+            filenames = map(internal_from_wxstring, dlg.GetPaths())
             for filename in filenames:
                 title = os.path.splitext(os.path.basename(filename))[0]
-                map = self.canvas.Map()
-                has_layers = map.HasLayers()
+                mymap = self.canvas.Map()
+                has_layers = mymap.HasLayers()
                 try:
                     store = self.application.Session().OpenShapefile(filename)
                 except IOError:
@@ -577,7 +577,7 @@
                                        _("Can't open the file '%s'.")%filename)
                 else:
                     layer = Layer(title, store)
-                    map.AddLayer(layer)
+                    mymap.AddLayer(layer)
                     if not has_layers:
                         # if we're adding a layer to an empty map, fit the
                         # new map to the window
@@ -590,10 +590,10 @@
                            self.application.Path("data"), "", "*.*",
                            wx.OPEN)
         if dlg.ShowModal() == wx.ID_OK:
-            filename = dlg.GetPath()
+            filenames = map(internal_from_wxstring, dlg.GetPaths())
             title = os.path.splitext(os.path.basename(filename))[0]
-            map = self.canvas.Map()
-            has_layers = map.HasLayers()
+            mymap = self.canvas.Map()
+            has_layers = mymap.HasLayers()
             try:
                 layer = RasterLayer(title, filename)
             except IOError:
@@ -601,7 +601,7 @@
                 self.RunMessageBox(_("Add Image Layer"),
                                    _("Can't open the file '%s'.") % filename)
             else:
-                map.AddLayer(layer)
+                mymap.AddLayer(layer)
                 if not has_layers:
                     # if we're adding a layer to an empty map, fit the
                     # new map to the window
@@ -631,10 +631,10 @@
                                    % dbtable)
                 return
 
-            map = self.canvas.Map()
+            mymap = self.canvas.Map()
 
-            has_layers = map.HasLayers()
-            map.AddLayer(layer)
+            has_layers = mymap.HasLayers()
+            mymap.AddLayer(layer)
             if not has_layers:
                 self.canvas.FitMapToWindow()
 
@@ -759,9 +759,9 @@
         dialog = self.get_open_dialog(name)
 
         if dialog is None:
-            map = self.canvas.Map()
+            mymap = self.canvas.Map()
             dialog = projdialog.ProjFrame(self, name,
-                     _("Map Projection: %s") % map.Title(), map)
+                     _("Map Projection: %s") % mymap.Title(), mymap)
             self.add_dialog(name, dialog)
             dialog.Show()
         dialog.Raise()
@@ -774,7 +774,6 @@
         dialog = self.get_open_dialog(name)
 
         if dialog is None:
-            map = self.canvas.Map()
             dialog = projdialog.ProjFrame(self, name,
                      _("Layer Projection: %s") % layer.Title(), layer)
             self.add_dialog(name, dialog)
@@ -1035,7 +1034,7 @@
                 # FIXME: bring dialog to front?
                 pass
 
-    def title_changed(self, map):
+    def title_changed(self, mymap):
         """Subscribed to the canvas' TITLE_CHANGED messages"""
         self.update_title()
 
@@ -1052,9 +1051,9 @@
         class this usually only means that a different map has been set
         or the current map's title has changed.
         """
-        map = self.Map()
-        if map is not None:
-            title = _("Thuban - %s") % (map.Title(),)
+        mymap = self.Map()
+        if mymap is not None:
+            title = _("Thuban - %s") % (mymap.Title(),)
         else:
             title = _("Thuban")
         self.SetTitle(title)
@@ -1127,9 +1126,9 @@
     """Return true iff theres a visible map in the mainwindow.
 
     A visible map is a map with at least one visible layer."""
-    map = context.mainwindow.Map()
-    if map is not None:
-        for layer in map.Layers():
+    mymap = context.mainwindow.Map()
+    if mymap is not None:
+        for layer in mymap.Layers():
             if layer.Visible():
                 return True
     return False
