53 size=wx.Size(350, 260 if type == "contact" else 310), |
53 size=wx.Size(350, 260 if type == "contact" else 310), |
54 title=(_("Edit Contact Values") |
54 title=(_("Edit Contact Values") |
55 if type == "contact" |
55 if type == "contact" |
56 else _("Edit Coil Values"))) |
56 else _("Edit Coil Values"))) |
57 |
57 |
58 # Create dialog main sizer |
58 # Init common sizers |
59 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
59 self._init_sizers(2, 0, |
60 main_sizer.AddGrowableCol(0) |
60 (7 if type == "contact" else 9), None, 2, 1) |
61 main_sizer.AddGrowableRow(0) |
|
62 |
|
63 # Create a sizer for dividing LD element parameters in two columns |
|
64 column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
65 main_sizer.AddSizer(column_sizer, border=20, |
|
66 flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
67 |
|
68 # Create a sizer for left column |
|
69 left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, |
|
70 rows=(7 if type == "contact" else 9), vgap=0) |
|
71 left_gridsizer.AddGrowableCol(0) |
|
72 column_sizer.AddSizer(left_gridsizer, 1, border=5, |
|
73 flag=wx.GROW|wx.RIGHT) |
|
74 |
61 |
75 # Create label for LD element modifier |
62 # Create label for LD element modifier |
76 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
63 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
77 left_gridsizer.AddWindow(modifier_label, border=5, |
64 self.LeftGridSizer.AddWindow(modifier_label, border=5, |
78 flag=wx.GROW|wx.BOTTOM) |
65 flag=wx.GROW|wx.BOTTOM) |
79 |
66 |
80 # Create radio buttons for selecting LD element modifier |
67 # Create radio buttons for selecting LD element modifier |
81 self.ModifierRadioButtons = {} |
68 self.ModifierRadioButtons = {} |
82 first = True |
69 first = True |
92 for modifier, label in zip(element_modifiers, modifiers_label): |
79 for modifier, label in zip(element_modifiers, modifiers_label): |
93 radio_button = wx.RadioButton(self, label=label, |
80 radio_button = wx.RadioButton(self, label=label, |
94 style=(wx.RB_GROUP if first else 0)) |
81 style=(wx.RB_GROUP if first else 0)) |
95 radio_button.SetValue(first) |
82 radio_button.SetValue(first) |
96 self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button) |
83 self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button) |
97 left_gridsizer.AddWindow(radio_button, |
84 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
98 border=(5 if not first and wx.Platform == '__WXMSW__' else 0), |
|
99 flag=wx.GROW|wx.TOP) |
|
100 self.ModifierRadioButtons[modifier] = radio_button |
85 self.ModifierRadioButtons[modifier] = radio_button |
101 first = False |
86 first = False |
102 |
87 |
103 # Create label for LD element variable |
88 # Create label for LD element variable |
104 element_variable_label = wx.StaticText(self, label=_('Variable:')) |
89 element_variable_label = wx.StaticText(self, label=_('Variable:')) |
105 left_gridsizer.AddWindow(element_variable_label, border=5, |
90 self.LeftGridSizer.AddWindow(element_variable_label, border=5, |
106 flag=wx.GROW|wx.TOP) |
91 flag=wx.GROW|wx.TOP) |
107 |
92 |
108 # Create a combo box for defining LD element variable |
93 # Create a combo box for defining LD element variable |
109 self.ElementVariable = wx.ComboBox(self, style=wx.CB_READONLY) |
94 self.ElementVariable = wx.ComboBox(self, style=wx.CB_READONLY) |
110 self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, |
95 self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, |
111 self.ElementVariable) |
96 self.ElementVariable) |
112 left_gridsizer.AddWindow(self.ElementVariable, border=5, |
97 self.LeftGridSizer.AddWindow(self.ElementVariable, border=5, |
113 flag=wx.GROW|wx.TOP) |
98 flag=wx.GROW|wx.TOP) |
114 |
99 |
115 # Create a sizer for right column |
|
116 right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
|
117 right_gridsizer.AddGrowableCol(0) |
|
118 right_gridsizer.AddGrowableRow(1) |
|
119 column_sizer.AddSizer(right_gridsizer, 1, border=5, |
|
120 flag=wx.GROW|wx.LEFT) |
|
121 |
|
122 # Add preview panel and associated label to sizers |
100 # Add preview panel and associated label to sizers |
123 right_gridsizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
101 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
124 right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) |
102 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
125 |
103 |
126 # Add buttons sizer to sizers |
104 # Add buttons sizer to sizers |
127 main_sizer.AddSizer(self.ButtonSizer, border=20, |
105 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
128 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
106 flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
129 |
|
130 self.SetSizer(main_sizer) |
|
131 |
107 |
132 # Save LD element class |
108 # Save LD element class |
133 self.ElementClass = (LD_Contact if type == "contact" else LD_Coil) |
109 self.ElementClass = (LD_Contact if type == "contact" else LD_Coil) |
134 |
110 |
135 # Extract list of variables defined in POU |
111 # Extract list of variables defined in POU |