Browse Source

wxGUI: fix About dialog for Python3

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73289 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 6 years ago
parent
commit
42b1e4bcfb
1 changed files with 10 additions and 8 deletions
  1. 10 8
      gui/wxpython/gui_core/ghelp.py

+ 10 - 8
gui/wxpython/gui_core/ghelp.py

@@ -25,6 +25,11 @@ import textwrap
 import sys
 import sys
 import six
 import six
 
 
+if sys.version_info.major == 2:
+    _unichr = unichr
+else:
+    _unichr = chr
+
 import wx
 import wx
 from wx.html import HtmlWindow
 from wx.html import HtmlWindow
 try:
 try:
@@ -323,9 +328,8 @@ class AboutWindow(wx.Frame):
         # credits
         # credits
         authfile = os.path.join(os.getenv("GISBASE"), "AUTHORS")
         authfile = os.path.join(os.getenv("GISBASE"), "AUTHORS")
         if os.path.exists(authfile):
         if os.path.exists(authfile):
-            authorsFile = open(authfile, 'r')
-            authors = unicode(''.join(authorsFile.readlines()), "utf-8")
-            authorsFile.close()
+            with codecs.open(authfile, encoding='utf-8', mode='r') as authorsFile:
+                authors = ''.join(authorsFile.readlines())
         else:
         else:
             authors = _('%s file missing') % 'AUTHORS'
             authors = _('%s file missing') % 'AUTHORS'
         authorwin = ScrolledPanel(self.aboutNotebook)
         authorwin = ScrolledPanel(self.aboutNotebook)
@@ -431,7 +435,7 @@ class AboutWindow(wx.Frame):
         """Translators info"""
         """Translators info"""
         translatorsfile = os.path.join(os.getenv("GISBASE"), "translators.csv")
         translatorsfile = os.path.join(os.getenv("GISBASE"), "translators.csv")
         if os.path.exists(translatorsfile):
         if os.path.exists(translatorsfile):
-            translatorsFile = open(translatorsfile, 'r')
+            translatorsFile = codecs.open(translatorsfile, encoding='utf-8', mode='r')
             translators = dict()
             translators = dict()
             errLines = list()
             errLines = list()
             for line in translatorsFile.readlines()[1:]:
             for line in translatorsFile.readlines()[1:]:
@@ -494,9 +498,7 @@ class AboutWindow(wx.Frame):
                         StaticText(
                         StaticText(
                             parent=translatorswin,
                             parent=translatorswin,
                             id=wx.ID_ANY,
                             id=wx.ID_ANY,
-                            label=unicode(
-                                name,
-                                "utf-8")))
+                            label=name))
                     translatorsBox.Add(
                     translatorsBox.Add(
                         StaticText(
                         StaticText(
                             parent=translatorswin,
                             parent=translatorswin,
@@ -926,7 +928,7 @@ def _grassDevTeam(start):
         end = date.today().year
         end = date.today().year
 
 
     return '%(c)s %(start)s-%(end)s by the GRASS Development Team' % {
     return '%(c)s %(start)s-%(end)s by the GRASS Development Team' % {
-        'c': unichr(169), 'start': start, 'end': end}
+        'c': _unichr(169), 'start': start, 'end': end}
 
 
 
 
 def main():
 def main():