32 #------------------------------------------------------------------------------- |
32 #------------------------------------------------------------------------------- |
33 |
33 |
34 [ID_BLOCKPROPERTIESDIALOG, ID_BLOCKPROPERTIESDIALOGNAME, |
34 [ID_BLOCKPROPERTIESDIALOG, ID_BLOCKPROPERTIESDIALOGNAME, |
35 ID_BLOCKPROPERTIESDIALOGTYPETREE, ID_BLOCKPROPERTIESDIALOGTYPEDESC, |
35 ID_BLOCKPROPERTIESDIALOGTYPETREE, ID_BLOCKPROPERTIESDIALOGTYPEDESC, |
36 ID_BLOCKPROPERTIESDIALOGINPUTS, ID_BLOCKPROPERTIESDIALOGPREVIEW, |
36 ID_BLOCKPROPERTIESDIALOGINPUTS, ID_BLOCKPROPERTIESDIALOGPREVIEW, |
37 ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, |
37 ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL, |
38 ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, |
38 ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
39 ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, |
39 ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
40 ] = [wx.NewId() for _init_ctrls in range(12)] |
40 ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, ID_BLOCKPROPERTIESDIALOGSTATICTEXT6, |
|
41 ] = [wx.NewId() for _init_ctrls in range(14)] |
41 |
42 |
42 [CATEGORY, BLOCK] = range(2) |
43 [CATEGORY, BLOCK] = range(2) |
43 |
44 |
44 class BlockPropertiesDialog(wx.Dialog): |
45 class BlockPropertiesDialog(wx.Dialog): |
45 |
46 |
66 parent.AddWindow(self.TypeTree, 3, border=5, flag=wx.GROW|wx.BOTTOM) |
67 parent.AddWindow(self.TypeTree, 3, border=5, flag=wx.GROW|wx.BOTTOM) |
67 parent.AddWindow(self.TypeDesc, 1, border=0, flag=wx.GROW) |
68 parent.AddWindow(self.TypeDesc, 1, border=0, flag=wx.GROW) |
68 |
69 |
69 def _init_coll_RightGridSizer_Items(self, parent): |
70 def _init_coll_RightGridSizer_Items(self, parent): |
70 parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW) |
71 parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW) |
71 parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW) |
72 parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW) |
72 parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
73 parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
73 |
74 |
74 def _init_coll_RightGridSizer_Growables(self, parent): |
75 def _init_coll_RightGridSizer_Growables(self, parent): |
75 parent.AddGrowableCol(0) |
76 parent.AddGrowableCol(0) |
76 parent.AddGrowableRow(2) |
77 parent.AddGrowableRow(2) |
80 parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW) |
81 parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW) |
81 parent.AddWindow(self.staticText3, 0, border=4, flag=wx.GROW|wx.TOP) |
82 parent.AddWindow(self.staticText3, 0, border=4, flag=wx.GROW|wx.TOP) |
82 parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW) |
83 parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW) |
83 parent.AddWindow(self.staticText4, 0, border=4, flag=wx.GROW|wx.TOP) |
84 parent.AddWindow(self.staticText4, 0, border=4, flag=wx.GROW|wx.TOP) |
84 parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW) |
85 parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW) |
|
86 parent.AddWindow(self.staticText5, 0, border=4, flag=wx.GROW|wx.TOP) |
|
87 parent.AddWindow(self.ExecutionControl, 0, border=0, flag=wx.GROW) |
85 |
88 |
86 def _init_sizers(self): |
89 def _init_sizers(self): |
87 self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
90 self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
88 self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
91 self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
89 self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL) |
92 self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL) |
90 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
93 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
91 self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=3, vgap=5) |
94 self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=4, vgap=5) |
92 |
95 |
93 self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
96 self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
94 self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
97 self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
95 self._init_coll_MainSizer_Items(self.MainSizer) |
98 self._init_coll_MainSizer_Items(self.MainSizer) |
96 self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
99 self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
101 self.SetSizer(self.flexGridSizer1) |
104 self.SetSizer(self.flexGridSizer1) |
102 |
105 |
103 def _init_ctrls(self, prnt): |
106 def _init_ctrls(self, prnt): |
104 wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG, |
107 wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG, |
105 name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
108 name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
106 size=wx.Size(600, 380), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
109 size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
107 title='Block Properties') |
110 title='Block Properties') |
108 self.SetClientSize(wx.Size(600, 380)) |
111 self.SetClientSize(wx.Size(600, 400)) |
109 |
112 |
110 self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, |
113 self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, |
111 label='Type:', name='staticBox1', parent=self, |
114 label='Type:', name='staticBox1', parent=self, |
112 pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
115 pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
113 |
116 |
122 self.staticText4 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
125 self.staticText4 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
123 label='Execution Order:', name='staticText4', parent=self, |
126 label='Execution Order:', name='staticText4', parent=self, |
124 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
127 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
125 |
128 |
126 self.staticText5 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, |
129 self.staticText5 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, |
127 label='Preview:', name='staticText5', parent=self, |
130 label='Execution Control:', name='staticText5', parent=self, |
|
131 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
132 |
|
133 self.staticText6 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT6, |
|
134 label='Preview:', name='staticText6', parent=self, |
128 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
135 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
129 |
136 |
130 if wx.Platform == '__WXMSW__': |
137 if wx.Platform == '__WXMSW__': |
131 treestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
138 treestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
132 else: |
139 else: |
153 |
160 |
154 self.ExecutionOrder = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, |
161 self.ExecutionOrder = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, |
155 name='ExecutionOrder', parent=self, pos=wx.Point(0, 0), |
162 name='ExecutionOrder', parent=self, pos=wx.Point(0, 0), |
156 size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) |
163 size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) |
157 self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER) |
164 self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER) |
|
165 |
|
166 self.ExecutionControl = wx.CheckBox(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL, |
|
167 name='ExecutionControl', parent=self, pos=wx.Point(0, 0), |
|
168 size=wx.Size(0, 24), style=0) |
|
169 self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL) |
158 |
170 |
159 self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW, |
171 self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW, |
160 name='Preview', parent=self, pos=wx.Point(0, 0), |
172 name='Preview', parent=self, pos=wx.Point(0, 0), |
161 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
173 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
162 self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
174 self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
352 if pydata["type"] == CATEGORY: |
374 if pydata["type"] == CATEGORY: |
353 self.Block = None |
375 self.Block = None |
354 else: |
376 else: |
355 blocktype = self.TypeTree.GetItemText(item) |
377 blocktype = self.TypeTree.GetItemText(item) |
356 if blocktype: |
378 if blocktype: |
357 self.Block = FBD_Block(self.Preview, blocktype, self.BlockName.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"], executionOrder = self.ExecutionOrder.GetValue()) |
379 self.Block = FBD_Block(self.Preview, blocktype, |
|
380 self.BlockName.GetValue(), |
|
381 extension = self.Inputs.GetValue(), |
|
382 inputs = pydata["inputs"], |
|
383 executionControl = self.ExecutionControl.GetValue(), |
|
384 executionOrder = self.ExecutionOrder.GetValue()) |
358 width, height = self.MinBlockSize |
385 width, height = self.MinBlockSize |
359 min_width, min_height = self.Block.GetMinSize() |
386 min_width, min_height = self.Block.GetMinSize() |
360 width, height = max(min_width, width), max(min_height, height) |
387 width, height = max(min_width, width), max(min_height, height) |
361 self.Block.SetSize(width, height) |
388 self.Block.SetSize(width, height) |
362 clientsize = self.Preview.GetClientSize() |
389 clientsize = self.Preview.GetClientSize() |
865 |
892 |
866 |
893 |
867 [ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, |
894 [ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, |
868 ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, |
895 ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, |
869 ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3, |
896 ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3, |
870 ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGPREVIEW, |
897 ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGRADIOBUTTON5, |
|
898 ID_LDELEMENTDIALOGRADIOBUTTON6, ID_LDELEMENTDIALOGPREVIEW, |
871 ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, |
899 ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, |
872 ID_LDELEMENTDIALOGSTATICTEXT3, |
900 ID_LDELEMENTDIALOGSTATICTEXT3, |
873 ] = [wx.NewId() for _init_ctrls in range(11)] |
901 ] = [wx.NewId() for _init_ctrls in range(13)] |
874 |
902 |
875 class LDElementDialog(wx.Dialog): |
903 class LDElementDialog(wx.Dialog): |
876 |
904 |
877 if wx.VERSION < (2, 6, 0): |
905 if wx.VERSION < (2, 6, 0): |
878 def Bind(self, event, function, id = None): |
906 def Bind(self, event, function, id = None): |
893 parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) |
921 parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) |
894 parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) |
922 parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) |
895 |
923 |
896 def _init_coll_LeftGridSizer_Items(self, parent): |
924 def _init_coll_LeftGridSizer_Items(self, parent): |
897 parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
925 parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
|
926 parent.AddSizer(self.RadioButtonSizer, 0, border=0, flag=wx.GROW) |
|
927 parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
|
928 parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW) |
|
929 parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
|
930 |
|
931 def _init_coll_LeftGridSizer_Growables(self, parent): |
|
932 parent.AddGrowableCol(0) |
|
933 parent.AddGrowableRow(7) |
|
934 |
|
935 def _init_coll_RadioButtonSizer_Items(self, parent): |
898 parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) |
936 parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) |
899 parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) |
937 parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) |
900 parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) |
938 parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) |
901 parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) |
939 parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) |
902 parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
940 parent.AddWindow(self.radioButton5, 0, border=0, flag=wx.GROW) |
903 parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW) |
941 parent.AddWindow(self.radioButton6, 0, border=0, flag=wx.GROW) |
904 parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
942 |
905 |
|
906 def _init_coll_LeftGridSizer_Growables(self, parent): |
|
907 parent.AddGrowableCol(0) |
|
908 parent.AddGrowableRow(7) |
|
909 |
|
910 def _init_coll_RightGridSizer_Items(self, parent): |
943 def _init_coll_RightGridSizer_Items(self, parent): |
911 parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
944 parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
912 parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
945 parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
913 |
946 |
914 def _init_coll_RightGridSizer_Growables(self, parent): |
947 def _init_coll_RightGridSizer_Growables(self, parent): |
916 parent.AddGrowableRow(1) |
949 parent.AddGrowableRow(1) |
917 |
950 |
918 def _init_sizers(self): |
951 def _init_sizers(self): |
919 self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
952 self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
920 self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
953 self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
921 self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) |
954 self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) |
|
955 self.RadioButtonSizer = wx.BoxSizer(wx.VERTICAL) |
922 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
956 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
923 |
957 |
924 self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
958 self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
925 self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
959 self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
926 self._init_coll_MainSizer_Items(self.MainSizer) |
960 self._init_coll_MainSizer_Items(self.MainSizer) |
927 self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
961 self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
928 self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
962 self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
|
963 self._init_coll_RadioButtonSizer_Items(self.RadioButtonSizer) |
929 self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
964 self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
930 self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
965 self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
931 |
966 |
932 self.SetSizer(self.flexGridSizer1) |
967 self.SetSizer(self.flexGridSizer1) |
933 |
968 |
934 def _init_ctrls(self, prnt, ctrler, title, labels): |
969 def _init_ctrls(self, prnt, ctrler, title, extra_size = 0): |
935 wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG, |
970 wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG, |
936 name='LDElementDialog', parent=prnt, pos=wx.Point(376, 223), |
971 name='LDElementDialog', parent=prnt, pos=wx.Point(376, 223), |
937 size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, |
972 size=wx.Size(350, 260 + extra_size), style=wx.DEFAULT_DIALOG_STYLE, |
938 title=title) |
973 title=title) |
939 self.SetClientSize(wx.Size(350, 260)) |
974 self.SetClientSize(wx.Size(350, 260 + extra_size)) |
940 |
975 |
941 self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1, |
976 self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1, |
942 label='Modifier:', name='staticText1', parent=self, |
977 label='Modifier:', name='staticText1', parent=self, |
943 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
978 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
944 |
979 |
949 self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3, |
984 self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3, |
950 label='Preview:', name='staticText3', parent=self, |
985 label='Preview:', name='staticText3', parent=self, |
951 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
986 pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
952 |
987 |
953 self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1, |
988 self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1, |
954 label=labels[0], name='radioButton1', parent=self, |
989 label="Normal", name='radioButton1', parent=self, |
955 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
990 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
956 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1) |
991 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1) |
957 self.radioButton1.SetValue(True) |
992 self.radioButton1.SetValue(True) |
958 |
993 |
959 self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2, |
994 self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2, |
960 label=labels[1], name='radioButton2', parent=self, |
995 label="Negated", name='radioButton2', parent=self, |
961 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
996 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
962 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2) |
997 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2) |
963 |
998 |
964 self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3, |
999 self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3, |
965 label=labels[2], name='radioButton3', parent=self, |
1000 label="Set", name='radioButton3', parent=self, |
966 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
1001 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
967 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3) |
1002 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3) |
968 |
1003 |
969 self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4, |
1004 self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4, |
970 label=labels[3], name='radioButton4', parent=self, |
1005 label="Reset", name='radioButton4', parent=self, |
971 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
1006 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
972 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4) |
1007 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4) |
|
1008 |
|
1009 self.radioButton5 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON5, |
|
1010 label="Rising Edge", name='radioButton5', parent=self, |
|
1011 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
|
1012 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON5) |
|
1013 |
|
1014 self.radioButton6 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON6, |
|
1015 label="Falling Edge", name='radioButton6', parent=self, |
|
1016 pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
|
1017 self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON6) |
973 |
1018 |
974 self.ElementName = wx.Choice(id=ID_LDELEMENTDIALOGNAME, |
1019 self.ElementName = wx.Choice(id=ID_LDELEMENTDIALOGNAME, |
975 name='Name', parent=self, pos=wx.Point(0, 0), |
1020 name='Name', parent=self, pos=wx.Point(0, 0), |
976 size=wx.Size(0, 24), style=0) |
1021 size=wx.Size(0, 24), style=0) |
977 self.Bind(wx.EVT_CHOICE, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME) |
1022 self.Bind(wx.EVT_CHOICE, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME) |
998 self._init_sizers() |
1043 self._init_sizers() |
999 |
1044 |
1000 def __init__(self, parent, controler, type): |
1045 def __init__(self, parent, controler, type): |
1001 self.Type = type |
1046 self.Type = type |
1002 if type == "contact": |
1047 if type == "contact": |
1003 self._init_ctrls(parent, controler, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge']) |
1048 self._init_ctrls(parent, controler, "Edit Contact Values") |
1004 self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") |
1049 self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") |
|
1050 self.radioButton3.Hide() |
|
1051 self.radioButton4.Hide() |
1005 elif type == "coil": |
1052 elif type == "coil": |
1006 self._init_ctrls(parent, controler, "Edit Coil Values", ['Normal','Negate','Set','Reset']) |
1053 self._init_ctrls(parent, controler, "Edit Coil Values", 50) |
1007 self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") |
1054 self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") |
|
1055 |
1008 |
1056 |
1009 def SetPreviewFont(self, font): |
1057 def SetPreviewFont(self, font): |
1010 self.Preview.SetFont(font) |
1058 self.Preview.SetFont(font) |
1011 |
1059 |
1012 def SetElementSize(self, size): |
1060 def SetElementSize(self, size): |
1031 if value == CONTACT_NORMAL: |
1079 if value == CONTACT_NORMAL: |
1032 self.radioButton1.SetValue(True) |
1080 self.radioButton1.SetValue(True) |
1033 elif value == CONTACT_REVERSE: |
1081 elif value == CONTACT_REVERSE: |
1034 self.radioButton2.SetValue(True) |
1082 self.radioButton2.SetValue(True) |
1035 elif value == CONTACT_RISING: |
1083 elif value == CONTACT_RISING: |
1036 self.radioButton3.SetValue(True) |
1084 self.radioButton5.SetValue(True) |
1037 elif value == CONTACT_FALLING: |
1085 elif value == CONTACT_FALLING: |
1038 self.radioButton4.SetValue(True) |
1086 self.radioButton6.SetValue(True) |
1039 elif self.Type == "coil": |
1087 elif self.Type == "coil": |
1040 if value == COIL_NORMAL: |
1088 if value == COIL_NORMAL: |
1041 self.radioButton1.SetValue(True) |
1089 self.radioButton1.SetValue(True) |
1042 elif value == COIL_REVERSE: |
1090 elif value == COIL_REVERSE: |
1043 self.radioButton2.SetValue(True) |
1091 self.radioButton2.SetValue(True) |
1044 elif value == COIL_SET: |
1092 elif value == COIL_SET: |
1045 self.radioButton3.SetValue(True) |
1093 self.radioButton3.SetValue(True) |
1046 elif value == COIL_RESET: |
1094 elif value == COIL_RESET: |
1047 self.radioButton4.SetValue(True) |
1095 self.radioButton4.SetValue(True) |
|
1096 elif value == COIL_RISING: |
|
1097 self.radioButton5.SetValue(True) |
|
1098 elif value == COIL_FALLING: |
|
1099 self.radioButton6.SetValue(True) |
1048 |
1100 |
1049 def GetValues(self): |
1101 def GetValues(self): |
1050 values = {} |
1102 values = {} |
1051 values["name"] = self.Element.GetName() |
1103 values["name"] = self.Element.GetName() |
1052 values["type"] = self.Element.GetType() |
1104 values["type"] = self.Element.GetType() |
1057 if self.Type == "contact": |
1109 if self.Type == "contact": |
1058 if self.radioButton1.GetValue(): |
1110 if self.radioButton1.GetValue(): |
1059 self.Element.SetType(CONTACT_NORMAL) |
1111 self.Element.SetType(CONTACT_NORMAL) |
1060 elif self.radioButton2.GetValue(): |
1112 elif self.radioButton2.GetValue(): |
1061 self.Element.SetType(CONTACT_REVERSE) |
1113 self.Element.SetType(CONTACT_REVERSE) |
1062 elif self.radioButton3.GetValue(): |
1114 elif self.radioButton5.GetValue(): |
1063 self.Element.SetType(CONTACT_RISING) |
1115 self.Element.SetType(CONTACT_RISING) |
1064 elif self.radioButton4.GetValue(): |
1116 elif self.radioButton6.GetValue(): |
1065 self.Element.SetType(CONTACT_FALLING) |
1117 self.Element.SetType(CONTACT_FALLING) |
1066 elif self.Type == "coil": |
1118 elif self.Type == "coil": |
1067 if self.radioButton1.GetValue(): |
1119 if self.radioButton1.GetValue(): |
1068 self.Element.SetType(COIL_NORMAL) |
1120 self.Element.SetType(COIL_NORMAL) |
1069 elif self.radioButton2.GetValue(): |
1121 elif self.radioButton2.GetValue(): |
1070 self.Element.SetType(COIL_REVERSE) |
1122 self.Element.SetType(COIL_REVERSE) |
1071 elif self.radioButton3.GetValue(): |
1123 elif self.radioButton3.GetValue(): |
1072 self.Element.SetType(COIL_SET) |
1124 self.Element.SetType(COIL_SET) |
1073 elif self.radioButton4.GetValue(): |
1125 elif self.radioButton4.GetValue(): |
1074 self.Element.SetType(COIL_RESET) |
1126 self.Element.SetType(COIL_RESET) |
|
1127 elif self.radioButton5.GetValue(): |
|
1128 self.Element.SetType(COIL_RISING) |
|
1129 elif self.radioButton6.GetValue(): |
|
1130 self.Element.SetType(COIL_FALLING) |
1075 self.RefreshPreview() |
1131 self.RefreshPreview() |
1076 event.Skip() |
1132 event.Skip() |
1077 |
1133 |
1078 def OnNameChanged(self, event): |
1134 def OnNameChanged(self, event): |
1079 self.Element.SetName(self.ElementName.GetStringSelection()) |
1135 self.Element.SetName(self.ElementName.GetStringSelection()) |