[GRASS-SVN] r74105 - in grass/trunk/gui/wxpython: core lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Feb 18 20:24:36 PST 2019
Author: annakrat
Date: 2019-02-18 20:24:36 -0800 (Mon, 18 Feb 2019)
New Revision: 74105
Modified:
grass/trunk/gui/wxpython/core/workspace.py
grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI: write workspace in Python 3, see #3755
Modified: grass/trunk/gui/wxpython/core/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/core/workspace.py 2019-02-19 04:15:17 UTC (rev 74104)
+++ grass/trunk/gui/wxpython/core/workspace.py 2019-02-19 04:24:36 UTC (rev 74105)
@@ -20,6 +20,10 @@
import wx
import six
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
from core.utils import normalize_whitespace, _
from core.settings import UserSettings
@@ -820,6 +824,8 @@
"""Generic class for writing workspace file"""
def __init__(self, lmgr, file):
+ self.outfile = file
+ file = StringIO()
self.file = file
self.lmgr = lmgr
self.indent = 0
@@ -892,7 +898,7 @@
'extent="%f,%f,%f,%f,%f,%f" '
'tbres="%f" ' # needed only for animation tool
'viewMode="%s" >\n' % (' ' * self.indent,
- dispName.encode('utf8'),
+ dispName,
int(mapdisp.mapWindowProperties.autoRender),
mapdisp.statusbarManager.GetMode(),
int(mapdisp.mapWindowProperties.showRegion),
@@ -952,6 +958,9 @@
self.indent = - 4
file.write('%s</gxw>\n' % (' ' * self.indent))
+ self.outfile.write(EncodeString(file.getvalue()))
+ file.close()
+
def __filterValue(self, value):
"""Make value XML-valid"""
value = value.replace('<', '<')
@@ -978,13 +987,13 @@
string=True)
self.file.write(
'%s<layer type="%s" name="%s" checked="%d">\n' %
- (' ' * self.indent, type, EncodeString(cmd), checked))
+ (' ' * self.indent, type, cmd, checked))
self.file.write('%s</layer>\n' % (' ' * self.indent))
elif type == 'group':
name = mapTree.GetItemText(item)
self.file.write(
'%s<group name="%s" checked="%d">\n' %
- (' ' * self.indent, EncodeString(name), checked))
+ (' ' * self.indent, name, checked))
self.indent += 4
subItem = mapTree.GetFirstChild(item)[0]
self.__writeLayer(mapTree, subItem)
@@ -1001,7 +1010,7 @@
name = name.split('(', -1)[0].strip()
self.file.write(
'%s<layer type="%s" name="%s" checked="%d" opacity="%f">\n' %
- (' ' * self.indent, type, EncodeString(name), checked, opacity))
+ (' ' * self.indent, type, name, checked, opacity))
self.indent += 4
# selected ?
@@ -1026,7 +1035,7 @@
self.indent += 4
self.file.write(
'%s<value>%s</value>\n' %
- (' ' * self.indent, EncodeString(self.__filterValue(val))))
+ (' ' * self.indent, self.__filterValue(val)))
self.indent -= 4
self.file.write(
'%s</parameter>\n' %
@@ -1609,7 +1618,7 @@
else:
self.file.write('%s<parameter name="%s">\n' % (' ' * self.indent, prm.split("=", 1)[0]))
self.indent += 4
- self.file.write('%s<value>%s</value>\n' % (' ' * self.indent, EncodeString(prm.split("=", 1)[1])))
+ self.file.write('%s<value>%s</value>\n' % (' ' * self.indent, prm.split("=", 1)[1]))
self.indent -= 4
self.file.write('%s</parameter>\n' % (' ' * self.indent))
self.indent -= 4
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2019-02-19 04:15:17 UTC (rev 74104)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2019-02-19 04:24:36 UTC (rev 74105)
@@ -65,7 +65,7 @@
from lmgr.giface import LayerManagerGrassInterface
from datacatalog.catalog import DataCatalog
from gui_core.forms import GUI
-from gui_core.wrap import Menu
+from gui_core.wrap import Menu, TextEntryDialog
class GMFrame(wx.Frame):
@@ -1707,7 +1707,7 @@
return False
try:
- mfile = open(filename, "w")
+ mfile = open(filename, "wb")
tmpfile.seek(0)
for line in tmpfile.readlines():
mfile.write(line)
@@ -1757,10 +1757,10 @@
def OnRenameDisplay(self, event):
"""Change Map Display name"""
name = self.notebookLayers.GetPageText(self.currentPageNum)
- dlg = wx.TextEntryDialog(
+ dlg = TextEntryDialog(
self, message=_("Enter new name:"),
caption=_("Rename Map Display"),
- defaultValue=name)
+ value=name)
if dlg.ShowModal() == wx.ID_OK:
name = dlg.GetValue()
self.notebookLayers.SetPageText(
More information about the grass-commit
mailing list