Bläddra i källkod

wxGUI: continue making gui compatible with Phoenix

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71311 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 7 år sedan
förälder
incheckning
077c7ccafc

+ 2 - 1
gui/wxpython/datacatalog/tree.py

@@ -30,6 +30,7 @@ from gui_core.dialogs import TextEntryDialog
 from core.giface import StandaloneGrassInterface
 from core.giface import StandaloneGrassInterface
 from core.treemodel import TreeModel, DictNode
 from core.treemodel import TreeModel, DictNode
 from gui_core.treeview import TreeView
 from gui_core.treeview import TreeView
+from gui_core.wrap import Menu
 from datacatalog.dialogs import CatalogReprojectionDialog
 from datacatalog.dialogs import CatalogReprojectionDialog
 
 
 from grass.pydispatch.signal import Signal
 from grass.pydispatch.signal import Signal
@@ -941,7 +942,7 @@ class DataCatalogTree(LocationMapTree):
 
 
     def _popupMenuLayer(self):
     def _popupMenuLayer(self):
         """Create popup menu for layers"""
         """Create popup menu for layers"""
-        menu = wx.Menu()
+        menu = Menu()
         genv = gisenv()
         genv = gisenv()
         currentLocation, currentMapset = self._isCurrent(genv)
         currentLocation, currentMapset = self._isCurrent(genv)
 
 

+ 5 - 5
gui/wxpython/gui_core/dialogs.py

@@ -47,7 +47,7 @@ from gui_core.widgets import SingleSymbolPanel, GListCtrl, SimpleValidator, MapV
 from core.utils import _
 from core.utils import _
 from core.settings import UserSettings
 from core.settings import UserSettings
 from core.debug import Debug
 from core.debug import Debug
-from gui_core.wrap import SpinCtrl
+from gui_core.wrap import SpinCtrl, TextCtrl
 
 
 
 
 class SimpleDialog(wx.Dialog):
 class SimpleDialog(wx.Dialog):
@@ -1495,16 +1495,16 @@ class MapLayersDialogBase(wx.Dialog):
                       flag=wx.ALIGN_CENTER_VERTICAL,
                       flag=wx.ALIGN_CENTER_VERTICAL,
                       pos=(2, 0))
                       pos=(2, 0))
 
 
-        self.filter = wx.TextCtrl(parent=self, id=wx.ID_ANY,
-                                  value="",
-                                  size=(250, -1))
+        self.filter = TextCtrl(parent=self, id=wx.ID_ANY,
+                               value="",
+                               size=(250, -1))
         bodySizer.Add(self.filter,
         bodySizer.Add(self.filter,
                       flag=wx.EXPAND,
                       flag=wx.EXPAND,
                       pos=(2, 1), span=(1, 2))
                       pos=(2, 1), span=(1, 2))
 
 
         self.filter.SetFocus()
         self.filter.SetFocus()
         # TODO same text in GroupDialog
         # TODO same text in GroupDialog
-        self.filter.SetToolTipString(
+        self.filter.SetToolTip(
             _(
             _(
                 "Put here a regular expression."
                 "Put here a regular expression."
                 " Characters '.*' stand for anything,"
                 " Characters '.*' stand for anything,"

+ 5 - 5
gui/wxpython/gui_core/gselect.py

@@ -702,7 +702,7 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
             self.Dismiss()
             self.Dismiss()
 
 
         elif event.GetKeyCode() == wx.WXK_RETURN:
         elif event.GetKeyCode() == wx.WXK_RETURN:
-            if self.seltree.GetPyData(item)['node']:
+            if self.seltree.GetItemData(item)['node']:
                 self.value = []
                 self.value = []
             else:
             else:
                 self._selectTreeItem(item)
                 self._selectTreeItem(item)
@@ -716,7 +716,7 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
         if item and flags & wx.TREE_HITTEST_ONITEMLABEL:
         if item and flags & wx.TREE_HITTEST_ONITEMLABEL:
             self.curitem = item
             self.curitem = item
 
 
-            if self.seltree.GetPyData(item)['node']:
+            if self.seltree.GetItemData(item)['node']:
                 evt.Skip()
                 evt.Skip()
                 return
                 return
 
 
@@ -727,8 +727,8 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
 
 
     def _selectTreeItem(self, item):
     def _selectTreeItem(self, item):
         fullName = self.seltree.GetItemText(item)
         fullName = self.seltree.GetItemText(item)
-        if self.fullyQualified and self.seltree.GetPyData(item)['mapset']:
-            fullName += '@' + self.seltree.GetPyData(item)['mapset']
+        if self.fullyQualified and self.seltree.GetItemData(item)['mapset']:
+            fullName += '@' + self.seltree.GetItemData(item)['mapset']
 
 
         if self.multiple:
         if self.multiple:
             self.value.append(fullName)
             self.value.append(fullName)
@@ -743,7 +743,7 @@ class TreeCtrlComboPopup(ListCtrlComboPopup):
 
 
     def _onItemConfirmed(self, event):
     def _onItemConfirmed(self, event):
         item = event.GetItem()
         item = event.GetItem()
-        if self.seltree.GetPyData(item)['node']:
+        if self.seltree.GetItemData(item)['node']:
             self.value = []
             self.value = []
         else:
         else:
             self._selectTreeItem(item)
             self._selectTreeItem(item)

+ 1 - 1
gui/wxpython/gui_core/menu.py

@@ -217,7 +217,7 @@ class SearchModuleWindow(wx.Panel):
         sizer.Add(self._search, proportion=0,
         sizer.Add(self._search, proportion=0,
                   flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
                   flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
 
 
-        sizer.Add(item=btnSizer, proportion=0,
+        sizer.Add(btnSizer, proportion=0,
                   flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
                   flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
 
 
         sizer.Add(self._helpText,
         sizer.Add(self._helpText,

+ 2 - 2
gui/wxpython/gui_core/toolbars.py

@@ -27,7 +27,7 @@ from core.utils import _
 from icons.icon import MetaIcon
 from icons.icon import MetaIcon
 from collections import defaultdict
 from collections import defaultdict
 from core.globalvar import IMGDIR
 from core.globalvar import IMGDIR
-from gui_core.wrap import ToolBar
+from gui_core.wrap import ToolBar, Menu
 
 
 from grass.pydispatch.signal import Signal
 from grass.pydispatch.signal import Signal
 
 
@@ -246,7 +246,7 @@ class BaseToolbar(ToolBar):
 
 
     def _onMenu(self, data):
     def _onMenu(self, data):
         """Toolbar pop-up menu"""
         """Toolbar pop-up menu"""
-        menu = wx.Menu()
+        menu = Menu()
 
 
         for icon, handler in data:
         for icon, handler in data:
             item = wx.MenuItem(menu, wx.ID_ANY, icon.GetLabel())
             item = wx.MenuItem(menu, wx.ID_ANY, icon.GetLabel())

+ 3 - 3
gui/wxpython/gui_core/widgets.py

@@ -89,7 +89,7 @@ from core import globalvar
 from core.utils import _
 from core.utils import _
 from core.gcmd import GMessage, GError
 from core.gcmd import GMessage, GError
 from core.debug import Debug
 from core.debug import Debug
-from gui_core.wrap import Button
+from gui_core.wrap import Button, SearchCtrl
 
 
 
 
 class NotebookController:
 class NotebookController:
@@ -1076,11 +1076,11 @@ class SearchModuleWidget(wx.Panel):
                 parent=self, id=wx.ID_ANY, size=(-1, 25),
                 parent=self, id=wx.ID_ANY, size=(-1, 25),
                 style=wx.TE_PROCESS_ENTER)
                 style=wx.TE_PROCESS_ENTER)
         else:
         else:
-            self._search = wx.SearchCtrl(
+            self._search = SearchCtrl(
                 parent=self, id=wx.ID_ANY, size=(-1, 25),
                 parent=self, id=wx.ID_ANY, size=(-1, 25),
                 style=wx.TE_PROCESS_ENTER)
                 style=wx.TE_PROCESS_ENTER)
             self._search.SetDescriptiveText(_('Fulltext search'))
             self._search.SetDescriptiveText(_('Fulltext search'))
-            self._search.SetToolTipString(
+            self._search.SetToolTip(
                 _("Type to search in all modules. Press Enter for next match."))
                 _("Type to search in all modules. Press Enter for next match."))
 
 
         self._search.Bind(wx.EVT_TEXT, self.OnSearchModule)
         self._search.Bind(wx.EVT_TEXT, self.OnSearchModule)

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

@@ -16,6 +16,7 @@ This program is free software under the GNU General Public License
 """
 """
 
 
 import wx
 import wx
+import wx.lib.buttons as buttons
 
 
 from core.globalvar import gtk3, wxPythonPhoenix
 from core.globalvar import gtk3, wxPythonPhoenix
 if wxPythonPhoenix:
 if wxPythonPhoenix:
@@ -50,6 +51,25 @@ def StockCursor(cursorId):
         return wx.StockCursor(cursorId)
         return wx.StockCursor(cursorId)
 
 
 
 
+class Window(wx.Window):
+    """Wrapper around wx.Window to have more control
+    over the widget on different platforms/wxpython versions"""
+    def __init__(self, *args, **kwargs):
+        wx.Window.__init__(self, *args, **kwargs)
+
+    def SetToolTip(self, tip):
+        if wxPythonPhoenix:
+            if tip is None:
+                wx.Window.UnsetToolTip(self)
+            else:
+                wx.Window.SetToolTip(self, tipString=tip)
+        else:
+            if tip is None:
+                wx.Window.SetToolTip(self, tip)
+            else:
+                wx.Window.SetToolTipString(self, tip)
+
+
 class SpinCtrl(wx.SpinCtrl):
 class SpinCtrl(wx.SpinCtrl):
     """Wrapper around wx.SpinCtrl to have more control
     """Wrapper around wx.SpinCtrl to have more control
     over the widget on different platforms"""
     over the widget on different platforms"""
@@ -79,6 +99,19 @@ class Button(wx.Button):
             wx.Button.SetToolTipString(self, tip)
             wx.Button.SetToolTipString(self, tip)
 
 
 
 
+class GenBitmapButton(buttons.GenBitmapButton):
+    """Wrapper around GenBitmapButton to have more control
+    over the widget on different platforms/wxpython versions"""
+    def __init__(self, *args, **kwargs):
+        buttons.GenBitmapButton.__init__(self, *args, **kwargs)
+
+    def SetToolTip(self, tip):
+        if wxPythonPhoenix:
+            buttons.GenBitmapButton.SetToolTip(self, tipString=tip)
+        else:
+            buttons.GenBitmapButton.SetToolTipString(self, tip)
+
+
 class ToggleButton(wx.ToggleButton):
 class ToggleButton(wx.ToggleButton):
     """Wrapper around wx.ToggleButton to have more control
     """Wrapper around wx.ToggleButton to have more control
     over the widget on different platforms/wxpython versions"""
     over the widget on different platforms/wxpython versions"""
@@ -131,6 +164,19 @@ class TextCtrl(wx.TextCtrl):
             wx.TextCtrl.SetToolTipString(self, tip)
             wx.TextCtrl.SetToolTipString(self, tip)
 
 
 
 
+class SearchCtrl(wx.SearchCtrl):
+    """Wrapper around wx.SearchCtrl to have more control
+    over the widget on different platforms/wxpython versions"""
+    def __init__(self, *args, **kwargs):
+        wx.SearchCtrl.__init__(self, *args, **kwargs)
+
+    def SetToolTip(self, tip):
+        if wxPythonPhoenix:
+            wx.SearchCtrl.SetToolTip(self, tipString=tip)
+        else:
+            wx.SearchCtrl.SetToolTipString(self, tip)
+
+
 class ListCtrl(wx.ListCtrl):
 class ListCtrl(wx.ListCtrl):
     """Wrapper around wx.ListCtrl to have more control
     """Wrapper around wx.ListCtrl to have more control
     over the widget on different platforms/wxpython versions"""
     over the widget on different platforms/wxpython versions"""
@@ -162,6 +208,12 @@ class TreeCtrl(wx.TreeCtrl):
         else:
         else:
             return wx.TreeCtrl.AppendItem(self, parent, text, image, selImage, wx.TreeItemData(data))
             return wx.TreeCtrl.AppendItem(self, parent, text, image, selImage, wx.TreeItemData(data))
 
 
+    def GetItemData(self, item):
+        if wxPythonPhoenix:
+            return wx.TreeCtrl.GetItemData(self, item)
+        else:
+            return wx.TreeCtrl.GetPyData(self, item)
+
 
 
 class ToolBar(wx.ToolBar):
 class ToolBar(wx.ToolBar):
     """Wrapper around wx.ToolBar to have more control
     """Wrapper around wx.ToolBar to have more control

+ 6 - 6
gui/wxpython/lmgr/layertree.py

@@ -22,7 +22,7 @@ try:
     import wx.lib.agw.customtreectrl as CT
     import wx.lib.agw.customtreectrl as CT
 except ImportError:
 except ImportError:
     import wx.lib.customtreectrl as CT
     import wx.lib.customtreectrl as CT
-import wx.lib.buttons as buttons
+
 try:
 try:
     import treemixin
     import treemixin
 except ImportError:
 except ImportError:
@@ -47,7 +47,7 @@ from core.gcmd import GWarning, GError, RunCommand
 from icons.icon import MetaIcon
 from icons.icon import MetaIcon
 from web_services.dialogs import SaveWMSLayerDialog
 from web_services.dialogs import SaveWMSLayerDialog
 from gui_core.widgets import MapValidator
 from gui_core.widgets import MapValidator
-from gui_core.wrap import Menu
+from gui_core.wrap import Menu, GenBitmapButton
 from lmgr.giface import LayerManagerGrassInterfaceForMapDisplay
 from lmgr.giface import LayerManagerGrassInterfaceForMapDisplay
 from core.giface import Notification
 from core.giface import Notification
 
 
@@ -1349,9 +1349,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
             self.groupnode += 1
             self.groupnode += 1
         else:
         else:
             btnbmp = LMIcons["layerOptions"].GetBitmap((16, 16))
             btnbmp = LMIcons["layerOptions"].GetBitmap((16, 16))
-            ctrl = buttons.GenBitmapButton(
+            ctrl = GenBitmapButton(
                 self, id=wx.ID_ANY, bitmap=btnbmp, size=(24, 24))
                 self, id=wx.ID_ANY, bitmap=btnbmp, size=(24, 24))
-            ctrl.SetToolTipString(_("Click to edit layer settings"))
+            ctrl.SetToolTip(_("Click to edit layer settings"))
             self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenuButton, ctrl)
             self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenuButton, ctrl)
         # add layer to the layer tree
         # add layer to the layer tree
         if loadWorkspace:
         if loadWorkspace:
@@ -1898,9 +1898,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         elif self.GetLayerInfo(dragItem, key='ctrl'):
         elif self.GetLayerInfo(dragItem, key='ctrl'):
             # recreate data layer
             # recreate data layer
             btnbmp = LMIcons["layerOptions"].GetBitmap((16, 16))
             btnbmp = LMIcons["layerOptions"].GetBitmap((16, 16))
-            newctrl = buttons.GenBitmapButton(
+            newctrl = GenBitmapButton(
                 self, id=wx.ID_ANY, bitmap=btnbmp, size=(24, 24))
                 self, id=wx.ID_ANY, bitmap=btnbmp, size=(24, 24))
-            newctrl.SetToolTipString(_("Click to edit layer settings"))
+            newctrl.SetToolTip(_("Click to edit layer settings"))
             self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenuButton, newctrl)
             self.Bind(wx.EVT_BUTTON, self.OnLayerContextMenuButton, newctrl)
             data = self.GetPyData(dragItem)
             data = self.GetPyData(dragItem)
 
 

+ 11 - 11
gui/wxpython/location_wizard/wizard.py

@@ -53,7 +53,7 @@ from core import utils
 from core.utils import _
 from core.utils import _
 from core.gcmd import RunCommand, GError, GMessage, GWarning
 from core.gcmd import RunCommand, GError, GMessage, GWarning
 from gui_core.widgets import GenericValidator
 from gui_core.widgets import GenericValidator
-from gui_core.wrap import SpinCtrl
+from gui_core.wrap import SpinCtrl, SearchCtrl
 from location_wizard.base import BaseClass
 from location_wizard.base import BaseClass
 from location_wizard.dialogs import SelectTransformDialog
 from location_wizard.dialogs import SelectTransformDialog
 
 
@@ -475,8 +475,8 @@ class ProjectionsPage(TitledPage):
         self.tproj = self.MakeTextCtrl("", size=(200, -1))
         self.tproj = self.MakeTextCtrl("", size=(200, -1))
 
 
         # search box
         # search box
-        self.searchb = wx.SearchCtrl(self, size=(200, -1),
-                                     style=wx.TE_PROCESS_ENTER)
+        self.searchb = SearchCtrl(self, size=(200, -1),
+                                  style=wx.TE_PROCESS_ENTER)
 
 
         # projection list
         # projection list
         self.projlist = ItemList(self, data=self.parent.projdesc.items(),
         self.projlist = ItemList(self, data=self.parent.projdesc.items(),
@@ -997,8 +997,8 @@ class DatumPage(TitledPage):
         self.tdatum = self.MakeTextCtrl("", size=(200, -1))
         self.tdatum = self.MakeTextCtrl("", size=(200, -1))
 
 
         # search box
         # search box
-        self.searchb = wx.SearchCtrl(self, size=(200, -1),
-                                     style=wx.TE_PROCESS_ENTER)
+        self.searchb = SearchCtrl(self, size=(200, -1),
+                                  style=wx.TE_PROCESS_ENTER)
 
 
         # create list control for datum/elipsoid list
         # create list control for datum/elipsoid list
         data = []
         data = []
@@ -1172,8 +1172,8 @@ class EllipsePage(TitledPage):
         self.tellipse = self.MakeTextCtrl("", size=(200, -1))
         self.tellipse = self.MakeTextCtrl("", size=(200, -1))
 
 
         # search box
         # search box
-        self.searchb = wx.SearchCtrl(self, size=(200, -1),
-                                     style=wx.TE_PROCESS_ENTER)
+        self.searchb = SearchCtrl(self, size=(200, -1),
+                                  style=wx.TE_PROCESS_ENTER)
         # radio buttons
         # radio buttons
         self.radio1 = wx.RadioButton(parent=self, id=wx.ID_ANY,
         self.radio1 = wx.RadioButton(parent=self, id=wx.ID_ANY,
                                      label=_("Earth based"),
                                      label=_("Earth based"),
@@ -1511,8 +1511,8 @@ class EPSGPage(TitledPage):
         self.bbrowse = self.MakeButton(_("Browse"))
         self.bbrowse = self.MakeButton(_("Browse"))
 
 
         # search box
         # search box
-        self.searchb = wx.SearchCtrl(self, size=(200, -1),
-                                     style=wx.TE_PROCESS_ENTER)
+        self.searchb = SearchCtrl(self, size=(200, -1),
+                                  style=wx.TE_PROCESS_ENTER)
 
 
         self.epsglist = ItemList(
         self.epsglist = ItemList(
             self,
             self,
@@ -1739,8 +1739,8 @@ class IAUPage(TitledPage):
         self.bbrowse = self.MakeButton(_("Browse"))
         self.bbrowse = self.MakeButton(_("Browse"))
 
 
         # search box
         # search box
-        self.searchb = wx.SearchCtrl(self, size=(200, -1),
-                                     style=wx.TE_PROCESS_ENTER)
+        self.searchb = SearchCtrl(self, size=(200, -1),
+                                  style=wx.TE_PROCESS_ENTER)
 
 
         self.epsglist = ItemList(
         self.epsglist = ItemList(
             self,
             self,

+ 4 - 4
gui/wxpython/mapwin/buffered.py

@@ -35,7 +35,7 @@ from core.globalvar import wxPythonPhoenix
 import grass.script as grass
 import grass.script as grass
 
 
 from gui_core.dialogs import SavedRegion
 from gui_core.dialogs import SavedRegion
-from gui_core.wrap import DragImage, PseudoDC, EmptyBitmap, BitmapFromImage
+from gui_core.wrap import DragImage, PseudoDC, EmptyBitmap, BitmapFromImage, Window
 from core.gcmd import RunCommand, GException, GError, GMessage
 from core.gcmd import RunCommand, GException, GError, GMessage
 from core.debug import Debug
 from core.debug import Debug
 from core.settings import UserSettings
 from core.settings import UserSettings
@@ -52,7 +52,7 @@ except ImportError:
     haveCtypes = False
     haveCtypes = False
 
 
 
 
-class BufferedMapWindow(MapWindowBase, wx.Window):
+class BufferedMapWindow(MapWindowBase, Window):
     """A Buffered window class (2D view mode)
     """A Buffered window class (2D view mode)
 
 
     Superclass for VDigitWindow (vector digitizer).
     Superclass for VDigitWindow (vector digitizer).
@@ -1695,8 +1695,8 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
         pos = event.GetPosition()
         pos = event.GetPosition()
         idlist = self.pdc.FindObjects(pos[0], pos[1], self.hitradius)
         idlist = self.pdc.FindObjects(pos[0], pos[1], self.hitradius)
         if self.overlays and idlist and [i for i in idlist if i in self.overlays.keys()]:  # legend, scale bar, north arrow, dtext
         if self.overlays and idlist and [i for i in idlist if i in self.overlays.keys()]:  # legend, scale bar, north arrow, dtext
-            self.SetToolTipString("Double click in Pointer mode to set object"
-                                  " properties,\nright click to remove")
+            self.SetToolTip("Double click in Pointer mode to set object"
+                            " properties,\nright click to remove")
         else:
         else:
             self.SetToolTip(None)
             self.SetToolTip(None)
         event.Skip()
         event.Skip()