Copy description when DnD variables from Globals in resources and configuration variable panels to POUs. Also prevent making exception in case some other DropSource wouldn't provide description. svghmi
authorEdouard Tisserant
Mon, 30 Aug 2021 09:39:23 +0200
branchsvghmi
changeset 3300 95fe62bfe920
parent 3299 8b45d8494fae
child 3301 8447d856908b
child 3302 c89fc366bebd
Copy description when DnD variables from Globals in resources and configuration variable panels to POUs. Also prevent making exception in case some other DropSource wouldn't provide description.
controls/VariablePanel.py
editors/Viewer.py
--- a/controls/VariablePanel.py	Fri Aug 27 11:31:32 2021 +0200
+++ b/controls/VariablePanel.py	Mon Aug 30 09:39:23 2021 +0200
@@ -956,7 +956,8 @@
             var_name = self.Table.GetValueByName(row, "Name")
             var_class = self.Table.GetValueByName(row, "Class")
             var_type = self.Table.GetValueByName(row, "Type")
-            data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName)))
+            var_doc = self.Table.GetValueByName(row, "Documentation")
+            data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName, var_doc)))
             dragSource = wx.DropSource(self.VariablesGrid)
             dragSource.SetData(data)
             dragSource.DoDragDrop()
--- a/editors/Viewer.py	Fri Aug 27 11:31:32 2021 +0200
+++ b/editors/Viewer.py	Mon Aug 30 09:39:23 2021 +0200
@@ -389,8 +389,8 @@
                 elif var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]:
                     message = _("\"%s\" pou already exists!") % var_name
                 elif not var_name.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
-                    print(values) 
-                    self.ParentWindow.Controler.AddEditedElementPouExternalVar(tagname, values[2], var_name, description=values[4])
+                    kwargs = dict(description=values[4]) if len(values)>4 else {}
+                    self.ParentWindow.Controler.AddEditedElementPouExternalVar(tagname, values[2], var_name, **kwargs)
                     self.ParentWindow.RefreshVariablePanel()
                     self.ParentWindow.ParentWindow.RefreshPouInstanceVariablesPanel()
                     self.ParentWindow.AddVariableBlock(x, y, scaling, INPUT, var_name, values[2])