49 @param controller: Reference to project controller |
49 @param controller: Reference to project controller |
50 @param tagname: Tagname of project POU edited |
50 @param tagname: Tagname of project POU edited |
51 @param type: Type of LD element ('contact or 'coil') |
51 @param type: Type of LD element ('contact or 'coil') |
52 """ |
52 """ |
53 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
53 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
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 # Init common sizers |
58 # Init common sizers |
59 self._init_sizers(2, 0, |
59 self._init_sizers(2, 0, (7 if type == "contact" else 9), |
60 (7 if type == "contact" else 9), None, 2, 1) |
60 None, 2, 1) |
61 |
61 |
62 # Create label for LD element modifier |
62 # Create label for LD element modifier |
63 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
63 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
64 self.LeftGridSizer.AddWindow(modifier_label, border=5, |
64 self.LeftGridSizer.AddWindow(modifier_label, border=5, |
65 flag=wx.GROW | wx.BOTTOM) |
65 flag=wx.GROW | wx.BOTTOM) |
66 |
66 |
67 # Create radio buttons for selecting LD element modifier |
67 # Create radio buttons for selecting LD element modifier |
68 self.ModifierRadioButtons = {} |
68 self.ModifierRadioButtons = {} |
69 first = True |
69 first = True |
70 element_modifiers = ([CONTACT_NORMAL, CONTACT_REVERSE, |
70 element_modifiers = ([CONTACT_NORMAL, CONTACT_REVERSE, |
77 ([_("Set"), _("Reset")] if type == "coil" else []) + \ |
77 ([_("Set"), _("Reset")] if type == "coil" else []) + \ |
78 [_("Rising Edge"), _("Falling Edge")] |
78 [_("Rising Edge"), _("Falling Edge")] |
79 |
79 |
80 for modifier, label in zip(element_modifiers, modifiers_label): |
80 for modifier, label in zip(element_modifiers, modifiers_label): |
81 radio_button = wx.RadioButton(self, label=label, |
81 radio_button = wx.RadioButton(self, label=label, |
82 style=(wx.RB_GROUP if first else 0)) |
82 style=(wx.RB_GROUP if first else 0)) |
83 radio_button.SetValue(first) |
83 radio_button.SetValue(first) |
84 self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button) |
84 self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button) |
85 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
85 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
86 self.ModifierRadioButtons[modifier] = radio_button |
86 self.ModifierRadioButtons[modifier] = radio_button |
87 first = False |
87 first = False |
88 |
88 |
89 # Create label for LD element variable |
89 # Create label for LD element variable |
90 element_variable_label = wx.StaticText(self, label=_('Variable:')) |
90 element_variable_label = wx.StaticText(self, label=_('Variable:')) |
91 self.LeftGridSizer.AddWindow(element_variable_label, border=5, |
91 self.LeftGridSizer.AddWindow(element_variable_label, border=5, |
92 flag=wx.GROW | wx.TOP) |
92 flag=wx.GROW | wx.TOP) |
93 |
93 |
94 # Create a combo box for defining LD element variable |
94 # Create a combo box for defining LD element variable |
95 self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT) |
95 self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT) |
96 self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, |
96 self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, |
97 self.ElementVariable) |
97 self.ElementVariable) |
98 self.Bind(wx.EVT_TEXT, self.OnVariableChanged, |
98 self.Bind(wx.EVT_TEXT, self.OnVariableChanged, |
99 self.ElementVariable) |
99 self.ElementVariable) |
100 self.LeftGridSizer.AddWindow(self.ElementVariable, border=5, |
100 self.LeftGridSizer.AddWindow(self.ElementVariable, border=5, |
101 flag=wx.GROW | wx.TOP) |
101 flag=wx.GROW | wx.TOP) |
102 |
102 |
103 # Add preview panel and associated label to sizers |
103 # Add preview panel and associated label to sizers |
104 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
104 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
105 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
105 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
106 |
106 |
107 # Add buttons sizer to sizers |
107 # Add buttons sizer to sizers |
108 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
108 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
109 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
109 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
110 |
110 |
111 # Save LD element class |
111 # Save LD element class |
112 self.ElementClass = (LD_Contact if type == "contact" else LD_Coil) |
112 self.ElementClass = (LD_Contact if type == "contact" else LD_Coil) |
113 |
113 |
114 # Extract list of variables defined in POU |
114 # Extract list of variables defined in POU |