--- a/dialogs/ConnectionDialog.py Fri Aug 11 15:18:19 2017 +0300
+++ b/dialogs/ConnectionDialog.py Mon Aug 14 19:13:01 2017 +0300
@@ -39,7 +39,7 @@
"""
class ConnectionDialog(BlockPreviewDialog):
-
+
def __init__(self, parent, controller, tagname, apply_button=False):
"""
Constructor
@@ -49,49 +49,49 @@
@param apply_button: Enable button for applying connector modification
to all connector having the same name in POU (default: False)
"""
- BlockPreviewDialog.__init__(self, parent, controller, tagname,
+ BlockPreviewDialog.__init__(self, parent, controller, tagname,
title=_('Connection Properties'))
-
+
# Init common sizers
self._init_sizers(2, 0, 7, 1, 0, None)
-
+
# Create label for connection type
type_label = wx.StaticText(self, label=_('Type:'))
self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
-
+
# Create radio buttons for selecting connection type
self.TypeRadioButtons = {}
first = True
for type, label in [(CONNECTOR, _('Connector')),
(CONTINUATION, _('Continuation'))]:
- radio_button = wx.RadioButton(self, label=label,
+ radio_button = wx.RadioButton(self, label=label,
style=(wx.RB_GROUP if first else 0))
radio_button.SetValue(first)
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
self.TypeRadioButtons[type] = radio_button
first = False
-
+
# Create label for connection name
name_label = wx.StaticText(self, label=_('Name:'))
self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW)
-
+
# Create text control for defining connection name
self.ConnectionName = wx.TextCtrl(self)
self.ConnectionName.SetMinSize(wx.Size(200,-1))
self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName)
self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW)
-
+
# Add preview panel and associated label to sizers
self.Preview.SetMinSize(wx.Size(-1,100))
self.LeftGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
self.LeftGridSizer.AddWindow(self.Preview, flag=wx.GROW)
-
+
# Add buttons sizer to sizers
- self.MainSizer.AddSizer(self.ButtonSizer, border=20,
+ self.MainSizer.AddSizer(self.ButtonSizer, border=20,
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
self.ColumnSizer.RemoveSizer(self.RightGridSizer)
-
+
# Add button for applying connection name modification to all connection
# of POU
if apply_button:
@@ -105,10 +105,10 @@
controller.GenerateNewName(
tagname, None, "Connection%d", 0))
self.Fit()
-
+
# Connector radio button is default control having keyboard focus
self.TypeRadioButtons[CONNECTOR].SetFocus()
-
+
def GetConnectionType(self):
"""
Return type selected for connection
@@ -117,7 +117,7 @@
return (CONNECTOR
if self.TypeRadioButtons[CONNECTOR].GetValue()
else CONTINUATION)
-
+
def SetValues(self, values):
"""
Set default connection parameters
@@ -125,18 +125,18 @@
"""
# For each parameters defined, set corresponding control value
for name, value in values.items():
-
+
# Parameter is connection type
if name == "type":
self.TypeRadioButtons[value].SetValue(True)
-
+
# Parameter is connection name
elif name == "name":
self.ConnectionName.SetValue(value)
-
+
# Refresh preview panel
self.RefreshPreview()
-
+
def GetValues(self):
"""
Return connection parameters defined in dialog
@@ -154,23 +154,23 @@
@return: True if connection name is valid
"""
message = None
-
+
# Get connection name typed by user
connection_name = self.ConnectionName.GetValue()
-
+
# Test that a name have been defined
if connection_name == "":
message = _("Form isn't complete. Name must be filled!")
-
+
# If an error have been identify, show error message dialog
if message is not None:
self.ShowErrorMessage(message)
# Test failed
return False
-
+
# Return result of element name test
return self.TestElementName(connection_name)
-
+
def OnOK(self, event):
"""
Called when dialog OK button is pressed
@@ -206,17 +206,16 @@
"""
self.RefreshPreview()
event.Skip()
-
+
def RefreshPreview(self):
"""
Refresh preview panel of graphic element
Override BlockPreviewDialog function
"""
# Set graphic element displayed, creating a FBD connection element
- self.Element = FBD_Connector(self.Preview,
+ self.Element = FBD_Connector(self.Preview,
self.GetConnectionType(),
self.ConnectionName.GetValue())
-
+
# Call BlockPreviewDialog function
BlockPreviewDialog.RefreshPreview(self)
-