Przeglądaj źródła

Python 3.10 compatibility fixes and SystemTrayIcon fix

Maftei Albert-Alexandru 4 lat temu
rodzic
commit
574cb6430d

+ 7 - 2
appCommon/Common.py

@@ -84,8 +84,13 @@ class LoudDict(dict):
 
         self.callback = callback
 
-
-class LoudUniqueList(list, collections.MutableSequence):
+# Fix for Python3.10
+MutableSequence = None
+try:
+    MutableSequence = collections.MutableSequence
+except AttributeError:
+    MutableSequence = collections.abc.MutableSequence
+class LoudUniqueList(list, MutableSequence):
     """
     A List with a callback for item changes, callback which returns the index where the items are added/modified.
     A List that will allow adding only items that are not in the list.

+ 1 - 2
appGUI/GUIElements.py

@@ -4662,8 +4662,7 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
         exitAction = menu.addAction(_("Exit"))
         exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))
         self.setContextMenu(menu)
-
-        menu_runscript.triggered.connect(lambda: self.app.on_filerunscript(
+        menu_runscript.triggered.connect(lambda: self.app.f_handlers.on_filerunscript(
             silent=True if self.app.cmd_line_headless == 1 else False))
 
         exitAction.triggered.connect(self.app.final_save)

+ 4 - 1
appTools/ToolCopperThieving.py

@@ -20,7 +20,10 @@ import shapely.affinity as affinity
 import logging
 from copy import deepcopy
 import numpy as np
-from collections import Iterable
+try:
+    from collections import Iterable
+except ImportError:
+    from collections.abc import Iterable
 
 import gettext
 import appTranslation as fcTranslate

+ 4 - 1
appTools/ToolQRCode.py

@@ -18,7 +18,10 @@ from shapely.affinity import translate
 from shapely.geometry import box
 
 from io import StringIO, BytesIO
-from collections import Iterable
+try:
+    from collections import Iterable
+except ImportError:
+    from collections.abc import Iterable
 import logging
 from copy import deepcopy
 

+ 5 - 2
camlib.py

@@ -38,8 +38,11 @@ from shapely.geometry import shape
 from descartes.patch import PolygonPatch
 # ---------------------------------------
 
-from collections import Iterable
-
+# Fix for python 3.10
+try:
+    from collections import Iterable
+except ImportError:
+    from collections.abc import Iterable
 import rasterio
 from rasterio.features import shapes
 import ezdxf