Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use. svghmi
authorEdouard Tisserant
Mon, 24 May 2021 14:33:54 +0200
branchsvghmi
changeset 3246 0e8dbc2c390e
parent 3245 c441181247cf
child 3248 ea93c14342d1
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
BeremizIDE.py
IDEFrame.py
PLCOpenEditor.py
controls/DiscoveryPanel.py
controls/LogViewer.py
controls/SearchResultPanel.py
docutil/dochtml.py
editors/CodeFileEditor.py
editors/DataTypeEditor.py
editors/ResourceEditor.py
editors/TextViewer.py
editors/Viewer.py
etherlab/ConfigEditor.py
--- a/BeremizIDE.py	Thu May 20 12:16:51 2021 +0200
+++ b/BeremizIDE.py	Mon May 24 14:33:54 2021 +0200
@@ -81,7 +81,6 @@
     LIBRARYTREE,\
     PAGETITLES,\
     IDEFrame, \
-    AppendMenu,\
     EncodeFileSystemPath, \
     DecodeFileSystemPath
 
@@ -92,6 +91,8 @@
 def Bpath(*args):
     return os.path.join(beremiz_dir, *args)
 
+def AppendMenu(parent, help, id, kind, text):
+    return parent.Append(help=help, id=id, kind=kind, text=text)
 
 MAX_RECENT_PROJECTS = 9
 
--- a/IDEFrame.py	Thu May 20 12:16:51 2021 +0200
+++ b/IDEFrame.py	Mon May 24 14:33:54 2021 +0200
@@ -114,8 +114,8 @@
     return text(path, sys.getfilesystemencoding())
 
 
-def AppendMenu(parent, help, id, kind, text):
-    parent.Append(help=help, id=id, kind=kind, text=text)
+def AppendMenu(parent, help, kind, text, id=wx.ID_ANY):
+    return parent.Append(help=help, kind=kind, text=text, id=id)
 
 
 [
@@ -444,10 +444,9 @@
         zoommenu = wx.Menu(title='')
         parent.AppendMenu(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu)
         for idx, value in enumerate(ZOOM_FACTORS):
-            new_id = wx.NewId()
-            AppendMenu(zoommenu, help='', id=new_id,
+            new_item = AppendMenu(zoommenu, help='',
                        kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%")
-            self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id)
+            self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), new_item)
 
         parent.AppendSeparator()
         AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE,
@@ -1906,56 +1905,49 @@
 
             if name == "Data Types":
                 menu = wx.Menu(title='')
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add DataType"))
-                self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, id=new_id)
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add DataType"))
+                self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, new_item)
 
             elif name in ["Functions", "Function Blocks", "Programs", "Project"]:
                 menu = wx.Menu(title='')
 
                 if name != "Project":
-                    new_id = wx.NewId()
-                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add POU"))
-                    self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions": "function", "Function Blocks": "functionBlock", "Programs": "program"}[name]), id=new_id)
-
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Paste POU"))
-                self.Bind(wx.EVT_MENU, self.OnPastePou, id=new_id)
+                    new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add POU"))
+                    self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions": "function", "Function Blocks": "functionBlock", "Programs": "program"}[name]), new_item)
+
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Paste POU"))
+                self.Bind(wx.EVT_MENU, self.OnPastePou, new_item)
                 if self.GetCopyBuffer() is None:
-                    menu.Enable(new_id, False)
+                    menu.Enable(new_item, False)
 
             elif name == "Configurations":
                 menu = wx.Menu(title='')
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Configuration"))
-                self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, id=new_id)
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Configuration"))
+                self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, new_item)
 
             elif name == "Transitions":
                 menu = wx.Menu(title='')
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition"))
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Transition"))
                 parent = self.ProjectTree.GetItemParent(item)
                 parent_type = self.ProjectTree.GetPyData(parent)["type"]
                 while parent_type != ITEM_POU:
                     parent = self.ProjectTree.GetItemParent(parent)
                     parent_type = self.ProjectTree.GetPyData(parent)["type"]
-                self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(self.ProjectTree.GetItemText(parent)), id=new_id)
+                self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(self.ProjectTree.GetItemText(parent)), new_item)
 
             elif name == "Actions":
                 menu = wx.Menu(title='')
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action"))
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Action"))
                 parent = self.ProjectTree.GetItemParent(item)
                 parent_type = self.ProjectTree.GetPyData(parent)["type"]
                 while parent_type != ITEM_POU:
                     parent = self.ProjectTree.GetItemParent(parent)
                     parent_type = self.ProjectTree.GetPyData(parent)["type"]
-                self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(self.ProjectTree.GetItemText(parent)), id=new_id)
+                self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(self.ProjectTree.GetItemText(parent)), new_item)
 
             elif name == "Resources":
                 menu = wx.Menu(title='')
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource"))
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Resource"))
                 parent = self.ProjectTree.GetItemParent(item)
                 parent_type = self.ProjectTree.GetPyData(parent)["type"]
                 while parent_type not in [ITEM_CONFIGURATION, ITEM_PROJECT]:
@@ -1969,52 +1961,44 @@
                 else:
                     parent_name = self.ProjectTree.GetItemText(parent)
                 if parent_name is not None:
-                    self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(parent_name), id=new_id)
+                    self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(parent_name), new_item)
 
         else:
             if item_infos["type"] == ITEM_POU:
                 menu = wx.Menu(title='')
                 if self.Controler.GetPouBodyType(name) == "SFC":
-                    new_id = wx.NewId()
-                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition"))
-                    self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), id=new_id)
-                    new_id = wx.NewId()
-                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action"))
-                    self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), id=new_id)
+                    new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Transition"))
+                    self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), new_item)
+                    new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Action"))
+                    self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), new_item)
                     menu.AppendSeparator()
 
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Copy POU"))
-                self.Bind(wx.EVT_MENU, self.OnCopyPou, id=new_id)
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Copy POU"))
+                self.Bind(wx.EVT_MENU, self.OnCopyPou, new_item)
 
                 pou_type = self.Controler.GetPouType(name)
                 if pou_type in ["function", "functionBlock"]:
                     change_menu = wx.Menu(title='')
                     if pou_type == "function":
-                        new_id = wx.NewId()
-                        AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Function Block"))
-                        self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "functionBlock"), id=new_id)
-                    new_id = wx.NewId()
-                    AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Program"))
-                    self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), id=new_id)
+                        new_item = AppendMenu(change_menu, help='', kind=wx.ITEM_NORMAL, text=_("Function Block"))
+                        self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "functionBlock"), new_item)
+                    new_item = AppendMenu(change_menu, help='', kind=wx.ITEM_NORMAL, text=_("Program"))
+                    self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), new_item)
                     menu.AppendMenu(wx.NewId(), _("Duplicate as..."), change_menu)
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Rename"))
-                self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, id=new_id)
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Rename"))
+                self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, new_item)
 
             elif item_infos["type"] == ITEM_CONFIGURATION:
                 menu = wx.Menu(title='')
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource"))
-                self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), id=new_id)
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Add Resource"))
+                self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), new_item)
 
             elif item_infos["type"] in [ITEM_DATATYPE, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE]:
                 menu = wx.Menu(title='')
 
             if menu is not None:
-                new_id = wx.NewId()
-                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete"))
-                self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=new_id)
+                new_item = AppendMenu(menu, help='', kind=wx.ITEM_NORMAL, text=_("Delete"))
+                self.Bind(wx.EVT_MENU, self.OnDeleteMenu, new_item)
 
         if menu is not None:
             self.FindFocus().PopupMenu(menu)
--- a/PLCOpenEditor.py	Thu May 20 12:16:51 2021 +0200
+++ b/PLCOpenEditor.py	Mon May 24 14:33:54 2021 +0200
@@ -140,9 +140,8 @@
                 _(u'Community support'),
                 wx.OK | wx.ICON_INFORMATION)
 
-        id = wx.NewId()
-        parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support'))
-        self.Bind(wx.EVT_MENU, handler, id=id)
+        menu_entry = parent.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, text=_(u'Community support'))
+        self.Bind(wx.EVT_MENU, handler, menu_entry)
 
         AppendMenu(parent, help='', id=wx.ID_ABOUT,
                    kind=wx.ITEM_NORMAL, text=_(u'About'))
--- a/controls/DiscoveryPanel.py	Thu May 20 12:16:51 2021 +0200
+++ b/controls/DiscoveryPanel.py	Mon May 24 14:33:54 2021 +0200
@@ -35,9 +35,9 @@
 
 
 class AutoWidthListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin):
-    def __init__(self, parent, id, name, pos=wx.DefaultPosition,
+    def __init__(self, parent, name, pos=wx.DefaultPosition,
                  size=wx.DefaultSize, style=0):
-        wx.ListCtrl.__init__(self, parent, id, pos, size, style, name=name)
+        wx.ListCtrl.__init__(self, parent, wx.ID_ANY, pos, size, style, name=name)
         listmix.ListCtrlAutoWidthMixin.__init__(self)
 
 
@@ -73,9 +73,7 @@
 
     def _init_list_ctrl(self):
         # Set up list control
-        listID = wx.NewId()
         self.ServicesList = AutoWidthListCtrl(
-            id=listID,
             name='ServicesList', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0),
             style=wx.LC_REPORT | wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING | wx.LC_SINGLE_SEL)
         self.ServicesList.InsertColumn(0, _('NAME'))
@@ -87,8 +85,8 @@
         self.ServicesList.SetColumnWidth(2, 150)
         self.ServicesList.SetColumnWidth(3, 150)
         self.ServicesList.SetInitialSize(wx.Size(-1, 300))
-        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, id=listID)
-        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, id=listID)
+        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.ServicesList)
+        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.ServicesList)
 
     def _init_ctrls(self, prnt):
         self.staticText1 = wx.StaticText(
--- a/controls/LogViewer.py	Thu May 20 12:16:51 2021 +0200
+++ b/controls/LogViewer.py	Mon May 24 14:33:54 2021 +0200
@@ -711,9 +711,8 @@
         if message is not None:
             menu = wx.Menu(title='')
 
-            new_id = wx.NewId()
-            menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Copy"))
-            self.Bind(wx.EVT_MENU, self.GetCopyMessageToClipboardFunction(message), id=new_id)
+            menu_entry = menu.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, text=_("Copy"))
+            self.Bind(wx.EVT_MENU, self.GetCopyMessageToClipboardFunction(message), menu_entry)
 
             self.MessagePanel.PopupMenu(menu)
             menu.Destroy()
--- a/controls/SearchResultPanel.py	Thu May 20 12:16:51 2021 +0200
+++ b/controls/SearchResultPanel.py	Mon May 24 14:33:54 2021 +0200
@@ -49,13 +49,6 @@
 #                            Search Result Panel
 # -------------------------------------------------------------------------------
 
-
-[
-    ID_SEARCHRESULTPANEL, ID_SEARCHRESULTPANELHEADERLABEL,
-    ID_SEARCHRESULTPANELSEARCHRESULTSTREE, ID_SEARCHRESULTPANELRESETBUTTON,
-] = [wx.NewId() for _init_ctrls in range(4)]
-
-
 class SearchResultPanel(wx.Panel):
 
     def _init_coll_MainSizer_Items(self, parent):
@@ -84,18 +77,15 @@
         self.SetSizer(self.MainSizer)
 
     def _init_ctrls(self, prnt):
-        self.HeaderLabel = wx.StaticText(id=ID_SEARCHRESULTPANELHEADERLABEL,
-                                         name='HeaderLabel', parent=self,
+        self.HeaderLabel = wx.StaticText(name='HeaderLabel', parent=self,
                                          pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
 
         search_results_tree_style = CT.TR_HAS_BUTTONS | CT.TR_NO_LINES | CT.TR_HAS_VARIABLE_ROW_HEIGHT
-        self.SearchResultsTree = CT.CustomTreeCtrl(id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE,
-                                                   name="SearchResultsTree", parent=self,
+        self.SearchResultsTree = CT.CustomTreeCtrl(name="SearchResultsTree", parent=self,
                                                    pos=wx.Point(0, 0), style=search_results_tree_style)
-        if wx.VERSION >= (2, 8, 11):
-            self.SearchResultsTree.SetAGWWindowStyleFlag(search_results_tree_style)
+        self.SearchResultsTree.SetAGWWindowStyleFlag(search_results_tree_style)
         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
-                  id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)
+                  self.SearchResultsTree)
 
         self.ResetButton = wx.lib.buttons.GenBitmapButton(
             self, bitmap=GetBitmap("reset"),
@@ -106,7 +96,7 @@
         self._init_sizers()
 
     def __init__(self, parent, window):
-        wx.Panel.__init__(self, id=ID_SEARCHRESULTPANEL,
+        wx.Panel.__init__(self,
                           name='SearchResultPanel', parent=parent,
                           pos=wx.Point(0, 0),
                           size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
--- a/docutil/dochtml.py	Thu May 20 12:16:51 2021 +0200
+++ b/docutil/dochtml.py	Mon May 24 14:33:54 2021 +0200
@@ -41,7 +41,6 @@
         window.Show()
 
 
-[ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)]
 EVT_HTML_URL_CLICK = wx.NewId()
 
 
@@ -72,13 +71,12 @@
         self.SetIcon(prnt.icon)
         self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
 
-        self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
-                                              name='HtmlContent', parent=self, pos=wx.Point(0, 0),
+        self.HtmlContent = UrlClickHtmlWindow(name='HtmlContent', parent=self, pos=wx.Point(0, 0),
                                               size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO | wx.html.HW_NO_SELECTION)
         self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
 
     def __init__(self, parent, opened):
-        wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
+        wx.Frame.__init__(self, name='HtmlFrame',
                           parent=parent, pos=wx.Point(320, 231),
                           size=wx.Size(853, 616),
                           style=wx.DEFAULT_FRAME_STYLE, title='')
--- a/editors/CodeFileEditor.py	Thu May 20 12:16:51 2021 +0200
+++ b/editors/CodeFileEditor.py	Mon May 24 14:33:54 2021 +0200
@@ -826,16 +826,14 @@
             type_menu = wx.Menu(title='')
             base_menu = wx.Menu(title='')
             for base_type in self.Controler.GetBaseTypes():
-                new_id = wx.NewId()
-                base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type)
-                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id)
-            type_menu.AppendMenu(wx.NewId(), "Base Types", base_menu)
+                new_entry = base_menu.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, text=base_type)
+                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), new_entry)
+            type_menu.AppendMenu(wx.ID_ANY, "Base Types", base_menu)
             datatype_menu = wx.Menu(title='')
             for datatype in self.Controler.GetDataTypes():
-                new_id = wx.NewId()
-                datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
-                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)
-            type_menu.AppendMenu(wx.NewId(), "User Data Types", datatype_menu)
+                new_entry = datatype_menu.Append(help='', id=wx.ID_ANY, kind=wx.ITEM_NORMAL, text=datatype)
+                self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), new_entry)
+            type_menu.AppendMenu(wx.ID_ANY, "User Data Types", datatype_menu)
             rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col))
 
             self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize())
--- a/editors/DataTypeEditor.py	Thu May 20 12:16:51 2021 +0200
+++ b/editors/DataTypeEditor.py	Mon May 24 14:33:54 2021 +0200
@@ -46,8 +46,8 @@
 DIMENSION_MODEL = re.compile(r"([0-9]+)\.\.([0-9]+)$")
 
 
-def AppendMenu(parent, help, id, kind, text):
-    parent.Append(help=help, id=id, kind=kind, text=text)
+def AppendMenu(parent, help, kind, text):
+    return parent.Append(help=help, id=wx.ID_ANY, kind=kind, text=text)
 
 
 def GetElementsTableColnames():
@@ -633,31 +633,18 @@
 
             base_menu = wx.Menu(title='')
             for base_type in self.Controler.GetBaseTypes():
-                new_id = wx.NewId()
-                AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type)
-                self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), id=new_id)
-            type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu)
+                new_entry = AppendMenu(base_menu, help='', kind=wx.ITEM_NORMAL, text=base_type)
+                self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), new_entry)
+            type_menu.AppendMenu(wx.ID_ANY, _("Base Types"), base_menu)
 
             datatype_menu = wx.Menu(title='')
             for datatype in self.Controler.GetDataTypes(self.TagName, False):
-                new_id = wx.NewId()
-                AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
-                self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), id=new_id)
-            type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu)
-
-            new_id = wx.NewId()
-            AppendMenu(type_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array"))
-            self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, id=new_id)
-
-#            functionblock_menu = wx.Menu(title='')
-#            bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
-#            pouname, poutype = self.Controler.GetEditedElementType(self.TagName)
-#            if classtype in ["Input","Output","InOut","External","Global"] or poutype != "function" and bodytype in ["ST", "IL"]:
-#                for functionblock_type in self.Controler.GetFunctionBlockTypes(self.TagName):
-#                    new_id = wx.NewId()
-#                    AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type)
-#                    self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id)
-#                type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu)
+                new_entry = AppendMenu(datatype_menu, help='', kind=wx.ITEM_NORMAL, text=datatype)
+                self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), new_entry)
+            type_menu.AppendMenu(wx.ID_ANY, _("User Data Types"), datatype_menu)
+
+            new_entry = AppendMenu(type_menu, help='', kind=wx.ITEM_NORMAL, text=_("Array"))
+            self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, new_entry)
 
             rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col))
             self.StructureElementsGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize())
--- a/editors/ResourceEditor.py	Thu May 20 12:16:51 2021 +0200
+++ b/editors/ResourceEditor.py	Mon May 24 14:33:54 2021 +0200
@@ -43,14 +43,8 @@
 # -------------------------------------------------------------------------------
 
 
-[
-    ID_CONFIGURATIONEDITOR,
-] = [wx.NewId() for _init_ctrls in range(1)]
-
-
 class ConfigurationEditor(EditorPanel):
 
-    ID = ID_CONFIGURATIONEDITOR
     VARIABLE_PANEL_TYPE = "config"
 
     def GetBufferState(self):
--- a/editors/TextViewer.py	Thu May 20 12:16:51 2021 +0200
+++ b/editors/TextViewer.py	Mon May 24 14:33:54 2021 +0200
@@ -55,10 +55,6 @@
  STC_PLC_EMPTY] = range(11)
 [SPACE, WORD, NUMBER, STRING, WSTRING, COMMENT, PRAGMA, DPRAGMA] = range(8)
 
-[
-    ID_TEXTVIEWER, ID_TEXTVIEWERTEXTCTRL,
-] = [wx.NewId() for _init_ctrls in range(2)]
-
 re_texts = {}
 re_texts["letter"] = "[A-Za-z]"
 re_texts["digit"] = "[0-9]"
@@ -79,11 +75,8 @@
 
 class TextViewer(EditorPanel):
 
-    ID = ID_TEXTVIEWER
-
     def _init_Editor(self, prnt):
-        self.Editor = CustomStyledTextCtrl(id=ID_TEXTVIEWERTEXTCTRL,
-                                           parent=prnt, name="TextViewer", size=wx.Size(0, 0), style=0)
+        self.Editor = CustomStyledTextCtrl(parent=prnt, name="TextViewer", size=wx.Size(0, 0), style=0)
         self.Editor.ParentWindow = self
 
         self.Editor.CmdKeyAssign(ord('+'), wx.stc.STC_SCMOD_CTRL, wx.stc.STC_CMD_ZOOMIN)
@@ -140,14 +133,14 @@
                                     wx.stc.STC_MOD_BEFOREDELETE |
                                     wx.stc.STC_PERFORMED_USER)
 
-        self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded, id=ID_TEXTVIEWERTEXTCTRL)
+        self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyleNeeded, self.Editor)
         self.Editor.Bind(wx.stc.EVT_STC_MARGINCLICK, self.OnMarginClick)
         self.Editor.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
         self.Editor.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
         if self.Controler is not None:
             self.Editor.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
-            self.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, id=ID_TEXTVIEWERTEXTCTRL)
-            self.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification, id=ID_TEXTVIEWERTEXTCTRL)
+            self.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, self.Editor)
+            self.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification, self.Editor)
 
     def __init__(self, parent, tagname, window, controler, debug=False, instancepath=""):
         if tagname != "" and controler is not None:
--- a/editors/Viewer.py	Thu May 20 12:16:51 2021 +0200
+++ b/editors/Viewer.py	Mon May 24 14:33:54 2021 +0200
@@ -67,10 +67,6 @@
                    wx.StockCursor(wx.CURSOR_SIZENS)]
 
 
-def AppendMenu(parent, help, id, kind, text):
-    parent.Append(help=help, id=id, kind=kind, text=text)
-
-
 if wx.Platform == '__WXMSW__':
     faces = {
         'times': 'Times New Roman',
@@ -238,25 +234,6 @@
 # -------------------------------------------------------------------------------
 
 
-# ID Constants for alignment menu items
-[
-    ID_VIEWERALIGNMENTMENUITEMS0, ID_VIEWERALIGNMENTMENUITEMS1,
-    ID_VIEWERALIGNMENTMENUITEMS2, ID_VIEWERALIGNMENTMENUITEMS4,
-    ID_VIEWERALIGNMENTMENUITEMS5, ID_VIEWERALIGNMENTMENUITEMS6,
-] = [wx.NewId() for _init_coll_AlignmentMenu_Items in range(6)]
-
-# ID Constants for contextual menu items
-[
-    ID_VIEWERCONTEXTUALMENUITEMS0, ID_VIEWERCONTEXTUALMENUITEMS1,
-    ID_VIEWERCONTEXTUALMENUITEMS2, ID_VIEWERCONTEXTUALMENUITEMS3,
-    ID_VIEWERCONTEXTUALMENUITEMS5, ID_VIEWERCONTEXTUALMENUITEMS6,
-    ID_VIEWERCONTEXTUALMENUITEMS8, ID_VIEWERCONTEXTUALMENUITEMS9,
-    ID_VIEWERCONTEXTUALMENUITEMS11, ID_VIEWERCONTEXTUALMENUITEMS12,
-    ID_VIEWERCONTEXTUALMENUITEMS14, ID_VIEWERCONTEXTUALMENUITEMS16,
-    ID_VIEWERCONTEXTUALMENUITEMS17,
-] = [wx.NewId() for _init_coll_ContextualMenu_Items in range(13)]
-
-
 class ViewerDropTarget(wx.TextDropTarget):
 
     def __init__(self, parent):
@@ -535,17 +512,6 @@
     manipulating graphic elements
     """
 
-    # Add list of menu items to the given menu
-    def AddMenuItems(self, menu, items):
-        for item in items:
-            if item is None:
-                menu.AppendSeparator()
-            else:
-                id, kind, text, help, callback = item
-                AppendMenu(menu, help=help, id=id, kind=kind, text=text)
-                # Link menu event to corresponding called functions
-                self.Bind(wx.EVT_MENU, callback, id=id)
-
     def AppendItem(self, menu, text, callback, *args, **kwargs):
         item = menu.Append(wx.ID_ANY, text, *args, **kwargs)
         self.Bind(wx.EVT_MENU, callback, item)
--- a/etherlab/ConfigEditor.py	Thu May 20 12:16:51 2021 +0200
+++ b/etherlab/ConfigEditor.py	Mon May 24 14:33:54 2021 +0200
@@ -33,13 +33,6 @@
 [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
 
 
-def AppendMenu(parent, help, id, kind, text):
-    if wx.VERSION >= (2, 6, 0):
-        parent.Append(help=help, id=id, kind=kind, text=text)
-    else:
-        parent.Append(helpString=help, id=id, kind=kind, item=text)
-
-
 def GetVariablesTableColnames(position=False):
     _ = NoTranslate
     colname = ["#"]