dialogs/SFCTransitionDialog.py
changeset 1784 64beb9e9c749
parent 1782 5b6ad7a7fd9d
child 1847 6198190bc121
--- a/dialogs/SFCTransitionDialog.py	Mon Aug 21 20:17:19 2017 +0000
+++ b/dialogs/SFCTransitionDialog.py	Mon Aug 21 23:22:58 2017 +0300
@@ -28,17 +28,17 @@
 from graphics.SFC_Objects import SFC_Transition
 from BlockPreviewDialog import BlockPreviewDialog
 
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
 #                        Set Transition Parameters Dialog
-#-------------------------------------------------------------------------------
-
-"""
-Class that implements a dialog for defining parameters of a transition graphic
-element
-"""
+# -------------------------------------------------------------------------------
+
 
 class SFCTransitionDialog(BlockPreviewDialog):
-    
+    """
+    Class that implements a dialog for defining parameters of a transition graphic
+    element
+    """
+
     def __init__(self, parent, controller, tagname, connection=True):
         """
         Constructor
@@ -49,34 +49,34 @@
         connection (default: True)
         """
         BlockPreviewDialog.__init__(self, parent, controller, tagname,
-              title=_('Edit transition'))
-        
+                                    title=_('Edit transition'))
+
         # Init common sizers
         self._init_sizers(2, 0, 8, None, 2, 1)
-        
+
         # Create label for transition type
         type_label = wx.StaticText(self, label=_('Type:'))
         self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)
-        
+
         # Create combo box for selecting reference value
         reference = wx.ComboBox(self, style=wx.CB_READONLY)
         reference.Append("")
         for transition in controller.GetEditedElementTransitions(tagname):
             reference.Append(transition)
         self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, reference)
-        
+
         # Create Text control for defining inline value
         inline = wx.TextCtrl(self)
         self.Bind(wx.EVT_TEXT, self.OnInlineChanged, inline)
-        
+
         # Create radio buttons for selecting power rail type
         self.TypeRadioButtons = {}
         first = True
         for type, label, control in [('reference', _('Reference'), reference),
                                      ('inline', _('Inline'), inline),
                                      ('connection', _('Connection'), None)]:
-            radio_button = wx.RadioButton(self, label=label, 
-                  style=(wx.RB_GROUP if first else 0))
+            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)
@@ -85,29 +85,30 @@
                 self.LeftGridSizer.AddWindow(control, flag=wx.GROW)
             self.TypeRadioButtons[type] = (radio_button, control)
             first = False
-        
+
         # Create label for transition priority
         priority_label = wx.StaticText(self, label=_('Priority:'))
         self.LeftGridSizer.AddWindow(priority_label, flag=wx.GROW)
-        
+
         # Create spin control for defining priority value
         self.Priority = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS)
         self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, self.Priority)
         self.LeftGridSizer.AddWindow(self.Priority, flag=wx.GROW)
-        
+
         # Add preview panel and associated label to sizers
         self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
         self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)
-        
+
         # Add buttons sizer to sizers
-        self.MainSizer.AddSizer(self.ButtonSizer, border=20, 
-              flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
+        self.MainSizer.AddSizer(
+            self.ButtonSizer, border=20,
+            flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
 
         self.Fit()
-        
+
         # Reference radio button is default control having keyboard focus
         self.TypeRadioButtons["reference"][0].SetFocus()
-    
+
     def GetTransitionType(self):
         """
         Return type selected for SFC transition and associated value
@@ -124,7 +125,7 @@
                 else:
                     return type, None
         return None, None
-    
+
     def SetValues(self, values):
         """
         Set default SFC transition parameters
@@ -132,14 +133,14 @@
         """
         # Extract transition value according to type
         type_value = values.get("value", None)
-        
+
         # For each parameters defined, set corresponding control value
         for name, value in values.items():
-            
+
             # Parameter is SFC transition priority
             if name == "priority":
                 self.Priority.SetValue(values["priority"])
-            
+
             # Parameter is SFC transition type
             elif name == "type":
                 for type, (radio, control) in self.TypeRadioButtons.iteritems():
@@ -152,20 +153,20 @@
                                 control.SetStringSelection(type_value)
                             elif isinstance(control, wx.TextCtrl):
                                 control.ChangeValue(type_value)
-        
+
         # Refresh preview panel
         self.RefreshPreview()
-        
+
     def GetValues(self):
         """
         Return SFC transition parameters defined in dialog
         @return: {parameter_name: parameter_value,...}
         """
-        values = {"priority" : self.Priority.GetValue()}
+        values = {"priority": self.Priority.GetValue()}
         values["type"], values["value"] = self.GetTransitionType()
         values["width"], values["height"] = self.Element.GetSize()
         return values
-    
+
     def OnOK(self, event):
         """
         Called when dialog OK button is pressed
@@ -173,18 +174,18 @@
         @param event: wx.Event from OK button
         """
         message = None
-        
+
         # Get transition type and value associated
         type, value = self.GetTransitionType()
-        
+
         # Test that value associated to type is defined
         if type != "connection" and value == "":
             message = _("Form isn't complete. %s must be filled!") % type
-        
+
         # Show error message if an error is detected
         if message is not None:
             self.ShowErrorMessage(message)
-        
+
         else:
             # Call BlockPreviewDialog function
             BlockPreviewDialog.OnOK(self, event)
@@ -198,7 +199,7 @@
         for type, (radio, control) in self.TypeRadioButtons.iteritems():
             if control is not None:
                 control.Enable(radio.GetValue())
-        
+
         # Refresh preview panel
         self.RefreshPreview()
         event.Skip()
@@ -236,6 +237,6 @@
         self.Element = SFC_Transition(self.Preview)
         self.Element.SetType(*self.GetTransitionType())
         self.Element.SetPriority(self.Priority.GetValue())
-        
+
         # Call BlockPreviewDialog function
         BlockPreviewDialog.RefreshPreview(self)