[GRASS-SVN] r74104 - in grass/trunk/gui/wxpython: gmodeler gui_core psmap

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 18 20:15:17 PST 2019


Author: annakrat
Date: 2019-02-18 20:15:17 -0800 (Mon, 18 Feb 2019)
New Revision: 74104

Modified:
   grass/trunk/gui/wxpython/gmodeler/frame.py
   grass/trunk/gui/wxpython/gui_core/wrap.py
   grass/trunk/gui/wxpython/psmap/dialogs.py
Log:
wxGUI: fix TextEntryDialog wx4 compatibility

Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py	2019-02-18 02:25:54 UTC (rev 74103)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py	2019-02-19 04:15:17 UTC (rev 74104)
@@ -49,7 +49,8 @@
 from gui_core.goutput import GConsoleWindow
 from core.debug import Debug
 from core.gcmd import GMessage, GException, GWarning, GError, RunCommand
-from gui_core.dialogs import GetImageHandlers, TextEntryDialog
+from gui_core.dialogs import GetImageHandlers
+from gui_core.dialogs import TextEntryDialog as CustomTextEntryDialog
 from gui_core.ghelp import ShowAboutDialog
 from gui_core.preferences import PreferencesBaseDialog
 from core.settings import UserSettings
@@ -65,6 +66,7 @@
 from gmodeler.dialogs import *
 from gui_core.wrap import Button, StaticText, StaticBox, TextCtrl, \
     Menu, StockCursor, EmptyBitmap
+from gui_core.wrap import TextEntryDialog as wxTextEntryDialog
 
 wxModelDone, EVT_MODEL_DONE = NewEvent()
 
@@ -882,7 +884,7 @@
 
     def OnAddComment(self, event):
         """Add comment to the model"""
-        dlg = TextEntryDialog(
+        dlg = CustomTextEntryDialog(
             parent=self,
             message=_("Comment:"),
             caption=_("Add comment"),
@@ -1609,11 +1611,11 @@
 
     def OnSetLabel(self, event):
         shape = self.GetShape()
-        dlg = wx.TextEntryDialog(
+        dlg = wxTextEntryDialog(
             parent=self.frame,
             message=_("Label:"),
             caption=_("Set label"),
-            defaultValue=shape.GetLabel())
+            value=shape.GetLabel())
         if dlg.ShowModal() == wx.ID_OK:
             label = dlg.GetValue()
             shape.SetLabel(label)
@@ -1624,7 +1626,7 @@
 
     def OnSetComment(self, event):
         shape = self.GetShape()
-        dlg = TextEntryDialog(
+        dlg = CustomTextEntryDialog(
             parent=self.frame, message=_("Comment:"),
             caption=_("Set comment"),
             defaultValue=shape.GetComment(),

Modified: grass/trunk/gui/wxpython/gui_core/wrap.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/wrap.py	2019-02-18 02:25:54 UTC (rev 74103)
+++ grass/trunk/gui/wxpython/gui_core/wrap.py	2019-02-19 04:15:17 UTC (rev 74104)
@@ -426,3 +426,16 @@
             wx.Choice.SetToolTip(self, tipString=tip)
         else:
             wx.Choice.SetToolTipString(self, tip)
+
+
+class TextEntryDialog(wx.TextEntryDialog):
+    """Wrapper around wx.TextEntryDialog to have more control
+    over the widget on different platforms/wxpython versions"""
+    def __init__(self, parent, message, caption="Please enter text", value="",
+                 style=wx.OK | wx.CANCEL | wx.CENTRE, pos=wx.DefaultPosition):
+        if wxPythonPhoenix:
+            super(TextEntryDialog, self).__init__(parent=parent, message=message, caption=caption,
+                                                  value=value, style=style, pos=pos)
+        else:
+            super(TextEntryDialog, self).__init__(parent=parent, message=message, caption=caption,
+                                                  defaultValue=value, style=style, pos=pos)

Modified: grass/trunk/gui/wxpython/psmap/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/dialogs.py	2019-02-18 02:25:54 UTC (rev 74103)
+++ grass/trunk/gui/wxpython/psmap/dialogs.py	2019-02-19 04:15:17 UTC (rev 74104)
@@ -73,7 +73,7 @@
 from core.gcmd import RunCommand, GError, GMessage
 from gui_core.dialogs import SymbolDialog
 from gui_core.wrap import SpinCtrl, Button, TextCtrl, BitmapButton, \
-    StaticText, StaticBox, Rect, EmptyBitmap
+    StaticText, StaticBox, Rect, EmptyBitmap, TextEntryDialog
 from psmap.utils import *
 from psmap.instructions import *
 
@@ -4145,11 +4145,11 @@
         if self.vectorListCtrl.GetFirstSelected() != -1:
             idx = self.vectorListCtrl.GetFirstSelected()
             default = self.vectorListCtrl.GetItem(idx, 1).GetText()
-            dlg = wx.TextEntryDialog(
+            dlg = TextEntryDialog(
                 self,
                 message=_("Edit legend label:"),
                 caption=_("Edit label"),
-                defaultValue=default,
+                value=default,
                 style=wx.OK | wx.CANCEL | wx.CENTRE)
             if dlg.ShowModal() == wx.ID_OK:
                 new = dlg.GetValue()



More information about the grass-commit mailing list