45 @param parent: Parent wx.Window of dialog for modal |
45 @param parent: Parent wx.Window of dialog for modal |
46 @param controller: Reference to project controller |
46 @param controller: Reference to project controller |
47 @param tagname: Tagname of project POU edited |
47 @param tagname: Tagname of project POU edited |
48 """ |
48 """ |
49 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
49 BlockPreviewDialog.__init__(self, parent, controller, tagname, |
50 title=_('Power Rail Properties')) |
50 title=_('Power Rail Properties')) |
51 |
51 |
52 # Init common sizers |
52 # Init common sizers |
53 self._init_sizers(2, 0, 5, None, 2, 1) |
53 self._init_sizers(2, 0, 5, None, 2, 1) |
54 |
54 |
55 # Create label for connection type |
55 # Create label for connection type |
60 self.TypeRadioButtons = {} |
60 self.TypeRadioButtons = {} |
61 first = True |
61 first = True |
62 for type, label in [(LEFTRAIL, _('Left PowerRail')), |
62 for type, label in [(LEFTRAIL, _('Left PowerRail')), |
63 (RIGHTRAIL, _('Right PowerRail'))]: |
63 (RIGHTRAIL, _('Right PowerRail'))]: |
64 radio_button = wx.RadioButton(self, label=label, |
64 radio_button = wx.RadioButton(self, label=label, |
65 style=(wx.RB_GROUP if first else 0)) |
65 style=(wx.RB_GROUP if first else 0)) |
66 radio_button.SetValue(first) |
66 radio_button.SetValue(first) |
67 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
67 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button) |
68 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
68 self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW) |
69 self.TypeRadioButtons[type] = radio_button |
69 self.TypeRadioButtons[type] = radio_button |
70 first = False |
70 first = False |
73 pin_number_label = wx.StaticText(self, label=_('Pin number:')) |
73 pin_number_label = wx.StaticText(self, label=_('Pin number:')) |
74 self.LeftGridSizer.AddWindow(pin_number_label, flag=wx.GROW) |
74 self.LeftGridSizer.AddWindow(pin_number_label, flag=wx.GROW) |
75 |
75 |
76 # Create spin control for defining power rail pin number |
76 # Create spin control for defining power rail pin number |
77 self.PinNumber = wx.SpinCtrl(self, min=1, max=50, |
77 self.PinNumber = wx.SpinCtrl(self, min=1, max=50, |
78 style=wx.SP_ARROW_KEYS) |
78 style=wx.SP_ARROW_KEYS) |
79 self.PinNumber.SetValue(1) |
79 self.PinNumber.SetValue(1) |
80 self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber) |
80 self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber) |
81 self.LeftGridSizer.AddWindow(self.PinNumber, flag=wx.GROW) |
81 self.LeftGridSizer.AddWindow(self.PinNumber, flag=wx.GROW) |
82 |
82 |
83 # Add preview panel and associated label to sizers |
83 # Add preview panel and associated label to sizers |
84 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
84 self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW) |
85 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
85 self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW) |
86 |
86 |
87 # Add buttons sizer to sizers |
87 # Add buttons sizer to sizers |
88 self.MainSizer.AddSizer(self.ButtonSizer, border=20, |
88 self.MainSizer.AddSizer( |
89 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
89 self.ButtonSizer, border=20, |
|
90 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
90 self.Fit() |
91 self.Fit() |
91 |
92 |
92 # Left Power Rail radio button is default control having keyboard focus |
93 # Left Power Rail radio button is default control having keyboard focus |
93 self.TypeRadioButtons[LEFTRAIL].SetFocus() |
94 self.TypeRadioButtons[LEFTRAIL].SetFocus() |
94 |
95 |
158 Override BlockPreviewDialog function |
159 Override BlockPreviewDialog function |
159 """ |
160 """ |
160 |
161 |
161 # Set graphic element displayed, creating a power rail element |
162 # Set graphic element displayed, creating a power rail element |
162 self.Element = LD_PowerRail(self.Preview, |
163 self.Element = LD_PowerRail(self.Preview, |
163 self.GetPowerRailType(), |
164 self.GetPowerRailType(), |
164 connectors=self.PinNumber.GetValue()) |
165 connectors=self.PinNumber.GetValue()) |
165 |
166 |
166 # Call BlockPreviewDialog function |
167 # Call BlockPreviewDialog function |
167 BlockPreviewDialog.RefreshPreview(self) |
168 BlockPreviewDialog.RefreshPreview(self) |