Prevent global python_poll blocks to be created when accidentally adding content to C-File OnChange column. svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Fri, 03 Jul 2020 14:02:04 +0200
branchsvghmi
changeset 2991 ddf6144a56cf
parent 2990 a4bae7edca13
child 2992 d48ad9c3ec91
Prevent global python_poll blocks to be created when accidentally adding content to C-File OnChange column.
CodeFileTreeNode.py
py_ext/PythonFileCTNMixin.py
--- a/CodeFileTreeNode.py	Fri Jul 03 10:03:25 2020 +0200
+++ b/CodeFileTreeNode.py	Fri Jul 03 14:02:04 2020 +0200
@@ -207,9 +207,6 @@
                 variable.gettype(),
                 variable.getinitial())
                for variable in variables]
-        ret.extend([("On"+variable.getname()+"Change", "python_poll", "")
-                    for variable in variables
-                    if variable.getonchange()])
         return ret
 
     def CTNSearch(self, criteria):
--- a/py_ext/PythonFileCTNMixin.py	Fri Jul 03 10:03:25 2020 +0200
+++ b/py_ext/PythonFileCTNMixin.py	Fri Jul 03 14:02:04 2020 +0200
@@ -95,6 +95,17 @@
                getattr(self.CodeFile, section).getanyText() + "\n" + \
                self.PostSectionsTexts.get(section, "")
 
+    def CTNGlobalInstances(self):
+        variables = self.CodeFileVariables(self.CodeFile)
+        ret = [(variable.getname(),
+                variable.gettype(),
+                variable.getinitial())
+               for variable in variables]
+        ret.extend([("On"+variable.getname()+"Change", "python_poll", "")
+                    for variable in variables
+                    if variable.getonchange()])
+        return ret
+
     def CTNGenerate_C(self, buildpath, locations):
         # location string for that CTN
         location_str = "_".join(map(str, self.GetCurrentLocation()))