72 self.LibraryPanel = LibraryPanel(self) |
72 self.LibraryPanel = LibraryPanel(self) |
73 self.LibraryPanel.SetInitialSize(wx.Size(-1, 400)) |
73 self.LibraryPanel.SetInitialSize(wx.Size(-1, 400)) |
74 |
74 |
75 # Set function to call when selection in Library panel changed |
75 # Set function to call when selection in Library panel changed |
76 setattr(self.LibraryPanel, "_OnTreeItemSelected", |
76 setattr(self.LibraryPanel, "_OnTreeItemSelected", |
77 self.OnLibraryTreeItemSelected) |
77 self.OnLibraryTreeItemSelected) |
78 left_staticboxsizer.AddWindow(self.LibraryPanel, 1, border=5, |
78 left_staticboxsizer.AddWindow(self.LibraryPanel, 1, border=5, |
79 flag=wx.GROW | wx.TOP) |
79 flag=wx.GROW | wx.TOP) |
80 |
80 |
81 # Create sizer for other block parameters |
81 # Create sizer for other block parameters |
82 top_right_gridsizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=5) |
82 top_right_gridsizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=5) |
83 top_right_gridsizer.AddGrowableCol(1) |
83 top_right_gridsizer.AddGrowableCol(1) |
84 self.RightGridSizer.AddSizer(top_right_gridsizer, flag=wx.GROW) |
84 self.RightGridSizer.AddSizer(top_right_gridsizer, flag=wx.GROW) |
85 |
85 |
86 # Create label for block name |
86 # Create label for block name |
87 name_label = wx.StaticText(self, label=_('Name:')) |
87 name_label = wx.StaticText(self, label=_('Name:')) |
88 top_right_gridsizer.AddWindow(name_label, |
88 top_right_gridsizer.AddWindow(name_label, |
89 flag=wx.ALIGN_CENTER_VERTICAL) |
89 flag=wx.ALIGN_CENTER_VERTICAL) |
90 |
90 |
91 # Create text control for defining block name |
91 # Create text control for defining block name |
92 self.BlockName = wx.TextCtrl(self) |
92 self.BlockName = wx.TextCtrl(self) |
93 self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.BlockName) |
93 self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.BlockName) |
94 top_right_gridsizer.AddWindow(self.BlockName, flag=wx.GROW) |
94 top_right_gridsizer.AddWindow(self.BlockName, flag=wx.GROW) |
95 |
95 |
96 # Create label for extended block input number |
96 # Create label for extended block input number |
97 inputs_label = wx.StaticText(self, label=_('Inputs:')) |
97 inputs_label = wx.StaticText(self, label=_('Inputs:')) |
98 top_right_gridsizer.AddWindow(inputs_label, |
98 top_right_gridsizer.AddWindow(inputs_label, |
99 flag=wx.ALIGN_CENTER_VERTICAL) |
99 flag=wx.ALIGN_CENTER_VERTICAL) |
100 |
100 |
101 # Create spin control for defining extended block input number |
101 # Create spin control for defining extended block input number |
102 self.Inputs = wx.SpinCtrl(self, min=2, max=20, |
102 self.Inputs = wx.SpinCtrl(self, min=2, max=20, |
103 style=wx.SP_ARROW_KEYS) |
103 style=wx.SP_ARROW_KEYS) |
104 self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, self.Inputs) |
104 self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, self.Inputs) |
105 top_right_gridsizer.AddWindow(self.Inputs, flag=wx.GROW) |
105 top_right_gridsizer.AddWindow(self.Inputs, flag=wx.GROW) |
106 |
106 |
107 # Create label for block execution order |
107 # Create label for block execution order |
108 execution_order_label = wx.StaticText(self, |
108 execution_order_label = wx.StaticText(self, |
109 label=_('Execution Order:')) |
109 label=_('Execution Order:')) |
110 top_right_gridsizer.AddWindow(execution_order_label, |
110 top_right_gridsizer.AddWindow(execution_order_label, |
111 flag=wx.ALIGN_CENTER_VERTICAL) |
111 flag=wx.ALIGN_CENTER_VERTICAL) |
112 |
112 |
113 # Create spin control for defining block execution order |
113 # Create spin control for defining block execution order |
114 self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS) |
114 self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS) |
115 self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, |
115 self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, |
116 self.ExecutionOrder) |
116 self.ExecutionOrder) |
117 top_right_gridsizer.AddWindow(self.ExecutionOrder, flag=wx.GROW) |
117 top_right_gridsizer.AddWindow(self.ExecutionOrder, flag=wx.GROW) |
118 |
118 |
119 # Create label for block execution control |
119 # Create label for block execution control |
120 execution_control_label = wx.StaticText(self, |
120 execution_control_label = wx.StaticText(self, |
121 label=_('Execution Control:')) |
121 label=_('Execution Control:')) |
122 top_right_gridsizer.AddWindow(execution_control_label, |
122 top_right_gridsizer.AddWindow(execution_control_label, |
123 flag=wx.ALIGN_CENTER_VERTICAL) |
123 flag=wx.ALIGN_CENTER_VERTICAL) |
124 |
124 |
125 # Create check box to enable block execution control |
125 # Create check box to enable block execution control |
126 self.ExecutionControl = wx.CheckBox(self) |
126 self.ExecutionControl = wx.CheckBox(self) |
127 self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, |
127 self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, |
128 self.ExecutionControl) |
128 self.ExecutionControl) |
338 values = self.LibraryPanel.GetSelectedBlock() |
338 values = self.LibraryPanel.GetSelectedBlock() |
339 |
339 |
340 # If a block type is selected in library panel |
340 # If a block type is selected in library panel |
341 if values is not None: |
341 if values is not None: |
342 # Set graphic element displayed, creating a FBD block element |
342 # Set graphic element displayed, creating a FBD block element |
343 self.Element = FBD_Block(self.Preview, values["type"], |
343 self.Element = FBD_Block( |
344 (self.BlockName.GetValue() |
344 self.Preview, values["type"], |
345 if self.BlockName.IsEnabled() |
345 (self.BlockName.GetValue() if self.BlockName.IsEnabled() else ""), |
346 else ""), |
346 extension=self.Inputs.GetValue(), |
347 extension=self.Inputs.GetValue(), |
347 inputs=values["inputs"], |
348 inputs=values["inputs"], |
348 executionControl=self.ExecutionControl.GetValue(), |
349 executionControl=self.ExecutionControl.GetValue(), |
349 executionOrder=self.ExecutionOrder.GetValue()) |
350 executionOrder=self.ExecutionOrder.GetValue()) |
|
351 |
350 |
352 # Reset graphic element displayed |
351 # Reset graphic element displayed |
353 else: |
352 else: |
354 self.Element = None |
353 self.Element = None |
355 |
354 |