Rename checkbox and immediately apply.
Added a checkbox in Location selection dialog (saved as user settings) to let user choose if variable is being renamed.
Also forced closing celle editor once new location is selected.
--- a/controls/LocationCellEditor.py Wed Apr 03 13:20:28 2019 +0200
+++ b/controls/LocationCellEditor.py Thu Apr 04 13:59:22 2019 +0200
@@ -127,6 +127,10 @@
self.VariableName = infos["var_name"]
self.VarType = infos["IEC_type"]
+ # when user selected something, end editing immediately
+ # so that changes over multiple colums appear
+ wx.CallAfter(self.Parent.Parent.CloseEditControl)
+
self.Location.SetFocus()
def OnLocationChar(self, event):
@@ -191,6 +195,9 @@
var_type = self.CellControl.GetVarType()
if var_type is not None:
self.Table.SetValueByName(row, 'Type', var_type)
+ else:
+ wx.CallAfter(self.Table.Parent.ShowErrorMessage,
+ _("Selected location is identical to previous one"))
self.CellControl.Disable()
return changed
--- a/dialogs/BrowseLocationsDialog.py Wed Apr 03 13:20:28 2019 +0200
+++ b/dialogs/BrowseLocationsDialog.py Thu Apr 04 13:59:22 2019 +0200
@@ -71,7 +71,7 @@
self.DIRFILTERCHOICE_OPTIONS = dict(
[(_(option), filter) for option, filter in GetDirFilterChoiceOptions()])
- main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10)
+ main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=10)
main_sizer.AddGrowableCol(0)
main_sizer.AddGrowableRow(1)
@@ -91,6 +91,15 @@
main_sizer.AddWindow(self.LocationsTree, border=20,
flag=wx.LEFT | wx.RIGHT | wx.GROW)
+ self.RenameCheckBox = wx.CheckBox(self, label=_("Rename variable to signal name"))
+ self.Config = wx.ConfigBase.Get()
+ default_checked = self.Config.Read("RenameVariableOnLocationChange") == "True"
+ self.RenameCheckBox.SetValue(default_checked)
+ self.do_rename = default_checked
+
+ main_sizer.AddWindow(self.RenameCheckBox, border=20,
+ flag=wx.LEFT | wx.RIGHT | wx.GROW)
+
button_gridsizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0)
button_gridsizer.AddGrowableCol(1)
button_gridsizer.AddGrowableCol(3)
@@ -217,9 +226,14 @@
def GetValues(self):
selected = self.LocationsTree.GetSelection()
- return self.LocationsTree.GetPyData(selected)
+ infos = self.LocationsTree.GetPyData(selected)
+ if not self.do_rename:
+ infos["var_name"] = None
+ return infos
def OnOK(self, event):
+ self.do_rename = self.RenameCheckBox.IsChecked()
+ self.Config.Write("RenameVariableOnLocationChange", str(self.do_rename))
selected = self.LocationsTree.GetSelection()
var_infos = None
if selected.IsOk():