61 self._init_sizers(2, 0, (7 if type == "contact" else 9), |
61 self._init_sizers(2, 0, (7 if type == "contact" else 9), |
62 None, 2, 1) |
62 None, 2, 1) |
63 |
63 |
64 # Create label for LD element modifier |
64 # Create label for LD element modifier |
65 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
65 modifier_label = wx.StaticText(self, label=_('Modifier:')) |
66 self.LeftGridSizer.AddWindow(modifier_label, border=5, |
66 self.LeftGridSizer.Add(modifier_label, border=5, |
67 flag=wx.GROW | wx.BOTTOM) |
67 flag=wx.GROW | wx.BOTTOM) |
68 |
68 |
69 # Create radio buttons for selecting LD element modifier |
69 # Create radio buttons for selecting LD element modifier |
70 self.ModifierRadioButtons = {} |
70 self.ModifierRadioButtons = {} |
71 first = True |
71 first = True |
82 for modifier, label in zip(element_modifiers, modifiers_label): |
82 for modifier, label in zip(element_modifiers, modifiers_label): |
83 radio_button = wx.RadioButton(self, label=label, |
83 radio_button = wx.RadioButton(self, label=label, |
84 style=(wx.RB_GROUP if first else 0)) |
84 style=(wx.RB_GROUP if first else 0)) |
85 radio_button.SetValue(first) |
85 radio_button.SetValue(first) |
86 self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button) |
86 self.Bind(wx.EVT_RADIOBUTTON, self.OnModifierChanged, radio_button) |
87 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
87 self.LeftGridSizer.Add(radio_button, flag=wx.GROW) |
88 self.ModifierRadioButtons[modifier] = radio_button |
88 self.ModifierRadioButtons[modifier] = radio_button |
89 first = False |
89 first = False |
90 |
90 |
91 # Create label for LD element variable |
91 # Create label for LD element variable |
92 element_variable_label = wx.StaticText(self, label=_('Variable:')) |
92 element_variable_label = wx.StaticText(self, label=_('Variable:')) |
93 self.LeftGridSizer.AddWindow(element_variable_label, border=5, |
93 self.LeftGridSizer.Add(element_variable_label, border=5, |
94 flag=wx.GROW | wx.TOP) |
94 flag=wx.GROW | wx.TOP) |
95 |
95 |
96 # Create a combo box for defining LD element variable |
96 # Create a combo box for defining LD element variable |
97 self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT) |
97 self.ElementVariable = wx.ComboBox(self, style=wx.CB_SORT) |
98 self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, |
98 self.Bind(wx.EVT_COMBOBOX, self.OnVariableChanged, |
99 self.ElementVariable) |
99 self.ElementVariable) |
100 self.Bind(wx.EVT_TEXT, self.OnVariableChanged, |
100 self.Bind(wx.EVT_TEXT, self.OnVariableChanged, |
101 self.ElementVariable) |
101 self.ElementVariable) |
102 self.LeftGridSizer.AddWindow(self.ElementVariable, border=5, |
102 self.LeftGridSizer.Add(self.ElementVariable, border=5, |
103 flag=wx.GROW | wx.TOP) |
103 flag=wx.GROW | wx.TOP) |
104 |
104 |
105 # Add preview panel and associated label to sizers |
105 # Add preview panel and associated label to sizers |
106 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
106 self.RightGridSizer.Add(self.PreviewLabel, flag=wx.GROW) |
107 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
107 self.RightGridSizer.Add(self.Preview, flag=wx.GROW) |
108 |
108 |
109 # Add buttons sizer to sizers |
109 # Add buttons sizer to sizers |
110 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
110 self.MainSizer.Add(self.ButtonSizer, border=20, |
111 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
111 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
112 |
112 |
113 # Save LD element class |
113 # Save LD element class |
114 self.ElementClass = (LD_Contact if type == "contact" else LD_Coil) |
114 self.ElementClass = (LD_Contact if type == "contact" else LD_Coil) |
115 |
115 |
196 self.Element = self.ElementClass( |
196 self.Element = self.ElementClass( |
197 self.Preview, |
197 self.Preview, |
198 self.GetElementModifier(), |
198 self.GetElementModifier(), |
199 value) |
199 value) |
200 |
200 |
201 button = self.ButtonSizer.GetAffirmativeButton() |
201 # FIXME : how to disable OK button when content is not valid |
202 button.Enable(value != "") |
202 # button = self.ButtonSizer.GetAffirmativeButton() |
|
203 # button.Enable(value != "") |
203 |
204 |
204 # Call BlockPreviewDialog function |
205 # Call BlockPreviewDialog function |
205 BlockPreviewDialog.DrawPreview(self) |
206 BlockPreviewDialog.DrawPreview(self) |
206 |
207 |
207 def OnOK(self, event): |
208 def OnOK(self, event): |