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.
--- 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])