ソースを参照

wxGUI: patch by sanjeet to fix warnings when using attribute manager with wxpython 4 - https://trac.osgeo.org/grass/ticket/3510

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72331 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 7 年 前
コミット
8356131b0d
3 ファイル変更41 行追加27 行削除
  1. 21 21
      gui/wxpython/dbmgr/base.py
  2. 7 6
      gui/wxpython/dbmgr/manager.py
  3. 13 0
      gui/wxpython/gui_core/wrap.py

+ 21 - 21
gui/wxpython/dbmgr/base.py

@@ -60,7 +60,7 @@ from dbmgr.vinfo import VectorDBInfo, GetUnicodeValue, CreateDbInfoDesc
 from core.debug import Debug
 from core.debug import Debug
 from dbmgr.dialogs import ModifyTableRecord, AddColumnDialog
 from dbmgr.dialogs import ModifyTableRecord, AddColumnDialog
 from core.settings import UserSettings
 from core.settings import UserSettings
-from gui_core.wrap import SpinCtrl
+from gui_core.wrap import SpinCtrl, Button, TextCtrl, ListCtrl, CheckBox
 
 
 
 
 class Log:
 class Log:
@@ -1182,11 +1182,11 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
         sqlNtb.AddPage(page=simpleSqlPanel,
         sqlNtb.AddPage(page=simpleSqlPanel,
                        text=_('Simple'))
                        text=_('Simple'))
 
 
-        btnApply = wx.Button(
+        btnApply = Button(
             parent=simpleSqlPanel,
             parent=simpleSqlPanel,
             id=wx.ID_APPLY,
             id=wx.ID_APPLY,
             name='btnApply')
             name='btnApply')
-        btnApply.SetToolTipString(
+        btnApply.SetToolTip(
             _("Apply SELECT statement and reload data records"))
             _("Apply SELECT statement and reload data records"))
         btnApply.Bind(wx.EVT_BUTTON, self.OnApplySqlStatement)
         btnApply.Bind(wx.EVT_BUTTON, self.OnApplySqlStatement)
 
 
@@ -1204,12 +1204,12 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
                                  size=(55, -1),
                                  size=(55, -1),
                                  choices=['=', '!=', '<', '<=', '>', '>='])
                                  choices=['=', '!=', '<', '<=', '>', '>='])
         sqlWhereCond.SetSelection(0)
         sqlWhereCond.SetSelection(0)
-        sqlWhereValue = wx.TextCtrl(
+        sqlWhereValue = TextCtrl(
             parent=whereSimpleSqlPanel,
             parent=whereSimpleSqlPanel,
             id=wx.ID_ANY,
             id=wx.ID_ANY,
             value="",
             value="",
             style=wx.TE_PROCESS_ENTER)
             style=wx.TE_PROCESS_ENTER)
-        sqlWhereValue.SetToolTipString(
+        sqlWhereValue.SetToolTip(
             _("Example: %s") %
             _("Example: %s") %
             "MULTILANE = 'no' AND OBJECTID < 10")
             "MULTILANE = 'no' AND OBJECTID < 10")
 
 
@@ -1229,13 +1229,13 @@ class DbMgrBrowsePage(DbMgrNotebookBase):
             label=_("SQL Builder"))
             label=_("SQL Builder"))
         btnSqlBuilder.Bind(wx.EVT_BUTTON, self.OnBuilder)
         btnSqlBuilder.Bind(wx.EVT_BUTTON, self.OnBuilder)
 
 
-        sqlStatement = wx.TextCtrl(
+        sqlStatement = TextCtrl(
             parent=advancedSqlPanel,
             parent=advancedSqlPanel,
             id=wx.ID_ANY,
             id=wx.ID_ANY,
             value="SELECT * FROM %s" %
             value="SELECT * FROM %s" %
             self.dbMgrData['mapDBInfo'].layers[layer]['table'],
             self.dbMgrData['mapDBInfo'].layers[layer]['table'],
             style=wx.TE_PROCESS_ENTER)
             style=wx.TE_PROCESS_ENTER)
-        sqlStatement.SetToolTipString(
+        sqlStatement.SetToolTip(
             _("Example: %s") %
             _("Example: %s") %
             "SELECT * FROM roadsmajor WHERE MULTILANE = 'no' AND OBJECTID < 10")
             "SELECT * FROM roadsmajor WHERE MULTILANE = 'no' AND OBJECTID < 10")
         sqlWhereValue.Bind(wx.EVT_TEXT_ENTER, self.OnApplySqlStatement)
         sqlWhereValue.Bind(wx.EVT_TEXT_ENTER, self.OnApplySqlStatement)
@@ -2865,7 +2865,7 @@ class DbMgrLayersPage(wx.Panel):
         pass
         pass
 
 
 
 
-class TableListCtrl(wx.ListCtrl,
+class TableListCtrl(ListCtrl,
                     listmix.ListCtrlAutoWidthMixin):
                     listmix.ListCtrlAutoWidthMixin):
     #                    listmix.TextEditMixin):
     #                    listmix.TextEditMixin):
     """Table description list"""
     """Table description list"""
@@ -2876,9 +2876,9 @@ class TableListCtrl(wx.ListCtrl,
         self.parent = parent
         self.parent = parent
         self.table = table
         self.table = table
         self.columns = columns
         self.columns = columns
-        wx.ListCtrl.__init__(self, parent, id, pos, size,
-                             style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES |
-                             wx.BORDER_NONE)
+        ListCtrl.__init__(self, parent, id, pos, size,
+                          style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES |
+                          wx.BORDER_NONE)
 
 
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         # listmix.TextEditMixin.__init__(self)
         # listmix.TextEditMixin.__init__(self)
@@ -2920,7 +2920,7 @@ class TableListCtrl(wx.ListCtrl,
         return itemData
         return itemData
 
 
 
 
-class LayerListCtrl(wx.ListCtrl,
+class LayerListCtrl(ListCtrl,
                     listmix.ListCtrlAutoWidthMixin):
                     listmix.ListCtrlAutoWidthMixin):
                     # listmix.ColumnSorterMixin):
                     # listmix.ColumnSorterMixin):
                     # listmix.TextEditMixin):
                     # listmix.TextEditMixin):
@@ -2932,9 +2932,9 @@ class LayerListCtrl(wx.ListCtrl,
 
 
         self.parent = parent
         self.parent = parent
         self.layers = layers
         self.layers = layers
-        wx.ListCtrl.__init__(self, parent, id, pos, size,
-                             style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES |
-                             wx.BORDER_NONE)
+        ListCtrl.__init__(self, parent, id, pos, size,
+                          style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES |
+                          wx.BORDER_NONE)
 
 
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         listmix.ListCtrlAutoWidthMixin.__init__(self)
         # listmix.TextEditMixin.__init__(self)
         # listmix.TextEditMixin.__init__(self)
@@ -3096,8 +3096,8 @@ class LayerBook(wx.Notebook):
                                      wx.Choice(parent=self.addPanel, id=wx.ID_ANY, size=(200, -1),
                                      wx.Choice(parent=self.addPanel, id=wx.ID_ANY, size=(200, -1),
                                                choices=self.defaultColumns)),
                                                choices=self.defaultColumns)),
                                 'addCat':
                                 'addCat':
-                                    (wx.CheckBox(parent=self.addPanel, id=wx.ID_ANY,
-                                                 label=_("Insert record for each category into table")),
+                                    (CheckBox(parent=self.addPanel, id=wx.ID_ANY,
+                                              label=_("Insert record for each category into table")),
                                      None),
                                      None),
                                 }
                                 }
 
 
@@ -3118,7 +3118,7 @@ class LayerBook(wx.Notebook):
             wx.EVT_CHOICE, self.OnTableChanged)
             wx.EVT_CHOICE, self.OnTableChanged)
 
 
         # tooltips
         # tooltips
-        self.addLayerWidgets['addCat'][0].SetToolTipString(
+        self.addLayerWidgets['addCat'][0].SetToolTip(
             _("You need to add categories " "by v.category module."))
             _("You need to add categories " "by v.category module."))
 
 
         # table description
         # table description
@@ -3275,7 +3275,7 @@ class LayerBook(wx.Notebook):
         except ValueError:
         except ValueError:
             tableName = ''
             tableName = ''
 
 
-        self.deleteTable = wx.CheckBox(
+        self.deleteTable = CheckBox(
             parent=self.deletePanel,
             parent=self.deletePanel,
             id=wx.ID_ANY,
             id=wx.ID_ANY,
             label=_('Drop also linked attribute table (%s)') %
             label=_('Drop also linked attribute table (%s)') %
@@ -3787,8 +3787,8 @@ class FieldStatistics(wx.Frame):
         self.text.SetBackgroundColour("white")
         self.text.SetBackgroundColour("white")
 
 
         # buttons
         # buttons
-        self.btnClipboard = wx.Button(parent=self.panel, id=wx.ID_COPY)
-        self.btnClipboard.SetToolTipString(
+        self.btnClipboard = Button(parent=self.panel, id=wx.ID_COPY)
+        self.btnClipboard.SetToolTip(
             _("Copy statistics the clipboard (Ctrl+C)"))
             _("Copy statistics the clipboard (Ctrl+C)"))
         self.btnCancel = wx.Button(parent=self.panel, id=wx.ID_CLOSE)
         self.btnCancel = wx.Button(parent=self.panel, id=wx.ID_CLOSE)
         self.btnCancel.SetDefault()
         self.btnCancel.SetDefault()

+ 7 - 6
gui/wxpython/dbmgr/manager.py

@@ -43,6 +43,7 @@ from core.debug import Debug
 from core.utils import _
 from core.utils import _
 from dbmgr.base import DbMgrBase
 from dbmgr.base import DbMgrBase
 from gui_core.widgets import GNotebook
 from gui_core.widgets import GNotebook
+from gui_core.wrap import Button
 
 
 
 
 class AttributeManager(wx.Frame, DbMgrBase):
 class AttributeManager(wx.Frame, DbMgrBase):
@@ -136,13 +137,13 @@ class AttributeManager(wx.Frame, DbMgrBase):
             wx.CallAfter(self.notebook.SetSelection, 0)  # select browse tab
             wx.CallAfter(self.notebook.SetSelection, 0)  # select browse tab
 
 
         # buttons
         # buttons
-        self.btnClose = wx.Button(parent=self.panel, id=wx.ID_CLOSE)
-        self.btnClose.SetToolTipString(_("Close Attribute Table Manager"))
-        self.btnReload = wx.Button(parent=self.panel, id=wx.ID_REFRESH)
-        self.btnReload.SetToolTipString(
+        self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE)
+        self.btnClose.SetToolTip(_("Close Attribute Table Manager"))
+        self.btnReload = Button(parent=self.panel, id=wx.ID_REFRESH)
+        self.btnReload.SetToolTip(
             _("Reload currently selected attribute data"))
             _("Reload currently selected attribute data"))
-        self.btnReset = wx.Button(parent=self.panel, id=wx.ID_CLEAR)
-        self.btnReset.SetToolTipString(
+        self.btnReset = Button(parent=self.panel, id=wx.ID_CLEAR)
+        self.btnReset.SetToolTip(
             _("Reload all attribute data (drop current selection)"))
             _("Reload all attribute data (drop current selection)"))
 
 
         # events
         # events

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

@@ -306,3 +306,16 @@ class Rect(wx.Rect):
             return wx.Rect.Contains(self, rect=rect)
             return wx.Rect.Contains(self, rect=rect)
         else:
         else:
             return wx.Rect.ContainsRect(self, rect)
             return wx.Rect.ContainsRect(self, rect)
+
+
+class CheckBox(wx.CheckBox):
+    """Wrapper around wx.CheckBox to have more control
+    over the widget on different platforms/wxpython versions"""
+    def __init__(self, *args, **kwargs):
+        wx.CheckBox.__init__(self, *args, **kwargs)
+
+    def SetToolTip(self, tip):
+        if wxPythonPhoenix:
+            wx.CheckBox.SetToolTip(self, tipString=tip)
+        else:
+            wx.CheckBox.SetToolTipString(self, tip)