disable empty coils and contacts in LD/SFC editors
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 20 Jun 2017 16:36:17 +0300
changeset 1698 ae3e819252fc
parent 1697 75b8c54fa4b3
child 1699 65ce8afe4b8f
disable empty coils and contacts in LD/SFC editors

Closes #30
dialogs/LDElementDialog.py
--- a/dialogs/LDElementDialog.py	Mon Jun 19 19:23:31 2017 +0300
+++ b/dialogs/LDElementDialog.py	Tue Jun 20 16:36:17 2017 +0300
@@ -94,6 +94,8 @@
         self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT)
         self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, 
                   self.ElementVariable)
+        self.Bind(wx.EVT_TEXT, self.OnVariableChanged, 
+                  self.ElementVariable)        
         self.LeftGridSizer.AddWindow(self.ElementVariable, border=5,
              flag=wx.GROW|wx.TOP)
         
@@ -185,11 +187,21 @@
         Refresh preview panel of graphic element
         Override BlockPreviewDialog function
         """
+        value = self.ElementVariable.GetValue()
+        
         # Set graphic element displayed, creating a LD element
         self.Element = self.ElementClass(
                 self.Preview, 
                 self.GetElementModifier(),
-                self.ElementVariable.GetValue())
+                value)
+
+        button = self.ButtonSizer.GetAffirmativeButton()
+        button.Enable(value != "")
         
         # Call BlockPreviewDialog function
         BlockPreviewDialog.RefreshPreview(self)
+        
+    def OnOK(self, event):
+        if self.ElementVariable.GetValue() != "":
+            self.EndModal(wx.ID_OK)
+