65 # Create label for connection type |
65 # Create label for connection type |
66 type_label = wx.StaticText(self, label=_('Type:')) |
66 type_label = wx.StaticText(self, label=_('Type:')) |
67 left_gridsizer.AddWindow(type_label, flag=wx.GROW) |
67 left_gridsizer.AddWindow(type_label, flag=wx.GROW) |
68 |
68 |
69 # Create radio buttons for selecting connection type |
69 # Create radio buttons for selecting connection type |
70 self.ConnectionRadioButtons = {} |
70 self.TypeRadioButtons = {} |
71 first = True |
71 first = True |
72 for type, label in [(CONNECTOR, _('Connector')), |
72 for type, label in [(CONNECTOR, _('Connector')), |
73 (CONTINUATION, _('Continuation'))]: |
73 (CONTINUATION, _('Continuation'))]: |
74 radio_button = wx.RadioButton(self, label=label, |
74 radio_button = wx.RadioButton(self, label=label, |
75 style=(wx.RB_GROUP if first else wx.RB_SINGLE)) |
75 style=(wx.RB_GROUP if first else wx.RB_SINGLE)) |
76 radio_button.SetValue(first) |
76 radio_button.SetValue(first) |
77 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
77 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
78 left_gridsizer.AddWindow(radio_button, flag=wx.GROW) |
78 left_gridsizer.AddWindow(radio_button, flag=wx.GROW) |
79 self.ConnectionRadioButtons[type] = radio_button |
79 self.TypeRadioButtons[type] = radio_button |
80 first = False |
80 first = False |
81 |
81 |
82 # Create label for connection name |
82 # Create label for connection name |
83 name_label = wx.StaticText(self, label=_('Name:')) |
83 name_label = wx.StaticText(self, label=_('Name:')) |
84 left_gridsizer.AddWindow(name_label, flag=wx.GROW) |
84 left_gridsizer.AddWindow(name_label, flag=wx.GROW) |
118 tagname, None, "Connection%d", 0)) |
118 tagname, None, "Connection%d", 0)) |
119 |
119 |
120 self.SetSizer(main_sizer) |
120 self.SetSizer(main_sizer) |
121 |
121 |
122 # Connector radio button is default control having keyboard focus |
122 # Connector radio button is default control having keyboard focus |
123 self.ConnectionRadioButtons[CONNECTOR].SetFocus() |
123 self.TypeRadioButtons[CONNECTOR].SetFocus() |
124 |
124 |
125 def SetValues(self, values): |
125 def SetValues(self, values): |
126 """ |
126 """ |
127 Set default connection parameters |
127 Set default connection parameters |
128 @param values: Connection parameters values |
128 @param values: Connection parameters values |
130 # For each parameters defined, set corresponding control value |
130 # For each parameters defined, set corresponding control value |
131 for name, value in values.items(): |
131 for name, value in values.items(): |
132 |
132 |
133 # Parameter is connection type |
133 # Parameter is connection type |
134 if name == "type": |
134 if name == "type": |
135 self.ConnectionRadioButtons[value].SetValue(True) |
135 self.TypeRadioButtons[value].SetValue(True) |
136 |
136 |
137 # Parameter is connection name |
137 # Parameter is connection name |
138 elif name == "name": |
138 elif name == "name": |
139 self.ConnectionName.SetValue(value) |
139 self.ConnectionName.SetValue(value) |
140 |
140 |
146 Return connection parameters defined in dialog |
146 Return connection parameters defined in dialog |
147 @return: {parameter_name: parameter_value,...} |
147 @return: {parameter_name: parameter_value,...} |
148 """ |
148 """ |
149 values = { |
149 values = { |
150 "type": (CONNECTOR |
150 "type": (CONNECTOR |
151 if self.ConnectionRadioButtons[CONNECTOR].GetValue() |
151 if self.TypeRadioButtons[CONNECTOR].GetValue() |
152 else CONTINUATION), |
152 else CONTINUATION), |
153 "name": self.ConnectionName.GetValue()} |
153 "name": self.ConnectionName.GetValue()} |
154 values["width"], values["height"] = self.Element.GetSize() |
154 values["width"], values["height"] = self.Element.GetSize() |
155 return values |
155 return values |
156 |
156 |
219 Override BlockPreviewDialog function |
219 Override BlockPreviewDialog function |
220 """ |
220 """ |
221 # Set graphic element displayed, creating a FBD connection element |
221 # Set graphic element displayed, creating a FBD connection element |
222 self.Element = FBD_Connector(self.Preview, |
222 self.Element = FBD_Connector(self.Preview, |
223 (CONNECTOR |
223 (CONNECTOR |
224 if self.ConnectionRadioButtons[CONNECTOR].GetValue() |
224 if self.TypeRadioButtons[CONNECTOR].GetValue() |
225 else CONTINUATION), |
225 else CONTINUATION), |
226 self.ConnectionName.GetValue()) |
226 self.ConnectionName.GetValue()) |
227 |
227 |
228 # Call BlockPreviewDialog function |
228 # Call BlockPreviewDialog function |
229 BlockPreviewDialog.RefreshPreview(self) |
229 BlockPreviewDialog.RefreshPreview(self) |