소스 검색

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

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

@@ -43,6 +43,7 @@ from core.debug import Debug
 from core.utils import _
 from dbmgr.base import DbMgrBase
 from gui_core.widgets import GNotebook
+from gui_core.wrap import Button
 
 
 class AttributeManager(wx.Frame, DbMgrBase):
@@ -136,13 +137,13 @@ class AttributeManager(wx.Frame, DbMgrBase):
             wx.CallAfter(self.notebook.SetSelection, 0)  # select browse tab
 
         # 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"))
-        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)"))
 
         # events

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

@@ -306,3 +306,16 @@ class Rect(wx.Rect):
             return wx.Rect.Contains(self, rect=rect)
         else:
             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)