--- a/BeremizIDE.py Thu Jul 20 23:20:21 2023 +0200
+++ b/BeremizIDE.py Tue Jul 25 21:22:30 2023 +0200
@@ -31,7 +31,7 @@
import time
import signal
from time import time as gettime
-from threading import Lock, Timer, currentThread
+from threading import Lock, Timer, current_thread
import wx.lib.buttons
import wx.lib.statbmp
@@ -102,7 +102,7 @@
}
-MainThread = currentThread().ident
+MainThread = current_thread().ident
REFRESH_PERIOD = 0.1
@@ -153,7 +153,7 @@
self.LastRefreshTimer = None
def _should_write(self):
- if MainThread == currentThread().ident:
+ if MainThread == current_thread().ident:
app = wx.GetApp()
if app is not None:
self._write()
@@ -247,9 +247,9 @@
kind=wx.ITEM_NORMAL, text=_('New') + '\tCTRL+N')
AppendMenu(parent, help='', id=wx.ID_OPEN,
kind=wx.ITEM_NORMAL, text=_('Open') + '\tCTRL+O')
- parent.Append(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu)
+ self.RecentProjectsMenuItem = parent.AppendSubMenu(self.RecentProjectsMenu, _("&Recent Projects"))
parent.AppendSeparator()
- parent.Append(wx.ID_ANY, _("&Tutorials and Examples"), self.TutorialsProjectsMenu)
+ parent.AppendSubMenu(self.TutorialsProjectsMenu, _("&Tutorials and Examples"))
exemples_dir = Bpath("exemples")
project_list = sorted(os.listdir(exemples_dir))
@@ -707,7 +707,7 @@
item = self.RecentProjectsMenu.FindItemByPosition(0)
self.RecentProjectsMenu.Remove(item)
- self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0)
+ self.RecentProjectsMenuItem.Enable(len(recent_projects) > 0)
for idx, projectpath in enumerate(recent_projects):
text = '&%d: %s' % (idx + 1, projectpath)
--- a/IDEFrame.py Thu Jul 20 23:20:21 2023 +0200
+++ b/IDEFrame.py Tue Jul 25 21:22:30 2023 +0200
@@ -389,7 +389,7 @@
parent.AppendSeparator()
add_menu = wx.Menu(title='')
self._init_coll_AddMenu_Items(add_menu)
- parent.Append(wx.ID_ADD, _("&Add Element"), add_menu)
+ self.AddMenuItem = parent.AppendSubMenu(add_menu, _("&Add Element"))
AppendMenu(parent, help='', id=wx.ID_SELECTALL,
kind=wx.ITEM_NORMAL, text=_('Select All') + '\tCTRL+A')
AppendMenu(parent, help='', id=wx.ID_DELETE,
@@ -440,7 +440,7 @@
kind=wx.ITEM_NORMAL, text=_('Clear Errors') + '\tCTRL+K')
parent.AppendSeparator()
zoommenu = wx.Menu(title='')
- parent.Append(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu)
+ self.ZoomMenuItem = parent.AppendSubMenu(zoommenu, _("Zoom"))
for idx, value in enumerate(ZOOM_FACTORS):
new_item = AppendMenu(zoommenu, help='',
kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%")
@@ -1179,7 +1179,7 @@
selected > -1 and self.SearchParams is not None)
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, True)
MenuToolBar.EnableTool(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, True)
- self.EditMenu.Enable(wx.ID_ADD, True)
+ self.AddMenuItem.Enable(True)
self.EditMenu.Enable(wx.ID_DELETE, True)
if self.TabsOpened.GetPageCount() > 0:
self.EditMenu.Enable(wx.ID_CUT, True)
@@ -1219,7 +1219,7 @@
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, False)
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False)
MenuToolBar.EnableTool(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False)
- self.EditMenu.Enable(wx.ID_ADD, False)
+ self.AddMenuItem.Enable( False)
self.EditMenu.Enable(wx.ID_DELETE, False)
def CloseTabsWithoutModel(self, refresh=True):
@@ -1351,24 +1351,24 @@
if selected != -1:
window = self.TabsOpened.GetPage(selected)
if isinstance(window, Viewer):
- self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, True)
- zoommenu = self.DisplayMenu.FindItemById(wx.ID_ZOOM_FIT).GetSubMenu()
+ self.ZoomMenuItem.Enable(True)
+ zoommenu = self.ZoomMenuItem.GetSubMenu()
zoomitem = zoommenu.FindItemByPosition(window.GetScale())
zoomitem.Check(True)
else:
- self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False)
+ self.ZoomMenuItem.Enable(False)
else:
- self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False)
+ self.ZoomMenuItem.Enable(False)
else:
self.DisplayMenu.Enable(wx.ID_REFRESH, False)
- self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False)
+ self.ZoomMenuItem.Enable(False)
if self.EnableDebug:
self.DisplayMenu.Enable(wx.ID_CLEAR, True)
else:
self.DisplayMenu.Enable(wx.ID_REFRESH, False)
if self.EnableDebug:
self.DisplayMenu.Enable(wx.ID_CLEAR, False)
- self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False)
+ self.ZoomMenuItem.Enable(False)
def OnRefreshMenu(self, event):
self.RefreshEditor()
--- a/ProjectController.py Thu Jul 20 23:20:21 2023 +0200
+++ b/ProjectController.py Tue Jul 25 21:22:30 2023 +0200
@@ -36,12 +36,11 @@
import re
import tempfile
import hashlib
+import shutil
from datetime import datetime
from weakref import WeakKeyDictionary
from functools import reduce
-from distutils.dir_util import copy_tree
-
import wx
import features
@@ -588,7 +587,7 @@
old_projectfiles_path = self._getProjectFilesPath(
from_project_path)
if os.path.isdir(old_projectfiles_path):
- copy_tree(old_projectfiles_path,
+ shutil.copytree(old_projectfiles_path,
self._getProjectFilesPath(self.ProjectPath))
self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml'))
result = self.CTNRequestSave(from_project_path)