49 to all connector having the same name in POU (default: False) |
49 to all connector having the same name in POU (default: False) |
50 """ |
50 """ |
51 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
51 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
52 size=wx.Size(350, 220), title=_('Connection Properties')) |
52 size=wx.Size(350, 220), title=_('Connection Properties')) |
53 |
53 |
54 # Create dialog main sizer |
54 # Init common sizers |
55 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
55 self._init_sizers(2, 0, 5, None, 2, 1) |
56 main_sizer.AddGrowableCol(0) |
|
57 main_sizer.AddGrowableRow(0) |
|
58 |
|
59 # Create a sizer for dividing FBD connection parameters in two columns |
|
60 column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
61 main_sizer.AddSizer(column_sizer, border=20, |
|
62 flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
63 |
|
64 # Create a sizer for left column |
|
65 left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) |
|
66 left_gridsizer.AddGrowableCol(0) |
|
67 column_sizer.AddSizer(left_gridsizer, 1, border=5, |
|
68 flag=wx.GROW|wx.RIGHT) |
|
69 |
56 |
70 # Create label for connection type |
57 # Create label for connection type |
71 type_label = wx.StaticText(self, label=_('Type:')) |
58 type_label = wx.StaticText(self, label=_('Type:')) |
72 left_gridsizer.AddWindow(type_label, flag=wx.GROW) |
59 self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW) |
73 |
60 |
74 # Create radio buttons for selecting connection type |
61 # Create radio buttons for selecting connection type |
75 self.TypeRadioButtons = {} |
62 self.TypeRadioButtons = {} |
76 first = True |
63 first = True |
77 for type, label in [(CONNECTOR, _('Connector')), |
64 for type, label in [(CONNECTOR, _('Connector')), |
78 (CONTINUATION, _('Continuation'))]: |
65 (CONTINUATION, _('Continuation'))]: |
79 radio_button = wx.RadioButton(self, label=label, |
66 radio_button = wx.RadioButton(self, label=label, |
80 style=(wx.RB_GROUP if first else 0)) |
67 style=(wx.RB_GROUP if first else 0)) |
81 radio_button.SetValue(first) |
68 radio_button.SetValue(first) |
82 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
69 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
83 left_gridsizer.AddWindow(radio_button, flag=wx.GROW) |
70 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
84 self.TypeRadioButtons[type] = radio_button |
71 self.TypeRadioButtons[type] = radio_button |
85 first = False |
72 first = False |
86 |
73 |
87 # Create label for connection name |
74 # Create label for connection name |
88 name_label = wx.StaticText(self, label=_('Name:')) |
75 name_label = wx.StaticText(self, label=_('Name:')) |
89 left_gridsizer.AddWindow(name_label, flag=wx.GROW) |
76 self.LeftGridSizer.AddWindow(name_label, flag=wx.GROW) |
90 |
77 |
91 # Create text control for defining connection name |
78 # Create text control for defining connection name |
92 self.ConnectionName = wx.TextCtrl(self) |
79 self.ConnectionName = wx.TextCtrl(self) |
93 self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName) |
80 self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName) |
94 left_gridsizer.AddWindow(self.ConnectionName, flag=wx.GROW) |
81 self.LeftGridSizer.AddWindow(self.ConnectionName, flag=wx.GROW) |
95 |
|
96 # Create a sizer for right column |
|
97 right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
|
98 right_gridsizer.AddGrowableCol(0) |
|
99 right_gridsizer.AddGrowableRow(1) |
|
100 column_sizer.AddSizer(right_gridsizer, 1, border=5, |
|
101 flag=wx.GROW|wx.LEFT) |
|
102 |
82 |
103 # Add preview panel and associated label to sizers |
83 # Add preview panel and associated label to sizers |
104 right_gridsizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
84 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
105 right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) |
85 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
106 |
86 |
107 # Add buttons sizer to sizers |
87 # Add buttons sizer to sizers |
108 main_sizer.AddSizer(self.ButtonSizer, border=20, |
88 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
109 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
89 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
110 |
90 |
111 # Add button for applying connection name modification to all connection |
91 # Add button for applying connection name modification to all connection |
112 # of POU |
92 # of POU |
113 if apply_button: |
93 if apply_button: |