Skip to content

Commit

Permalink
wxGUI: fix deprecated wx.NewId
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa authored and neteler committed Oct 14, 2019
1 parent 9175ae3 commit 2f5c06a
Show file tree
Hide file tree
Showing 36 changed files with 172 additions and 182 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/animation/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, frame, sliders, animations, mapwindows,
self.temporalMode = None
self.animationData = []

self.timer = wx.Timer(self, id=wx.NewId())
self.timer = wx.Timer(self, id=wx.ID_ANY)

self.animations = animations
self.bitmapPool = bitmapPool
Expand Down
5 changes: 2 additions & 3 deletions gui/wxpython/datacatalog/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def __init__(self, parent):
BaseToolbar.__init__(self, parent)

self.InitToolbar(self._toolbarData())
self.filterId = wx.NewId()
self.filter = TextCtrl(parent=self, id=self.filterId)
self.filter = TextCtrl(parent=self)
self.filter.SetSize((120, self.filter.GetBestSize()[1]))
self.filter.Bind(wx.EVT_TEXT,
lambda event: self.parent.Filter(
Expand All @@ -57,7 +56,7 @@ def __init__(self, parent):
"Use prefix 'r:', 'v:' and 'r3:'"
"to show only raster, vector or 3D raster data, respectively. "
"Use Python regular expressions to refine your search.")
self.SetToolShortHelp(self.filterId, help)
self.SetToolShortHelp(self.filter.GetId(), help)
# realize the toolbar
self.Realize()

Expand Down
26 changes: 13 additions & 13 deletions gui/wxpython/datacatalog/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,32 +991,32 @@ def _popupMenuLayer(self):
genv = gisenv()
currentLocation, currentMapset = self._isCurrent(genv)

item = wx.MenuItem(menu, wx.NewId(), _("&Cut"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Cut"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnMoveMap, item)
if not currentMapset:
item.Enable(False)

item = wx.MenuItem(menu, wx.NewId(), _("&Copy"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Copy"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnCopyMap, item)

item = wx.MenuItem(menu, wx.NewId(), _("Copy &name"))
item = wx.MenuItem(menu, wx.ID_ANY, _("Copy &name"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnCopyName, item)

item = wx.MenuItem(menu, wx.NewId(), _("&Paste"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Paste"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnPasteMap, item)
if not(currentMapset and self.copy_layer):
item.Enable(False)

item = wx.MenuItem(menu, wx.NewId(), _("&Delete"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Delete"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnDeleteMap, item)
item.Enable(currentMapset)

item = wx.MenuItem(menu, wx.NewId(), _("&Rename"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Rename"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnRenameMap, item)
item.Enable(currentMapset and len(self.selected_layer) == 1)
Expand All @@ -1026,13 +1026,13 @@ def _popupMenuLayer(self):
if not isinstance(self._giface, StandaloneGrassInterface):
if all([each.label == genv['LOCATION_NAME'] for each in self.selected_location]):
if len(self.selected_layer) > 1:
item = wx.MenuItem(menu, wx.NewId(), _("&Display layers"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Display layers"))
else:
item = wx.MenuItem(menu, wx.NewId(), _("&Display layer"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Display layer"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnDisplayLayer, item)

item = wx.MenuItem(menu, wx.NewId(), _("Show &metadata"))
item = wx.MenuItem(menu, wx.ID_ANY, _("Show &metadata"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnMetadata, item)

Expand All @@ -1045,13 +1045,13 @@ def _popupMenuMapset(self):
genv = gisenv()
currentLocation, currentMapset = self._isCurrent(genv)

item = wx.MenuItem(menu, wx.NewId(), _("&Paste"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Paste"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnPasteMap, item)
if not(currentMapset and self.copy_layer):
item.Enable(False)

item = wx.MenuItem(menu, wx.NewId(), _("&Switch mapset"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Switch mapset"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnSwitchLocationMapset, item)
if (self.selected_location[0].label == genv['LOCATION_NAME']
Expand All @@ -1063,7 +1063,7 @@ def _popupMenuMapset(self):
def _popupMenuElement(self):
"""Create popup menu for elements"""
menu = Menu()
item = wx.MenuItem(menu, wx.NewId(), _("&Paste"))
item = wx.MenuItem(menu, wx.ID_ANY, _("&Paste"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnPasteMap, item)
genv = gisenv()
Expand All @@ -1077,7 +1077,7 @@ def _popupMenuElement(self):
def _popupMenuEmpty(self):
"""Create empty popup when multiple different types of items are selected"""
menu = Menu()
item = wx.MenuItem(menu, wx.NewId(), _("No available options"))
item = wx.MenuItem(menu, wx.ID_ANY, _("No available options"))
menu.AppendItem(item)
item.Enable(False)
self.PopupMenu(menu)
Expand Down
60 changes: 30 additions & 30 deletions gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
from dbmgr.dialogs import ModifyTableRecord, AddColumnDialog
from core.settings import UserSettings
from gui_core.wrap import SpinCtrl, Button, TextCtrl, ListCtrl, CheckBox, \
StaticText, StaticBox, Menu
StaticText, StaticBox, Menu, NewId
from core.utils import cmp

if sys.version_info.major >= 3:
Expand Down Expand Up @@ -441,20 +441,20 @@ def OnColumnMenu(self, event):
popupMenu = Menu()

if not hasattr(self, "popupID"):
self.popupId = {'sortAsc': wx.NewId(),
'sortDesc': wx.NewId(),
'calculate': wx.NewId(),
'area': wx.NewId(),
'length': wx.NewId(),
'compact': wx.NewId(),
'fractal': wx.NewId(),
'perimeter': wx.NewId(),
'ncats': wx.NewId(),
'slope': wx.NewId(),
'lsin': wx.NewId(),
'lazimuth': wx.NewId(),
'calculator': wx.NewId(),
'stats': wx.NewId()}
self.popupId = {'sortAsc': NewId(),
'sortDesc': NewId(),
'calculate': NewId(),
'area': NewId(),
'length': NewId(),
'compact': NewId(),
'fractal': NewId(),
'perimeter': NewId(),
'ncats': NewId(),
'slope': NewId(),
'lsin': NewId(),
'lazimuth': NewId(),
'calculator': NewId(),
'stats': NewId()}

popupMenu.Append(self.popupId['sortAsc'], text=_("Sort ascending"))
popupMenu.Append(self.popupId['sortDesc'], text=_("Sort descending"))
Expand All @@ -470,7 +470,7 @@ def OnColumnMenu(self, event):

if not self.pages['manageTable']:
popupMenu.AppendSeparator()
self.popupId['addCol'] = wx.NewId()
self.popupId['addCol'] = NewId()
popupMenu.Append(self.popupId['addCol'], text=_("Add column"))
if not self.dbMgrData['editable']:
popupMenu.Enable(self.popupId['addCol'], False)
Expand Down Expand Up @@ -1373,17 +1373,17 @@ def OnDataItemActivated(self, event):
def OnDataRightUp(self, event):
"""Table description area, context menu"""
if not hasattr(self, "popupDataID1"):
self.popupDataID1 = wx.NewId()
self.popupDataID2 = wx.NewId()
self.popupDataID3 = wx.NewId()
self.popupDataID4 = wx.NewId()
self.popupDataID5 = wx.NewId()
self.popupDataID6 = wx.NewId()
self.popupDataID7 = wx.NewId()
self.popupDataID8 = wx.NewId()
self.popupDataID9 = wx.NewId()
self.popupDataID10 = wx.NewId()
self.popupDataID11 = wx.NewId()
self.popupDataID1 = NewId()
self.popupDataID2 = NewId()
self.popupDataID3 = NewId()
self.popupDataID4 = NewId()
self.popupDataID5 = NewId()
self.popupDataID6 = NewId()
self.popupDataID7 = NewId()
self.popupDataID8 = NewId()
self.popupDataID9 = NewId()
self.popupDataID10 = NewId()
self.popupDataID11 = NewId()

self.Bind(wx.EVT_MENU, self.OnDataItemEdit, id=self.popupDataID1)
self.Bind(wx.EVT_MENU, self.OnDataItemAdd, id=self.popupDataID2)
Expand Down Expand Up @@ -2576,9 +2576,9 @@ def OnTableItemChange(self, event):
def OnTableRightUp(self, event):
"""Table description area, context menu"""
if not hasattr(self, "popupTableID"):
self.popupTableID1 = wx.NewId()
self.popupTableID2 = wx.NewId()
self.popupTableID3 = wx.NewId()
self.popupTableID1 = NewId()
self.popupTableID2 = NewId()
self.popupTableID3 = NewId()
self.Bind(
wx.EVT_MENU,
self.OnTableItemDelete,
Expand Down
5 changes: 2 additions & 3 deletions gui/wxpython/gcp/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ def __init__(self, parent, toolSwitcher):
self._default = self.gcpset

# add tool to toggle active map window
self.togglemapid = wx.NewId()
self.togglemap = wx.Choice(parent=self, id=self.togglemapid,
self.togglemap = wx.Choice(parent=self, id=wx.ID_ANY,
choices=[_('source'), _('target')])

self.InsertControl(10, self.togglemap)

self.SetToolShortHelp(
self.togglemapid, '%s %s %s' %
self.togglemap.GetId(), '%s %s %s' %
(_('Set map canvas for '),
BaseIcons["zoomBack"].GetLabel(),
_(' / Zoom to map')))
Expand Down
12 changes: 6 additions & 6 deletions gui/wxpython/gmodeler/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from gmodeler.model import *
from lmgr.menudata import LayerManagerMenuData
from gui_core.wrap import Button, StaticText, StaticBox, TextCtrl, \
Menu, ListCtrl
Menu, ListCtrl, NewId

from grass.script import task as gtask

Expand Down Expand Up @@ -836,9 +836,9 @@ def OnReload(self, event):
def OnRightUp(self, event):
"""Mouse right button up"""
if not hasattr(self, "popupID1"):
self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
self.popupID3 = wx.NewId()
self.popupID1 = NewId()
self.popupID2 = NewId()
self.popupID3 = NewId()
self.Bind(wx.EVT_MENU, self.OnRemove, id=self.popupID1)
self.Bind(wx.EVT_MENU, self.OnRemoveAll, id=self.popupID2)
self.Bind(wx.EVT_MENU, self.OnReload, id=self.popupID3)
Expand Down Expand Up @@ -1007,8 +1007,8 @@ def OnRightUp(self, event):

if not hasattr(self, "popupId"):
self.popupID = dict()
self.popupID['remove'] = wx.NewId()
self.popupID['reload'] = wx.NewId()
self.popupID['remove'] = NewId()
self.popupID['reload'] = NewId()
self.Bind(wx.EVT_MENU, self.OnRemove, id=self.popupID['remove'])
self.Bind(wx.EVT_MENU, self.OnReload, id=self.popupID['reload'])

Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gmodeler/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from gmodeler.model import *
from gmodeler.dialogs import *
from gui_core.wrap import Button, StaticText, StaticBox, TextCtrl, \
Menu, StockCursor, EmptyBitmap
Menu, StockCursor, EmptyBitmap, NewId
from gui_core.wrap import TextEntryDialog as wxTextEntryDialog

wxModelDone, EVT_MODEL_DONE = NewEvent()
Expand Down Expand Up @@ -1489,7 +1489,7 @@ def OnRightClick(self, x, y, keys=0, attachment=0):
for key in ('remove', 'enable', 'addPoint',
'delPoint', 'intermediate', 'display', 'props', 'id',
'label', 'comment'):
self.popupID[key] = wx.NewId()
self.popupID[key] = NewId()

# record coordinates
self.x = x
Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/gui_core/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from core.settings import UserSettings
from core.debug import Debug
from gui_core.wrap import SpinCtrl, TextCtrl, Button, CheckListBox, \
StaticText, StaticBox, Menu
StaticText, StaticBox, Menu, NewId


class SimpleDialog(wx.Dialog):
Expand Down Expand Up @@ -1571,9 +1571,9 @@ def OnChangeParams(self, event):
def OnMenu(self, event):
"""Table description area, context menu"""
if not hasattr(self, "popupID1"):
self.popupDataID1 = wx.NewId()
self.popupDataID2 = wx.NewId()
self.popupDataID3 = wx.NewId()
self.popupDataID1 = NewId()
self.popupDataID2 = NewId()
self.popupDataID3 = NewId()

self.Bind(wx.EVT_MENU, self.OnSelectAll, id=self.popupDataID1)
self.Bind(wx.EVT_MENU, self.OnSelectInvert, id=self.popupDataID2)
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
from core.giface import Notification
from gui_core.widgets import LayersList
from gui_core.wrap import BitmapFromImage, Button, StaticText, StaticBox, SpinCtrl, \
CheckBox, BitmapButton, TextCtrl
CheckBox, BitmapButton, TextCtrl, NewId
from core.debug import Debug

wxUpdateDialog, EVT_DIALOG_UPDATE = NewEvent()
Expand Down Expand Up @@ -658,7 +658,7 @@ def __init__(self, parent, giface, task_description, id=wx.ID_ANY,
flag=wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT,
border=30)
# abort key bindings
abortId = wx.NewIdRef()
abortId = NewId()
self.Bind(wx.EVT_MENU, self.OnAbort, id=abortId)
accelTableList.append((wx.ACCEL_CTRL, ord('S'), abortId))
# set accelerator table
Expand Down
3 changes: 2 additions & 1 deletion gui/wxpython/gui_core/mapdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from core import globalvar
from core.debug import Debug
from gui_core.toolbars import ToolSwitcher
from gui_core.wrap import NewId

from grass.script import core as grass

Expand Down Expand Up @@ -127,7 +128,7 @@ def _initShortcuts(self):
)
accelTable = []
for handler, entry, kdb in shortcuts_table:
wxId = wx.NewId()
wxId = NewId()
self.Bind(wx.EVT_MENU, handler, id=wxId)
accelTable.append((entry, kdb, wxId))

Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from core.gcmd import DecodeString
from gui_core.treeview import TreeListView
from gui_core.wrap import Button, StaticText, Menu
from gui_core.wrap import Button, StaticText, Menu, NewId
from core.treemodel import TreeModel, DictNode

from grass.pydispatch.signal import Signal
Expand Down Expand Up @@ -153,7 +153,7 @@ def ShowContextMenu(self, node):

ids = []
for text in texts:
id = wx.NewId()
id = NewId()
ids.append(id)
self.Bind(
wx.EVT_MENU,
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/simplelmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from icons.icon import MetaIcon
from gui_core.forms import GUI
from gui_core.dialogs import SetOpacityDialog
from gui_core.wrap import CheckListBox, Menu
from gui_core.wrap import CheckListBox, Menu, NewId
from core.utils import GetLayerNameFromCmd
from core.gcmd import GError
from core.layerlist import LayerList
Expand Down Expand Up @@ -149,7 +149,7 @@ def OnContextMenu(self, event):
labels = [_("Copy map names to clipboard (top to bottom)"),
_("Copy map names to clipboard (bottom to top)")]
for label, text in zip(labels, texts):
id = wx.NewId()
id = NewId()
self.Bind(
wx.EVT_MENU,
lambda evt,
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from icons.icon import MetaIcon
from collections import defaultdict
from core.globalvar import IMGDIR
from gui_core.wrap import ToolBar, Menu, BitmapButton
from gui_core.wrap import ToolBar, Menu, BitmapButton, NewId

from grass.pydispatch.signal import Signal

Expand Down Expand Up @@ -138,7 +138,7 @@ def CreateTool(self, label, bitmap, kind,
bmpDisabled = wx.NullBitmap
tool = -1
if label:
tool = vars(self)[label] = wx.NewId()
tool = vars(self)[label] = NewId()
Debug.msg(3, "CreateTool(): tool=%d, label=%s bitmap=%s" %
(tool, label, bitmap))
if pos < 0:
Expand Down

0 comments on commit 2f5c06a

Please sign in to comment.