57 # Init common sizers |
57 # Init common sizers |
58 self._init_sizers(2, 0, 7, 1, 0, None) |
58 self._init_sizers(2, 0, 7, 1, 0, None) |
59 |
59 |
60 # Create label for connection type |
60 # Create label for connection type |
61 type_label = wx.StaticText(self, label=_('Type:')) |
61 type_label = wx.StaticText(self, label=_('Type:')) |
62 self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW) |
62 self.LeftGridSizer.Add(type_label, flag=wx.GROW) |
63 |
63 |
64 # Create radio buttons for selecting connection type |
64 # Create radio buttons for selecting connection type |
65 self.TypeRadioButtons = {} |
65 self.TypeRadioButtons = {} |
66 first = True |
66 first = True |
67 for type, label in [(CONNECTOR, _('Connector')), |
67 for type, label in [(CONNECTOR, _('Connector')), |
68 (CONTINUATION, _('Continuation'))]: |
68 (CONTINUATION, _('Continuation'))]: |
69 radio_button = wx.RadioButton(self, label=label, |
69 radio_button = wx.RadioButton(self, label=label, |
70 style=(wx.RB_GROUP if first else 0)) |
70 style=(wx.RB_GROUP if first else 0)) |
71 radio_button.SetValue(first) |
71 radio_button.SetValue(first) |
72 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
72 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
73 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
73 self.LeftGridSizer.Add(radio_button, flag=wx.GROW) |
74 self.TypeRadioButtons[type] = radio_button |
74 self.TypeRadioButtons[type] = radio_button |
75 first = False |
75 first = False |
76 |
76 |
77 # Create label for connection name |
77 # Create label for connection name |
78 name_label = wx.StaticText(self, label=_('Name:')) |
78 name_label = wx.StaticText(self, label=_('Name:')) |
79 self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW) |
79 self.LeftGridSizer.Add(name_label, flag=wx.GROW) |
80 |
80 |
81 # Create text control for defining connection name |
81 # Create text control for defining connection name |
82 self.ConnectionName = wx.TextCtrl(self) |
82 self.ConnectionName = wx.TextCtrl(self) |
83 self.ConnectionName.SetMinSize(wx.Size(200, -1)) |
83 self.ConnectionName.SetMinSize(wx.Size(200, -1)) |
84 self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName) |
84 self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName) |
85 self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW) |
85 self.LeftGridSizer.Add(self.ConnectionName, flag=wx.GROW) |
86 |
86 |
87 # Add preview panel and associated label to sizers |
87 # Add preview panel and associated label to sizers |
88 self.Preview.SetMinSize(wx.Size(-1, 100)) |
88 self.Preview.SetMinSize(wx.Size(-1, 100)) |
89 self.LeftGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
89 self.LeftGridSizer.Add(self.PreviewLabel, flag=wx.GROW) |
90 self.LeftGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
90 self.LeftGridSizer.Add(self.Preview, flag=wx.GROW) |
91 |
91 |
92 # Add buttons sizer to sizers |
92 # Add buttons sizer to sizers |
93 self.MainSizer.AddSizer( |
93 self.MainSizer.Add( |
94 self.ButtonSizer, border=20, |
94 self.ButtonSizer, border=20, |
95 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
95 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
96 self.ColumnSizer.RemoveSizer(self.RightGridSizer) |
96 self.ColumnSizer.RemoveSizer(self.RightGridSizer) |
97 |
97 |
98 # Add button for applying connection name modification to all connection |
98 # Add button for applying connection name modification to all connection |
99 # of POU |
99 # of POU |
100 if apply_button: |
100 if apply_button: |
101 self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name")) |
101 self.ApplyToAllButton = wx.Button(self, label=_("Propagate Name")) |
102 self.ApplyToAllButton.SetToolTipString( |
102 self.ApplyToAllButton.SetToolTip( |
103 _("Apply name modification to all continuations with the same name")) |
103 _("Apply name modification to all continuations with the same name")) |
104 self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton) |
104 self.Bind(wx.EVT_BUTTON, self.OnApplyToAll, self.ApplyToAllButton) |
105 self.ButtonSizer.AddWindow(self.ApplyToAllButton, flag=wx.LEFT) |
105 self.ButtonSizer.Add(self.ApplyToAllButton, flag=wx.LEFT) |
106 else: |
106 else: |
107 self.ConnectionName.ChangeValue( |
107 self.ConnectionName.ChangeValue( |
108 controller.GenerateNewName( |
108 controller.GenerateNewName( |
109 tagname, None, "Connection%d", 0)) |
109 tagname, None, "Connection%d", 0)) |
110 self.Fit() |
110 self.Fit() |