Bug on variables editing corrected
authorlbessard
Fri, 13 Apr 2007 17:10:09 +0200
changeset 11 e55d8385aef1
parent 10 112985848e1d
child 12 58a65b901719
Bug on variables editing corrected
PLCOpenEditor.py
--- a/PLCOpenEditor.py	Fri Apr 13 16:45:55 2007 +0200
+++ b/PLCOpenEditor.py	Fri Apr 13 17:10:09 2007 +0200
@@ -819,7 +819,7 @@
                             self.Controler.SetPouInterfaceReturnType(item_name, new_values["returnType"])
                         self.Controler.SetPouInterfaceVars(item_name, new_values["data"])
                         pou_names = self.Controler.GetElementsOpenedNames()
-                        if pou_name in pou_names:
+                        if item_name in pou_names:
                             window = self.TabsOpened.GetPage(pou_names.index(item_name))
                             if isinstance(window, TextViewer):
                                 varlist = []
@@ -2041,9 +2041,11 @@
             "Temp" : "   Temp", "Global" : "Global", "Access" : "Access"}
         
         if pou_type:
-            self.DefaultValue = {"Name" : "", "Class" : "Input", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
+            self.DefaultTypes = {"All" : "Input", "Interface" : "Input", "Variables" : "Local"}
+            self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
         else:
-            self.DefaultValue = {"Name" : "", "Class" : "Global", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
+            self.DefaultTypes = {"All" : "Global"}
+            self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No"}
         if not pou_type or pou_type == "program":
             self.Table = VariableTable(self, [], ["Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"])
             if pou_type:
@@ -2138,7 +2140,12 @@
             self.DownButton.Enable(False)
 
     def OnAddButton(self, event):
-        self.Table.AppendRow(self.DefaultValue.copy())
+        new_row = self.DefaultValue.copy()
+        if self.Filter in self.DefaultTypes:
+            new_row["Class"] = self.DefaultTypes[self.Filter]
+        else:
+            new_row["Class"] = self.Filter
+        self.Table.AppendRow(new_row)
         self.Table.ResetView(self.VariablesGrid)
         event.Skip()