Forráskód Böngészése

wxGUI: fix TextEntryDialog wx4 compatibility

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74104 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 6 éve
szülő
commit
3431613015

+ 7 - 5
gui/wxpython/gmodeler/frame.py

@@ -49,7 +49,8 @@ from core.gconsole        import GConsole, \
 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.model import *
 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 @@ class ModelFrame(wx.Frame):
 
     def OnAddComment(self, event):
         """Add comment to the model"""
-        dlg = TextEntryDialog(
+        dlg = CustomTextEntryDialog(
             parent=self,
             message=_("Comment:"),
             caption=_("Add comment"),
@@ -1609,11 +1611,11 @@ class ModelEvtHandler(ogl.ShapeEvtHandler):
 
     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 @@ class ModelEvtHandler(ogl.ShapeEvtHandler):
 
     def OnSetComment(self, event):
         shape = self.GetShape()
-        dlg = TextEntryDialog(
+        dlg = CustomTextEntryDialog(
             parent=self.frame, message=_("Comment:"),
             caption=_("Set comment"),
             defaultValue=shape.GetComment(),

+ 13 - 0
gui/wxpython/gui_core/wrap.py

@@ -426,3 +426,16 @@ class Choice(wx.Choice):
             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)

+ 3 - 3
gui/wxpython/psmap/dialogs.py

@@ -73,7 +73,7 @@ from gui_core.gselect import Select
 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 @@ class LegendDialog(PsmapDialog):
         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()