author | lbessard |
Fri, 03 Aug 2007 18:02:54 +0200 | |
changeset 62 | 1908c45f21ef |
parent 58 | 39cd981ff242 |
child 64 | dd6f693e46a1 |
permissions | -rw-r--r-- |
27 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
5 |
#based on the plcopen standard. |
|
6 |
# |
|
58 | 7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
27 | 8 |
# |
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
58 | 19 |
#General Public License for more details. |
27 | 20 |
# |
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
from wxPython.wx import * |
|
26 |
from wxPython.grid import * |
|
27 |
import wx |
|
28 |
||
45 | 29 |
from graphics import * |
27 | 30 |
|
31 |
#------------------------------------------------------------------------------- |
|
32 |
# Create New Block Dialog |
|
33 |
#------------------------------------------------------------------------------- |
|
34 |
||
58 | 35 |
[wxID_BLOCKPROPERTIESDIALOG, wxID_BLOCKPROPERTIESDIALOGNAME, |
36 |
wxID_BLOCKPROPERTIESDIALOGTYPETREE, wxID_BLOCKPROPERTIESDIALOGTYPEDESC, |
|
37 |
wxID_BLOCKPROPERTIESDIALOGINPUTS, wxID_BLOCKPROPERTIESDIALOGPREVIEW, |
|
38 |
wxID_BLOCKPROPERTIESDIALOGSTATICTEXT1, wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
|
39 |
wxID_BLOCKPROPERTIESDIALOGSTATICTEXT3, wxID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
|
40 |
] = [wx.NewId() for _init_ctrls in range(10)] |
|
27 | 41 |
|
42 |
[CATEGORY, BLOCK] = range(2) |
|
43 |
||
44 |
class BlockPropertiesDialog(wx.Dialog): |
|
45 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
46 |
# generated method, don't edit |
|
47 |
||
58 | 48 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) |
49 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) |
|
50 |
||
51 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
|
52 |
# generated method, don't edit |
|
53 |
||
54 |
parent.AddGrowableCol(0) |
|
55 |
parent.AddGrowableRow(0) |
|
56 |
||
57 |
def _init_coll_MainSizer_Items(self, parent): |
|
58 |
# generated method, don't edit |
|
59 |
||
60 |
parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wxGROW|wxRIGHT) |
|
61 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) |
|
62 |
||
63 |
def _init_coll_LeftBoxSizer_Items(self, parent): |
|
64 |
# generated method, don't edit |
|
65 |
||
66 |
parent.AddWindow(self.TypeTree, 3, border=5, flag=wxGROW|wxBOTTOM) |
|
67 |
parent.AddWindow(self.TypeDesc, 1, border=0, flag=wxGROW) |
|
68 |
||
69 |
def _init_coll_RightGridSizer_Items(self, parent): |
|
70 |
# generated method, don't edit |
|
71 |
||
72 |
parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wxGROW) |
|
73 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wxGROW) |
|
74 |
parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) |
|
75 |
||
76 |
def _init_coll_RightGridSizer_Growables(self, parent): |
|
77 |
# generated method, don't edit |
|
78 |
||
79 |
parent.AddGrowableCol(0) |
|
80 |
parent.AddGrowableRow(2) |
|
81 |
||
82 |
def _init_coll_RightUpGridSizer_Items(self, parent): |
|
83 |
# generated method, don't edit |
|
84 |
||
85 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW|wxALIGN_BOTTOM) |
|
86 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW|wxALIGN_BOTTOM) |
|
87 |
parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) |
|
88 |
parent.AddWindow(self.Inputs, 0, border=0, flag=wxGROW) |
|
27 | 89 |
|
90 |
def _init_sizers(self): |
|
91 |
# generated method, don't edit |
|
58 | 92 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
93 |
self.MainSizer = wx.BoxSizer(wxHORIZONTAL) |
|
94 |
self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wxVERTICAL) |
|
95 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
|
96 |
self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=2, vgap=5) |
|
97 |
||
27 | 98 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
58 | 99 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
100 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
101 |
self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
|
102 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
|
103 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
|
104 |
self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer) |
|
105 |
||
27 | 106 |
self.SetSizer(self.flexGridSizer1) |
107 |
||
108 |
def _init_ctrls(self, prnt): |
|
109 |
# generated method, don't edit |
|
110 |
wx.Dialog.__init__(self, id=wxID_BLOCKPROPERTIESDIALOG, |
|
111 |
name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
58 | 112 |
size=wx.Size(600, 360), style=wx.DEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, |
27 | 113 |
title='Block Properties') |
114 |
self.SetClientSize(wx.Size(600, 360)) |
|
115 |
||
116 |
self.staticbox1 = wx.StaticBox(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT1, |
|
58 | 117 |
label='Type:', name='staticBox1', parent=self, |
118 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
|
27 | 119 |
|
120 |
self.staticText2 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
|
58 | 121 |
label='Name:', name='staticText2', parent=self, |
122 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 123 |
|
124 |
self.staticText3 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
|
58 | 125 |
label='Inputs:', name='staticText4', parent=self, |
126 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 127 |
|
128 |
self.staticText4 = wx.StaticText(id=wxID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
|
58 | 129 |
label='Preview:', name='staticText4', parent=self, |
130 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 131 |
|
132 |
self.TypeTree = wx.TreeCtrl(id=wxID_BLOCKPROPERTIESDIALOGTYPETREE, |
|
58 | 133 |
name='TypeTree', parent=self, pos=wx.Point(0, 0), |
134 |
size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
|
27 | 135 |
EVT_TREE_SEL_CHANGED(self, wxID_BLOCKPROPERTIESDIALOGTYPETREE, self.OnTypeTreeItemSelected) |
136 |
||
137 |
self.TypeDesc = wx.TextCtrl(id=wxID_BLOCKPROPERTIESDIALOGTYPEDESC, |
|
58 | 138 |
name='TypeDesc', parent=self, pos=wx.Point(0, 0), |
139 |
size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE) |
|
27 | 140 |
|
141 |
self.Name = wx.TextCtrl(id=wxID_BLOCKPROPERTIESDIALOGNAME, value='', |
|
58 | 142 |
name='Name', parent=self, pos=wx.Point(0, 0), |
143 |
size=wx.Size(0, 24), style=0) |
|
27 | 144 |
EVT_TEXT(self, wxID_BLOCKPROPERTIESDIALOGNAME, self.OnNameChanged) |
145 |
||
146 |
self.Inputs = wx.SpinCtrl(id=wxID_BLOCKPROPERTIESDIALOGINPUTS, |
|
58 | 147 |
name='Inputs', parent=self, pos=wx.Point(0, 0), |
148 |
size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=2, max=20) |
|
27 | 149 |
EVT_SPINCTRL(self, wxID_BLOCKPROPERTIESDIALOGINPUTS, self.OnInputsChanged) |
150 |
||
151 |
self.Preview = wx.Panel(id=wxID_BLOCKPROPERTIESDIALOGPREVIEW, |
|
58 | 152 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
153 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
|
27 | 154 |
self.Preview.SetBackgroundColour(wxColour(255,255,255)) |
42 | 155 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
27 | 156 |
|
58 | 157 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
158 |
||
27 | 159 |
self._init_sizers() |
160 |
||
161 |
def __init__(self, parent): |
|
162 |
self._init_ctrls(parent) |
|
163 |
self.Name.SetValue("") |
|
164 |
self.Name.Enable(False) |
|
165 |
self.Inputs.Enable(False) |
|
166 |
self.Block = None |
|
167 |
self.MinBlockSize = None |
|
168 |
||
169 |
EVT_PAINT(self, self.OnPaint) |
|
170 |
EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
|
171 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
172 |
def FindTreeItem(self, root, name, inputs = None): |
27 | 173 |
if root.IsOk(): |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
174 |
pydata = self.TypeTree.GetPyData(root) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
175 |
if inputs and "inputs" in pydata: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
176 |
same_inputs = pydata["inputs"] == inputs |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
177 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
178 |
same_inputs = True |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
179 |
if self.TypeTree.GetItemText(root) == name and same_inputs: |
27 | 180 |
return root |
181 |
else: |
|
182 |
item, root_cookie = self.TypeTree.GetFirstChild(root) |
|
183 |
while item.IsOk(): |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
184 |
result = self.FindTreeItem(item, name, inputs) |
27 | 185 |
if result: |
186 |
return result |
|
187 |
item, root_cookie = self.TypeTree.GetNextChild(root, root_cookie) |
|
188 |
return None |
|
189 |
||
190 |
def OnOK(self, event): |
|
191 |
error = [] |
|
192 |
selected = self.TypeTree.GetSelection() |
|
193 |
if not selected.IsOk() or self.TypeTree.GetItemParent(selected) == self.TypeTree.GetRootItem() or selected == self.TypeTree.GetRootItem(): |
|
194 |
message = wxMessageDialog(self, "Form isn't complete. Valid block type must be selected!", "Error", wxOK|wxICON_ERROR) |
|
195 |
message.ShowModal() |
|
196 |
message.Destroy() |
|
197 |
elif self.Name.IsEnabled() and self.Name.GetValue() == "": |
|
198 |
message = wxMessageDialog(self, "Form isn't complete. Name must be filled!", "Error", wxOK|wxICON_ERROR) |
|
199 |
message.ShowModal() |
|
200 |
message.Destroy() |
|
201 |
else: |
|
202 |
self.EndModal(wxID_OK) |
|
203 |
||
204 |
def SetBlockList(self, blocktypes): |
|
205 |
root = self.TypeTree.AddRoot("") |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
206 |
self.TypeTree.SetPyData(root, {"type" : CATEGORY}) |
27 | 207 |
for category in blocktypes: |
208 |
category_item = self.TypeTree.AppendItem(root, category["name"]) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
209 |
self.TypeTree.SetPyData(category_item, {"type" : CATEGORY}) |
27 | 210 |
for blocktype in category["list"]: |
211 |
blocktype_item = self.TypeTree.AppendItem(category_item, blocktype["name"]) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
212 |
self.TypeTree.SetPyData(blocktype_item, {"type" : BLOCK, "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]])}) |
27 | 213 |
|
214 |
def SetMinBlockSize(self, size): |
|
215 |
self.MinBlockSize = size |
|
216 |
||
217 |
def SetValues(self, values): |
|
218 |
for name, value in values.items(): |
|
219 |
if name == "type": |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
220 |
inputs = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
221 |
if "inputs" in values: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
222 |
inputs = values["inputs"] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
223 |
item = self.FindTreeItem(self.TypeTree.GetRootItem(), value, inputs) |
27 | 224 |
if item: |
225 |
self.TypeTree.SelectItem(item) |
|
226 |
elif name == "name": |
|
227 |
self.Name.SetValue(value) |
|
228 |
elif name == "extension": |
|
229 |
self.Inputs.SetValue(value) |
|
230 |
self.RefreshPreview() |
|
231 |
||
232 |
def GetValues(self): |
|
233 |
values = {} |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
234 |
item = self.TypeTree.GetSelection() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
235 |
values["type"] = self.TypeTree.GetItemText(item) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
236 |
values["inputs"] = self.TypeTree.GetPyData(item)["inputs"] |
27 | 237 |
if self.Name.GetValue() != "": |
238 |
values["name"] = self.Name.GetValue() |
|
239 |
values["width"], values["height"] = self.Block.GetSize() |
|
240 |
values["extension"] = self.Inputs.GetValue() |
|
241 |
return values |
|
242 |
||
243 |
def OnTypeTreeItemSelected(self, event): |
|
244 |
self.Name.SetValue("") |
|
245 |
selected = event.GetItem() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
246 |
pydata = self.TypeTree.GetPyData(selected) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
247 |
if pydata["type"] != CATEGORY: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
248 |
blocktype = GetBlockType(self.TypeTree.GetItemText(selected), pydata["inputs"]) |
27 | 249 |
if blocktype: |
250 |
self.Inputs.SetValue(len(blocktype["inputs"])) |
|
251 |
self.Inputs.Enable(blocktype["extensible"]) |
|
252 |
self.Name.Enable(blocktype["type"] != "function") |
|
253 |
self.TypeDesc.SetValue(blocktype["comment"]) |
|
254 |
wxCallAfter(self.RefreshPreview) |
|
255 |
else: |
|
256 |
self.Name.Enable(False) |
|
257 |
self.Inputs.Enable(False) |
|
258 |
self.Inputs.SetValue(2) |
|
259 |
self.TypeDesc.SetValue("") |
|
260 |
wxCallAfter(self.ErasePreview) |
|
261 |
else: |
|
262 |
self.Name.Enable(False) |
|
263 |
self.Inputs.Enable(False) |
|
264 |
self.Inputs.SetValue(2) |
|
265 |
self.TypeDesc.SetValue("") |
|
266 |
wxCallAfter(self.ErasePreview) |
|
267 |
event.Skip() |
|
268 |
||
269 |
def OnNameChanged(self, event): |
|
270 |
if self.Name.IsEnabled(): |
|
271 |
self.RefreshPreview() |
|
272 |
event.Skip() |
|
273 |
||
274 |
def OnInputsChanged(self, event): |
|
275 |
if self.Inputs.IsEnabled(): |
|
276 |
self.RefreshPreview() |
|
277 |
event.Skip() |
|
278 |
||
279 |
def ErasePreview(self): |
|
280 |
dc = wxClientDC(self.Preview) |
|
281 |
dc.Clear() |
|
282 |
self.Block = None |
|
283 |
||
284 |
def RefreshPreview(self): |
|
285 |
dc = wxClientDC(self.Preview) |
|
286 |
dc.Clear() |
|
287 |
item = self.TypeTree.GetSelection() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
288 |
pydata = self.TypeTree.GetPyData(item) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
289 |
if pydata["type"] == CATEGORY: |
27 | 290 |
self.Block = None |
291 |
else: |
|
292 |
blocktype = self.TypeTree.GetItemText(item) |
|
293 |
if blocktype: |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
294 |
self.Block = FBD_Block(self.Preview, blocktype, self.Name.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"]) |
27 | 295 |
width, height = self.MinBlockSize |
296 |
min_width, min_height = self.Block.GetMinSize() |
|
297 |
width, height = max(min_width, width), max(min_height, height) |
|
298 |
self.Block.SetSize(width, height) |
|
299 |
clientsize = self.Preview.GetClientSize() |
|
300 |
x = (clientsize.width - width) / 2 |
|
301 |
y = (clientsize.height - height) / 2 |
|
302 |
self.Block.SetPosition(x, y) |
|
303 |
self.Block.Draw(dc) |
|
304 |
else: |
|
305 |
self.Block = None |
|
306 |
||
307 |
def OnPaint(self, event): |
|
308 |
if self.Block: |
|
309 |
self.RefreshPreview() |
|
310 |
||
311 |
||
312 |
#------------------------------------------------------------------------------- |
|
313 |
# Create New Variable Dialog |
|
314 |
#------------------------------------------------------------------------------- |
|
315 |
||
58 | 316 |
[wxID_VARIABLEPROPERTIESDIALOG, wxID_VARIABLEPROPERTIESDIALOGSPACER, |
27 | 317 |
wxID_VARIABLEPROPERTIESDIALOGNAME, wxID_VARIABLEPROPERTIESDIALOGCLASS, |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
318 |
wxID_VARIABLEPROPERTIESDIALOGPREVIEW, wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
319 |
wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
320 |
wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
321 |
] = [wx.NewId() for _init_ctrls in range(10)] |
27 | 322 |
|
323 |
class VariablePropertiesDialog(wx.Dialog): |
|
324 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
325 |
# generated method, don't edit |
|
326 |
||
58 | 327 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) |
328 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) |
|
329 |
||
330 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
|
331 |
# generated method, don't edit |
|
332 |
||
333 |
parent.AddGrowableCol(0) |
|
334 |
parent.AddGrowableRow(0) |
|
335 |
||
336 |
def _init_coll_MainSizer_Items(self, parent): |
|
337 |
# generated method, don't edit |
|
338 |
||
339 |
parent.AddSizer(self.TopSizer, 0, border=0, flag=wxGROW) |
|
340 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wxGROW) |
|
341 |
parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) |
|
342 |
||
343 |
def _init_coll_MainSizer_Growables(self, parent): |
|
344 |
# generated method, don't edit |
|
345 |
||
346 |
parent.AddGrowableCol(0) |
|
347 |
parent.AddGrowableRow(2) |
|
348 |
||
349 |
def _init_coll_TopSizer_Items(self, parent): |
|
350 |
# generated method, don't edit |
|
351 |
||
352 |
parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) |
|
353 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) |
|
354 |
||
355 |
def _init_coll_LeftGridSizer_Items(self, parent): |
|
356 |
# generated method, don't edit |
|
357 |
||
358 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) |
|
359 |
parent.AddWindow(self.Class, 0, border=0, flag=wxGROW) |
|
360 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) |
|
361 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) |
|
362 |
parent.AddWindow(self.Expression, 0, border=0, flag=wxGROW) |
|
363 |
||
364 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
|
365 |
# generated method, don't edit |
|
366 |
||
367 |
parent.AddGrowableCol(0) |
|
368 |
parent.AddGrowableRow(2) |
|
369 |
||
370 |
def _init_coll_RightGridSizer_Items(self, parent): |
|
371 |
# generated method, don't edit |
|
372 |
||
373 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) |
|
374 |
parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) |
|
375 |
||
376 |
def _init_coll_RightGridSizer_Growables(self, parent): |
|
377 |
# generated method, don't edit |
|
378 |
||
379 |
parent.AddGrowableCol(0) |
|
380 |
parent.AddGrowableRow(1) |
|
381 |
||
27 | 382 |
def _init_sizers(self): |
383 |
# generated method, don't edit |
|
58 | 384 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
385 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
|
386 |
self.TopSizer = wx.BoxSizer(wxHORIZONTAL) |
|
387 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) |
|
388 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
|
27 | 389 |
|
390 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
58 | 391 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
392 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
393 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
|
394 |
self._init_coll_TopSizer_Items(self.TopSizer) |
|
395 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
|
396 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
|
397 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
|
398 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
|
399 |
||
27 | 400 |
self.SetSizer(self.flexGridSizer1) |
401 |
||
402 |
def _init_ctrls(self, prnt): |
|
403 |
# generated method, don't edit |
|
404 |
wx.Dialog.__init__(self, id=wxID_VARIABLEPROPERTIESDIALOG, |
|
405 |
name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
406 |
size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE, |
27 | 407 |
title='Variable Properties') |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
408 |
self.SetClientSize(wx.Size(400, 380)) |
27 | 409 |
|
410 |
self.staticText1 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, |
|
58 | 411 |
label='Class:', name='staticText1', parent=self, |
412 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 413 |
|
414 |
self.staticText2 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, |
|
58 | 415 |
label='Expression:', name='staticText2', parent=self, |
416 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
417 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
418 |
self.staticText3 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, |
58 | 419 |
label='Name:', name='staticText3', parent=self, |
420 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 421 |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
422 |
self.staticText4 = wx.StaticText(id=wxID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, |
58 | 423 |
label='Preview:', name='staticText4', parent=self, |
424 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 425 |
|
426 |
self.Class = wx.Choice(id=wxID_VARIABLEPROPERTIESDIALOGCLASS, |
|
58 | 427 |
name='Class', parent=self, pos=wx.Point(0, 0), |
428 |
size=wx.Size(0, 24), style=0) |
|
27 | 429 |
EVT_CHOICE(self, wxID_VARIABLEPROPERTIESDIALOGCLASS, self.OnClassChanged) |
430 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
431 |
self.Name = wx.ListBox(id=wxID_VARIABLEPROPERTIESDIALOGNAME, |
58 | 432 |
name='Name', parent=self, pos=wx.Point(0, 0), |
433 |
size=wx.Size(0, 90), style=wx.LB_SINGLE) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
434 |
EVT_LISTBOX(self, wxID_VARIABLEPROPERTIESDIALOGNAME, self.OnNameChanged) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
435 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
436 |
self.Expression = wx.TextCtrl(id=wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, |
58 | 437 |
name='Expression', parent=self, pos=wx.Point(0, 0), |
438 |
size=wx.Size(0, 24), style=0) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
439 |
EVT_TEXT(self, wxID_VARIABLEPROPERTIESDIALOGEXPRESSION, self.OnExpressionChanged) |
27 | 440 |
|
58 | 441 |
self.Spacer = wx.Panel(id=wxID_VARIABLEPROPERTIESDIALOGSPACER, |
442 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
|
443 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
444 |
||
27 | 445 |
self.Preview = wx.Panel(id=wxID_VARIABLEPROPERTIESDIALOGPREVIEW, |
58 | 446 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
447 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
|
27 | 448 |
self.Preview.SetBackgroundColour(wxColour(255,255,255)) |
42 | 449 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
27 | 450 |
|
58 | 451 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
452 |
||
27 | 453 |
self._init_sizers() |
454 |
||
455 |
def __init__(self, parent): |
|
456 |
self._init_ctrls(parent) |
|
457 |
self.Variable = None |
|
458 |
self.VarList = [] |
|
459 |
self.MinVariableSize = None |
|
460 |
self.RefreshNameList() |
|
461 |
||
462 |
for choice in ["Input", "Output", "InOut"]: |
|
463 |
self.Class.Append(choice) |
|
464 |
self.Class.SetStringSelection("Input") |
|
465 |
||
466 |
EVT_PAINT(self, self.OnPaint) |
|
467 |
||
468 |
def RefreshNameList(self): |
|
469 |
selected = self.Name.GetStringSelection() |
|
470 |
self.Name.Clear() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
471 |
self.Name.Append("") |
27 | 472 |
for name, var_type, value_type in self.VarList: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
473 |
if var_type in ["Local","Temp","Global","External"]: |
27 | 474 |
self.Name.Append(name) |
475 |
elif var_type == "Input" and self.Class.GetStringSelection() == "Input": |
|
476 |
self.Name.Append(name) |
|
477 |
elif var_type == "Output" and self.Class.GetStringSelection() == "Output": |
|
478 |
self.Name.Append(name) |
|
479 |
elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut": |
|
480 |
self.Name.Append(name) |
|
481 |
if self.Name.FindString(selected) != wxNOT_FOUND: |
|
482 |
self.Name.SetStringSelection(selected) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
483 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
484 |
self.Name.SetStringSelection("") |
27 | 485 |
self.Name.Enable(self.Name.GetCount() > 0) |
486 |
||
487 |
def SetMinVariableSize(self, size): |
|
488 |
self.MinVariableSize = size |
|
489 |
||
490 |
def SetVariables(self, vars): |
|
491 |
self.VarList = vars |
|
492 |
self.RefreshNameList() |
|
493 |
||
494 |
def SetValues(self, values): |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
495 |
value_type = values.get("type", None) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
496 |
value_name = values.get("name", None) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
497 |
if value_type: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
498 |
if value_type == INPUT: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
499 |
self.Class.SetStringSelection("Input") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
500 |
if value_type == OUTPUT: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
501 |
self.Class.SetStringSelection("Output") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
502 |
if value_type == INOUT: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
503 |
self.Class.SetStringSelection("InOut") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
504 |
self.RefreshNameList() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
505 |
if value_name: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
506 |
if self.Name.FindString(value_name) != wxNOT_FOUND: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
507 |
self.Name.SetStringSelection(value_name) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
508 |
self.Expression.Enable(False) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
509 |
else: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
510 |
self.Expression.SetValue(value_name) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
511 |
self.Name.Enable(False) |
27 | 512 |
self.RefreshPreview() |
513 |
||
514 |
def GetValues(self): |
|
515 |
values = {} |
|
516 |
classtype = self.Class.GetStringSelection() |
|
517 |
if classtype == "Input": |
|
518 |
values["type"] = INPUT |
|
519 |
elif classtype == "Output": |
|
520 |
values["type"] = OUTPUT |
|
521 |
elif classtype == "InOut": |
|
522 |
values["type"] = INOUT |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
523 |
expression = self.Expression.GetValue() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
524 |
if self.Expression.IsEnabled() and expression != "": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
525 |
values["name"] = expression |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
526 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
527 |
values["name"] = self.Name.GetStringSelection() |
27 | 528 |
values["value_type"] = "" |
529 |
for var_name, var_type, value_type in self.VarList: |
|
530 |
if var_name == values["name"]: |
|
531 |
values["value_type"] = value_type |
|
532 |
values["width"], values["height"] = self.Variable.GetSize() |
|
533 |
return values |
|
534 |
||
535 |
def OnClassChanged(self, event): |
|
536 |
self.RefreshNameList() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
537 |
if self.Class.GetStringSelection() == "Input": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
538 |
self.Expression.Enable(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
539 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
540 |
self.Expression.Enable(False) |
27 | 541 |
self.RefreshPreview() |
542 |
event.Skip() |
|
543 |
||
544 |
def OnNameChanged(self, event): |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
545 |
if self.Name.GetStringSelection() != "": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
546 |
self.Expression.Enable(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
547 |
elif self.Class.GetStringSelection() == "Input": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
548 |
self.Expression.Enable(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
549 |
self.RefreshPreview() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
550 |
event.Skip() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
551 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
552 |
def OnExpressionChanged(self, event): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
553 |
if self.Expression.GetValue() != "": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
554 |
self.Name.Enable(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
555 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
556 |
self.Name.Enable(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
557 |
self.RefreshPreview() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
558 |
event.Skip() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
559 |
|
27 | 560 |
def RefreshPreview(self): |
561 |
dc = wxClientDC(self.Preview) |
|
562 |
dc.Clear() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
563 |
expression = self.Expression.GetValue() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
564 |
if self.Expression.IsEnabled() and expression != "": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
565 |
name = expression |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
566 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
567 |
name = self.Name.GetStringSelection() |
27 | 568 |
type = "" |
569 |
for var_name, var_type, value_type in self.VarList: |
|
570 |
if var_name == name: |
|
571 |
type = value_type |
|
572 |
classtype = self.Class.GetStringSelection() |
|
573 |
if classtype == "Input": |
|
574 |
self.Variable = FBD_Variable(self.Preview, INPUT, name, type) |
|
575 |
elif classtype == "Output": |
|
576 |
self.Variable = FBD_Variable(self.Preview, OUTPUT, name, type) |
|
577 |
elif classtype == "InOut": |
|
578 |
self.Variable = FBD_Variable(self.Preview, INOUT, name, type) |
|
579 |
width, height = self.MinVariableSize |
|
580 |
min_width, min_height = self.Variable.GetMinSize() |
|
581 |
width, height = max(min_width, width), max(min_height, height) |
|
582 |
self.Variable.SetSize(width, height) |
|
583 |
clientsize = self.Preview.GetClientSize() |
|
584 |
x = (clientsize.width - width) / 2 |
|
585 |
y = (clientsize.height - height) / 2 |
|
586 |
self.Variable.SetPosition(x, y) |
|
587 |
self.Variable.Draw(dc) |
|
588 |
||
589 |
def OnPaint(self, event): |
|
590 |
self.RefreshPreview() |
|
591 |
||
592 |
#------------------------------------------------------------------------------- |
|
593 |
# Create New Connection Dialog |
|
594 |
#------------------------------------------------------------------------------- |
|
595 |
||
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
596 |
[wxID_CONNECTIONPROPERTIESDIALOG, wxID_CONNECTIONPROPERTIESDIALOGSPACER, |
27 | 597 |
wxID_CONNECTIONPROPERTIESDIALOGNAME, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, |
598 |
wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, wxID_CONNECTIONPROPERTIESDIALOGPREVIEW, |
|
599 |
wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, |
|
600 |
wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, |
|
601 |
] = [wx.NewId() for _init_ctrls in range(9)] |
|
602 |
||
603 |
class ConnectionPropertiesDialog(wx.Dialog): |
|
604 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
605 |
# generated method, don't edit |
|
606 |
||
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
607 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
608 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
609 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
610 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
611 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
612 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
613 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
614 |
parent.AddGrowableRow(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
615 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
616 |
def _init_coll_MainSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
617 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
618 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
619 |
parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
620 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
621 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
622 |
def _init_coll_LeftGridSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
623 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
624 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
625 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
626 |
parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
627 |
parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
628 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
629 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
630 |
parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
631 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
632 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
633 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
634 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
635 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
636 |
parent.AddGrowableRow(3) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
637 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
638 |
def _init_coll_RightGridSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
639 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
640 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
641 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
642 |
parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
643 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
644 |
def _init_coll_RightGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
645 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
646 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
647 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
648 |
parent.AddGrowableRow(1) |
27 | 649 |
|
650 |
def _init_sizers(self): |
|
651 |
# generated method, don't edit |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
652 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
653 |
self.MainSizer = wx.BoxSizer(wxHORIZONTAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
654 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
655 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 656 |
|
657 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
658 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
659 |
self._init_coll_MainSizer_Items(self.MainSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
660 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
661 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
662 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
663 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 664 |
|
665 |
self.SetSizer(self.flexGridSizer1) |
|
666 |
||
667 |
def _init_ctrls(self, prnt): |
|
668 |
# generated method, don't edit |
|
669 |
wx.Dialog.__init__(self, id=wxID_CONNECTIONPROPERTIESDIALOG, |
|
670 |
name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
671 |
size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE, |
|
672 |
title='Connection Properties') |
|
673 |
self.SetClientSize(wx.Size(350, 220)) |
|
674 |
||
675 |
self.staticText1 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
676 |
label='Type:', name='staticText1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
677 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 678 |
|
679 |
self.staticText2 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
680 |
label='Name:', name='staticText2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
681 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 682 |
|
683 |
self.staticText3 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
684 |
label='Preview:', name='staticText3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
685 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 686 |
|
687 |
self.radioButton1 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
688 |
label='Connector', name='radioButton1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
689 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 690 |
EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, self.OnTypeChanged) |
691 |
self.radioButton1.SetValue(True) |
|
692 |
||
693 |
self.radioButton2 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
694 |
label='Continuation', name='radioButton2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
695 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 696 |
EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, self.OnTypeChanged) |
697 |
self.radioButton2.SetValue(False) |
|
698 |
||
699 |
self.Name = wx.TextCtrl(id=wxID_CONNECTIONPROPERTIESDIALOGNAME, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
700 |
name='Name', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
701 |
size=wx.Size(0, 24), style=0) |
27 | 702 |
EVT_TEXT(self, wxID_CONNECTIONPROPERTIESDIALOGNAME, self.OnNameChanged) |
703 |
||
704 |
self.Preview = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGPREVIEW, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
705 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
706 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
27 | 707 |
self.Preview.SetBackgroundColour(wxColour(255,255,255)) |
42 | 708 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
27 | 709 |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
710 |
self.Spacer = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGSPACER, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
711 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
712 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
713 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
714 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
715 |
|
27 | 716 |
self._init_sizers() |
717 |
||
718 |
def __init__(self, parent): |
|
719 |
self._init_ctrls(parent) |
|
720 |
self.Connection = None |
|
721 |
self.MinConnectionSize = None |
|
722 |
||
723 |
EVT_PAINT(self, self.OnPaint) |
|
724 |
||
725 |
def SetMinConnectionSize(self, size): |
|
726 |
self.MinConnectionSize = size |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
727 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
728 |
def SetValues(self, values): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
729 |
for name, value in values.items(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
730 |
if name == "type": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
731 |
if value == CONNECTOR: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
732 |
self.radioButton1.SetValue(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
733 |
elif value == CONTINUATION: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
734 |
self.radioButton2.SetValue(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
735 |
elif name == "name": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
736 |
self.Name.SetValue(value) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
737 |
self.RefreshPreview() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
738 |
|
27 | 739 |
def GetValues(self): |
740 |
values = {} |
|
741 |
if self.radioButton1.GetValue(): |
|
742 |
values["type"] = CONNECTOR |
|
743 |
else: |
|
744 |
values["type"] = CONTINUATION |
|
745 |
values["name"] = self.Name.GetValue() |
|
746 |
values["width"], values["height"] = self.Connection.GetSize() |
|
747 |
return values |
|
748 |
||
749 |
def OnTypeChanged(self, event): |
|
750 |
self.RefreshPreview() |
|
751 |
event.Skip() |
|
752 |
||
753 |
def OnNameChanged(self, event): |
|
754 |
self.RefreshPreview() |
|
755 |
event.Skip() |
|
756 |
||
757 |
def RefreshPreview(self): |
|
758 |
dc = wxClientDC(self.Preview) |
|
759 |
dc.Clear() |
|
760 |
if self.radioButton1.GetValue(): |
|
761 |
self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.Name.GetValue()) |
|
762 |
else: |
|
763 |
self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.Name.GetValue()) |
|
764 |
width, height = self.MinConnectionSize |
|
765 |
min_width, min_height = self.Connection.GetMinSize() |
|
766 |
width, height = max(min_width, width), max(min_height, height) |
|
767 |
self.Connection.SetSize(width, height) |
|
768 |
clientsize = self.Preview.GetClientSize() |
|
769 |
x = (clientsize.width - width) / 2 |
|
770 |
y = (clientsize.height - height) / 2 |
|
771 |
self.Connection.SetPosition(x, y) |
|
772 |
self.Connection.Draw(dc) |
|
773 |
||
774 |
def OnPaint(self, event): |
|
775 |
self.RefreshPreview() |
|
776 |
||
777 |
||
778 |
#------------------------------------------------------------------------------- |
|
779 |
# Edit Ladder Element Properties Dialog |
|
780 |
#------------------------------------------------------------------------------- |
|
781 |
||
782 |
||
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
783 |
[wxID_LDELEMENTDIALOG, wxID_LDELEMENTDIALOGSPACER, |
27 | 784 |
wxID_LDELEMENTDIALOGNAME, wxID_LDELEMENTDIALOGRADIOBUTTON1, |
785 |
wxID_LDELEMENTDIALOGRADIOBUTTON2, wxID_LDELEMENTDIALOGRADIOBUTTON3, |
|
786 |
wxID_LDELEMENTDIALOGRADIOBUTTON4, wxID_LDELEMENTDIALOGPREVIEW, |
|
787 |
wxID_LDELEMENTDIALOGSTATICTEXT1, wxID_LDELEMENTDIALOGSTATICTEXT2, |
|
788 |
wxID_LDELEMENTDIALOGSTATICTEXT3, |
|
789 |
] = [wx.NewId() for _init_ctrls in range(11)] |
|
790 |
||
791 |
class LDElementDialog(wx.Dialog): |
|
792 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
793 |
# generated method, don't edit |
|
794 |
||
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
795 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
796 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
797 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
798 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
799 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
800 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
801 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
802 |
parent.AddGrowableRow(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
803 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
804 |
def _init_coll_MainSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
805 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
806 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
807 |
parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
808 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
809 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
810 |
def _init_coll_LeftGridSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
811 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
812 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
813 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
814 |
parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
815 |
parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
816 |
parent.AddWindow(self.radioButton3, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
817 |
parent.AddWindow(self.radioButton4, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
818 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
819 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
820 |
parent.AddWindow(self.Name, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
821 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
822 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
823 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
824 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
825 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
826 |
parent.AddGrowableRow(5) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
827 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
828 |
def _init_coll_RightGridSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
829 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
830 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
831 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
832 |
parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
833 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
834 |
def _init_coll_RightGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
835 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
836 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
837 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
838 |
parent.AddGrowableRow(1) |
27 | 839 |
|
840 |
def _init_sizers(self): |
|
841 |
# generated method, don't edit |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
842 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
843 |
self.MainSizer = wx.BoxSizer(wxHORIZONTAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
844 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
845 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 846 |
|
847 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
848 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
849 |
self._init_coll_MainSizer_Items(self.MainSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
850 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
851 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
852 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
853 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 854 |
|
855 |
self.SetSizer(self.flexGridSizer1) |
|
856 |
||
857 |
def _init_ctrls(self, prnt, title, labels): |
|
858 |
# generated method, don't edit |
|
859 |
wx.Dialog.__init__(self, id=wxID_LDELEMENTDIALOG, |
|
860 |
name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
861 |
size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, |
|
862 |
title=title) |
|
863 |
self.SetClientSize(wx.Size(350, 260)) |
|
864 |
||
865 |
self.staticText1 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT1, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
866 |
label='Modifier:', name='staticText1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
867 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 868 |
|
869 |
self.staticText2 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT2, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
870 |
label='Name:', name='staticText2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
871 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 872 |
|
873 |
self.staticText3 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT3, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
874 |
label='Preview:', name='staticText3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
875 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 876 |
|
877 |
self.radioButton1 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON1, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
878 |
label=labels[0], name='radioButton1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
879 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 880 |
EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON1, self.OnTypeChanged) |
881 |
self.radioButton1.SetValue(True) |
|
882 |
||
883 |
self.radioButton2 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON2, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
884 |
label=labels[1], name='radioButton2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
885 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 886 |
EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON2, self.OnTypeChanged) |
887 |
||
888 |
self.radioButton3 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON3, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
889 |
label=labels[2], name='radioButton3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
890 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 891 |
EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON3, self.OnTypeChanged) |
892 |
||
893 |
self.radioButton4 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON4, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
894 |
label=labels[3], name='radioButton4', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
895 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 896 |
EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON4, self.OnTypeChanged) |
897 |
||
898 |
self.Name = wx.Choice(id=wxID_LDELEMENTDIALOGNAME, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
899 |
name='Name', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
900 |
size=wx.Size(0, 24), style=0) |
27 | 901 |
EVT_CHOICE(self, wxID_LDELEMENTDIALOGNAME, self.OnNameChanged) |
902 |
||
903 |
self.Preview = wx.Panel(id=wxID_LDELEMENTDIALOGPREVIEW, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
904 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
905 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
27 | 906 |
self.Preview.SetBackgroundColour(wxColour(255,255,255)) |
42 | 907 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
27 | 908 |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
909 |
self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
910 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
911 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
912 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
913 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
914 |
|
27 | 915 |
self._init_sizers() |
916 |
||
917 |
def __init__(self, parent, type): |
|
918 |
self.Type = type |
|
919 |
if type == "contact": |
|
920 |
self._init_ctrls(parent, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge']) |
|
921 |
self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") |
|
922 |
elif type == "coil": |
|
923 |
self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset']) |
|
924 |
self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") |
|
925 |
self.Element.SetPosition((150 - LD_ELEMENT_SIZE[0]) / 2, (150 - LD_ELEMENT_SIZE[1]) / 2) |
|
926 |
||
927 |
EVT_PAINT(self, self.OnPaint) |
|
928 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
929 |
def SetElementSize(self, size): |
27 | 930 |
min_width, min_height = self.Element.GetMinSize() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
931 |
width, height = max(min_width, size[0]), max(min_height, size[1]) |
27 | 932 |
self.Element.SetSize(width, height) |
933 |
self.Element.SetPosition((150 - width) / 2, (150 - height) / 2) |
|
934 |
||
935 |
def SetVariables(self, vars): |
|
936 |
self.Name.Clear() |
|
937 |
for name in vars: |
|
938 |
self.Name.Append(name) |
|
939 |
self.Name.Enable(self.Name.GetCount() > 0) |
|
940 |
||
941 |
def SetValues(self, values): |
|
942 |
for name, value in values.items(): |
|
943 |
if name == "name": |
|
944 |
self.Element.SetName(value) |
|
945 |
self.Name.SetStringSelection(value) |
|
946 |
elif name == "type": |
|
947 |
self.Element.SetType(value) |
|
948 |
if self.Type == "contact": |
|
949 |
if value == CONTACT_NORMAL: |
|
950 |
self.radioButton1.SetValue(True) |
|
951 |
elif value == CONTACT_REVERSE: |
|
952 |
self.radioButton2.SetValue(True) |
|
953 |
elif value == CONTACT_RISING: |
|
954 |
self.radioButton3.SetValue(True) |
|
955 |
elif value == CONTACT_FALLING: |
|
956 |
self.radioButton4.SetValue(True) |
|
957 |
elif self.Type == "coil": |
|
958 |
if value == COIL_NORMAL: |
|
959 |
self.radioButton1.SetValue(True) |
|
960 |
elif value == COIL_REVERSE: |
|
961 |
self.radioButton2.SetValue(True) |
|
962 |
elif value == COIL_SET: |
|
963 |
self.radioButton3.SetValue(True) |
|
964 |
elif value == COIL_RESET: |
|
965 |
self.radioButton4.SetValue(True) |
|
966 |
||
967 |
def GetValues(self): |
|
968 |
values = {} |
|
969 |
values["name"] = self.Element.GetName() |
|
970 |
values["type"] = self.Element.GetType() |
|
971 |
values["width"], values["height"] = self.Element.GetSize() |
|
972 |
return values |
|
973 |
||
974 |
def OnTypeChanged(self, event): |
|
975 |
if self.Type == "contact": |
|
976 |
if self.radioButton1.GetValue(): |
|
977 |
self.Element.SetType(CONTACT_NORMAL) |
|
978 |
elif self.radioButton2.GetValue(): |
|
979 |
self.Element.SetType(CONTACT_REVERSE) |
|
980 |
elif self.radioButton3.GetValue(): |
|
981 |
self.Element.SetType(CONTACT_RISING) |
|
982 |
elif self.radioButton4.GetValue(): |
|
983 |
self.Element.SetType(CONTACT_FALLING) |
|
984 |
elif self.Type == "coil": |
|
985 |
if self.radioButton1.GetValue(): |
|
986 |
self.Element.SetType(COIL_NORMAL) |
|
987 |
elif self.radioButton2.GetValue(): |
|
988 |
self.Element.SetType(COIL_REVERSE) |
|
989 |
elif self.radioButton3.GetValue(): |
|
990 |
self.Element.SetType(COIL_SET) |
|
991 |
elif self.radioButton4.GetValue(): |
|
992 |
self.Element.SetType(COIL_RESET) |
|
993 |
self.RefreshPreview() |
|
994 |
event.Skip() |
|
995 |
||
996 |
def OnNameChanged(self, event): |
|
997 |
self.Element.SetName(self.Name.GetStringSelection()) |
|
998 |
self.RefreshPreview() |
|
999 |
event.Skip() |
|
1000 |
||
1001 |
def RefreshPreview(self): |
|
1002 |
dc = wxClientDC(self.Preview) |
|
1003 |
dc.Clear() |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1004 |
clientsize = self.Preview.GetClientSize() |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1005 |
width, height = self.Element.GetSize() |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1006 |
self.Element.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2) |
27 | 1007 |
self.Element.Draw(dc) |
1008 |
||
1009 |
def OnPaint(self, event): |
|
1010 |
self.RefreshPreview() |
|
1011 |
event.Skip() |
|
1012 |
||
1013 |
||
1014 |
#------------------------------------------------------------------------------- |
|
1015 |
# Edit Ladder Power Rail Properties Dialog |
|
1016 |
#------------------------------------------------------------------------------- |
|
1017 |
||
1018 |
||
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1019 |
[wxID_LDPOWERRAILDIALOG, wxID_LDPOWERRAILDIALOGSPACER, |
27 | 1020 |
wxID_LDPOWERRAILDIALOGTYPE, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, |
1021 |
wxID_LDPOWERRAILDIALOGRADIOBUTTON2, wxID_LDPOWERRAILDIALOGPREVIEW, |
|
1022 |
wxID_LDPOWERRAILDIALOGSTATICTEXT1, wxID_LDPOWERRAILDIALOGSTATICTEXT2, |
|
1023 |
wxID_LDPOWERRAILDIALOGSTATICTEXT3, wxID_LDPOWERRAILDIALOGPINNUMBER, |
|
1024 |
] = [wx.NewId() for _init_ctrls in range(10)] |
|
1025 |
||
1026 |
class LDPowerRailDialog(wx.Dialog): |
|
1027 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1028 |
# generated method, don't edit |
|
1029 |
||
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1030 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1031 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1032 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1033 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1034 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1035 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1036 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1037 |
parent.AddGrowableRow(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1038 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1039 |
def _init_coll_MainSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1040 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1041 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1042 |
parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1043 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1044 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1045 |
def _init_coll_LeftGridSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1046 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1047 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1048 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1049 |
parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1050 |
parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1051 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1052 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1053 |
parent.AddWindow(self.PinNumber, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1054 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1055 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1056 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1057 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1058 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1059 |
parent.AddGrowableRow(3) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1060 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1061 |
def _init_coll_RightGridSizer_Items(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1062 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1063 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1064 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1065 |
parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1066 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1067 |
def _init_coll_RightGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1068 |
# generated method, don't edit |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1069 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1070 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1071 |
parent.AddGrowableRow(1) |
27 | 1072 |
|
1073 |
def _init_sizers(self): |
|
1074 |
# generated method, don't edit |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1075 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1076 |
self.MainSizer = wx.BoxSizer(wxHORIZONTAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1077 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1078 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 1079 |
|
1080 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1081 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1082 |
self._init_coll_MainSizer_Items(self.MainSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1083 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1084 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1085 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1086 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 1087 |
|
1088 |
self.SetSizer(self.flexGridSizer1) |
|
1089 |
||
1090 |
def _init_ctrls(self, prnt): |
|
1091 |
# generated method, don't edit |
|
1092 |
wx.Dialog.__init__(self, id=wxID_LDPOWERRAILDIALOG, |
|
1093 |
name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1094 |
size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, |
|
1095 |
title='Power Rail Properties') |
|
1096 |
self.SetClientSize(wx.Size(350, 260)) |
|
1097 |
||
1098 |
self.staticText1 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT1, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1099 |
label='Type:', name='staticText1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1100 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 1101 |
|
1102 |
self.staticText2 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT2, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1103 |
label='Pin number:', name='staticText2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1104 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 1105 |
|
1106 |
self.staticText3 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT3, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1107 |
label='Preview:', name='staticText3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1108 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 1109 |
|
1110 |
self.radioButton1 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON1, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1111 |
label='Left PowerRail', name='radioButton1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1112 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 1113 |
EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, self.OnTypeChanged) |
1114 |
self.radioButton1.SetValue(True) |
|
1115 |
||
1116 |
self.radioButton2 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON2, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1117 |
label='Right PowerRail', name='radioButton2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1118 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
27 | 1119 |
EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON2, self.OnTypeChanged) |
1120 |
||
1121 |
self.PinNumber = wx.SpinCtrl(id=wxID_LDPOWERRAILDIALOGPINNUMBER, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1122 |
name='PinNumber', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1123 |
size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=1, max=20) |
27 | 1124 |
EVT_SPINCTRL(self, wxID_LDPOWERRAILDIALOGPINNUMBER, self.OnPinNumberChanged) |
1125 |
||
1126 |
self.Preview = wx.Panel(id=wxID_LDPOWERRAILDIALOGPREVIEW, |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1127 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1128 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
27 | 1129 |
self.Preview.SetBackgroundColour(wxColour(255,255,255)) |
42 | 1130 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
27 | 1131 |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1132 |
self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1133 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1134 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1135 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1136 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1137 |
|
27 | 1138 |
self._init_sizers() |
1139 |
||
1140 |
def __init__(self, parent, type = LEFTRAIL, number = 1): |
|
1141 |
self._init_ctrls(parent) |
|
1142 |
self.Type = type |
|
1143 |
if type == LEFTRAIL: |
|
1144 |
self.radioButton1.SetValue(True) |
|
1145 |
elif type == RIGHTRAIL: |
|
1146 |
self.radioButton2.SetValue(True) |
|
1147 |
self.PinNumber.SetValue(number) |
|
1148 |
||
1149 |
self.PowerRailMinSize = (0, 0) |
|
1150 |
self.PowerRail = None |
|
1151 |
||
1152 |
EVT_PAINT(self, self.OnPaint) |
|
1153 |
||
1154 |
def SetMinSize(self, size): |
|
1155 |
self.PowerRailMinSize = size |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1156 |
self.RefreshPreview() |
27 | 1157 |
|
1158 |
def GetValues(self): |
|
1159 |
values = {} |
|
1160 |
values["type"] = self.Type |
|
1161 |
values["number"] = self.PinNumber.GetValue() |
|
1162 |
values["width"], values["height"] = self.PowerRail.GetSize() |
|
1163 |
return values |
|
1164 |
||
1165 |
def OnTypeChanged(self, event): |
|
1166 |
if self.radioButton1.GetValue(): |
|
1167 |
self.Type = LEFTRAIL |
|
1168 |
elif self.radioButton2.GetValue(): |
|
1169 |
self.Type = RIGHTRAIL |
|
1170 |
self.RefreshPreview() |
|
1171 |
event.Skip() |
|
1172 |
||
1173 |
def OnPinNumberChanged(self, event): |
|
1174 |
self.RefreshPreview() |
|
1175 |
event.Skip() |
|
1176 |
||
1177 |
def RefreshPreview(self): |
|
1178 |
dc = wxClientDC(self.Preview) |
|
1179 |
dc.Clear() |
|
1180 |
self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())]) |
|
1181 |
min_width, min_height = self.PowerRail.GetMinSize() |
|
1182 |
width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1]) |
|
1183 |
self.PowerRail.SetSize(width, height) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1184 |
clientsize = self.Preview.GetClientSize() |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1185 |
self.PowerRail.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2) |
27 | 1186 |
self.PowerRail.Draw(dc) |
1187 |
||
1188 |
def OnPaint(self, event): |
|
1189 |
self.RefreshPreview() |
|
1190 |
event.Skip() |
|
1191 |
||
1192 |
||
1193 |
#------------------------------------------------------------------------------- |
|
1194 |
# Edit Transition Content Dialog |
|
1195 |
#------------------------------------------------------------------------------- |
|
1196 |
||
1197 |
[wxID_TRANSITIONCONTENTDIALOG, wxID_TRANSITIONCONTENTDIALOGMAINPANEL, |
|
1198 |
wxID_TRANSITIONCONTENTDIALOGREFERENCE, wxID_TRANSITIONCONTENTDIALOGINLINE, |
|
1199 |
wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, |
|
1200 |
] = [wx.NewId() for _init_ctrls in range(6)] |
|
1201 |
||
1202 |
class TransitionContentDialog(wx.Dialog): |
|
1203 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1204 |
# generated method, don't edit |
|
1205 |
||
1206 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1207 |
||
1208 |
def _init_sizers(self): |
|
1209 |
# generated method, don't edit |
|
1210 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1211 |
||
1212 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1213 |
||
1214 |
self.SetSizer(self.flexGridSizer1) |
|
1215 |
||
1216 |
def _init_ctrls(self, prnt): |
|
1217 |
# generated method, don't edit |
|
1218 |
wx.Dialog.__init__(self, id=wxID_TRANSITIONCONTENTDIALOG, |
|
1219 |
name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1220 |
size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE, |
|
1221 |
title='Edit transition') |
|
1222 |
self.SetClientSize(wx.Size(300, 200)) |
|
1223 |
||
1224 |
self.MainPanel = wx.Panel(id=wxID_TRANSITIONCONTENTDIALOGMAINPANEL, |
|
1225 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1226 |
size=wx.Size(300, 200), style=wx.TAB_TRAVERSAL) |
|
1227 |
self.MainPanel.SetAutoLayout(True) |
|
1228 |
||
1229 |
self.radioButton1 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, |
|
1230 |
label='Reference', name='radioButton1', parent=self.MainPanel, |
|
1231 |
pos=wx.Point(24, 24), size=wx.Size(114, 24), style=0) |
|
1232 |
EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, self.OnTypeChanged) |
|
1233 |
self.radioButton1.SetValue(True) |
|
1234 |
||
1235 |
self.Reference = wx.Choice(id=wxID_TRANSITIONCONTENTDIALOGREFERENCE, |
|
1236 |
name='Reference', parent=self.MainPanel, pos=wx.Point(48, 48), |
|
1237 |
size=wx.Size(200, 24), style=0) |
|
1238 |
||
1239 |
self.radioButton2 = wx.RadioButton(id=wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, |
|
1240 |
label='Inline', name='radioButton2', parent=self.MainPanel, |
|
1241 |
pos=wx.Point(24, 72), size=wx.Size(114, 24), style=0) |
|
1242 |
EVT_RADIOBUTTON(self, wxID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, self.OnTypeChanged) |
|
1243 |
self.radioButton2.SetValue(False) |
|
1244 |
||
1245 |
self.Inline = wx.TextCtrl(id=wxID_TRANSITIONCONTENTDIALOGINLINE, |
|
1246 |
name='Inline', parent=self.MainPanel, pos=wx.Point(48, 96), |
|
1247 |
size=wx.Size(200, 24), style=0) |
|
1248 |
||
1249 |
self._init_sizers() |
|
1250 |
||
1251 |
def __init__(self, parent): |
|
1252 |
self._init_ctrls(parent) |
|
1253 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
|
1254 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
|
1255 |
||
1256 |
EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) |
|
1257 |
||
1258 |
def OnOK(self, event): |
|
1259 |
error = [] |
|
1260 |
if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "": |
|
1261 |
error.append("Reference") |
|
1262 |
if self.radioButton2.GetValue() and self.Inline.GetValue() == "": |
|
1263 |
error.append("Inline") |
|
1264 |
if len(error) > 0: |
|
1265 |
text = "" |
|
1266 |
for i, item in enumerate(error): |
|
1267 |
if i == 0: |
|
1268 |
text += item |
|
1269 |
elif i == len(error) - 1: |
|
1270 |
text += " and %s"%item |
|
1271 |
else: |
|
1272 |
text += ", %s"%item |
|
1273 |
message = wxMessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wxOK|wxICON_ERROR) |
|
1274 |
message.ShowModal() |
|
1275 |
message.Destroy() |
|
1276 |
else: |
|
1277 |
self.EndModal(wxID_OK) |
|
1278 |
||
1279 |
def OnTypeChanged(self, event): |
|
1280 |
if self.radioButton1.GetValue(): |
|
1281 |
self.Reference.Enable(True) |
|
1282 |
self.Inline.Enable(False) |
|
1283 |
else: |
|
1284 |
self.Reference.Enable(False) |
|
1285 |
self.Inline.Enable(True) |
|
1286 |
event.Skip() |
|
1287 |
||
1288 |
def SetTransitions(self, transitions): |
|
1289 |
for transition in transitions: |
|
1290 |
self.Reference.Append(transition) |
|
1291 |
||
1292 |
def SetValues(self, values): |
|
1293 |
if values["type"] == "reference": |
|
1294 |
self.radioButton1.SetValue(True) |
|
1295 |
self.radioButton2.SetValue(False) |
|
1296 |
self.Reference.Enable(True) |
|
1297 |
self.Inline.Enable(False) |
|
1298 |
self.Reference.SetStringSelection(values["value"]) |
|
1299 |
elif values["type"] == "inline": |
|
1300 |
self.radioButton1.SetValue(False) |
|
1301 |
self.radioButton2.SetValue(True) |
|
1302 |
self.Reference.Enable(False) |
|
1303 |
self.Inline.Enable(True) |
|
1304 |
self.Inline.SetValue(values["value"]) |
|
1305 |
||
1306 |
def GetValues(self): |
|
1307 |
values = {} |
|
1308 |
if self.radioButton1.GetValue(): |
|
1309 |
values["type"] = "reference" |
|
1310 |
values["value"] = self.Reference.GetStringSelection() |
|
1311 |
else: |
|
1312 |
values["type"] = "inline" |
|
1313 |
values["value"] = self.Inline.GetValue() |
|
1314 |
return values |
|
1315 |
||
1316 |
#------------------------------------------------------------------------------- |
|
1317 |
# Create New Divergence Dialog |
|
1318 |
#------------------------------------------------------------------------------- |
|
1319 |
||
1320 |
[wxID_DIVERGENCECREATEDIALOG, wxID_DIVERGENCECREATEDIALOGMAINPANEL, |
|
1321 |
wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, |
|
1322 |
wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, |
|
1323 |
wxID_DIVERGENCECREATEDIALOGSEQUENCES, wxID_DIVERGENCECREATEDIALOGPREVIEW, |
|
1324 |
wxID_DIVERGENCECREATEDIALOGSTATICTEXT1, wxID_DIVERGENCECREATEDIALOGSTATICTEXT2, |
|
1325 |
wxID_DIVERGENCECREATEDIALOGSTATICTEXT3, |
|
1326 |
] = [wx.NewId() for _init_ctrls in range(11)] |
|
1327 |
||
1328 |
class DivergenceCreateDialog(wx.Dialog): |
|
1329 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1330 |
# generated method, don't edit |
|
1331 |
||
1332 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1333 |
||
1334 |
def _init_sizers(self): |
|
1335 |
# generated method, don't edit |
|
1336 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1337 |
||
1338 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1339 |
||
1340 |
self.SetSizer(self.flexGridSizer1) |
|
1341 |
||
1342 |
def _init_ctrls(self, prnt): |
|
1343 |
# generated method, don't edit |
|
1344 |
wx.Dialog.__init__(self, id=wxID_DIVERGENCECREATEDIALOG, |
|
1345 |
name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1346 |
size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE, |
|
1347 |
title='Create a new divergence or convergence') |
|
1348 |
self.SetClientSize(wx.Size(500, 260)) |
|
1349 |
||
1350 |
self.MainPanel = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGMAINPANEL, |
|
1351 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1352 |
size=wx.Size(600, 220), style=wx.TAB_TRAVERSAL) |
|
1353 |
self.MainPanel.SetAutoLayout(True) |
|
1354 |
||
1355 |
self.staticText1 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT1, |
|
1356 |
label='Type:', name='staticText1', parent=self.MainPanel, |
|
1357 |
pos=wx.Point(24, 24), size=wx.Size(200, 17), style=0) |
|
1358 |
||
1359 |
self.radioButton1 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, |
|
1360 |
label='Selection Divergence', name='radioButton1', parent=self.MainPanel, |
|
1361 |
pos=wx.Point(24, 48), size=wx.Size(200, 24), style=0) |
|
1362 |
EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON1, self.OnTypeChanged) |
|
1363 |
self.radioButton1.SetValue(True) |
|
1364 |
||
1365 |
self.radioButton2 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, |
|
1366 |
label='Selection Convergence', name='radioButton2', parent=self.MainPanel, |
|
1367 |
pos=wx.Point(24, 72), size=wx.Size(200, 24), style=0) |
|
1368 |
EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON2, self.OnTypeChanged) |
|
1369 |
self.radioButton2.SetValue(False) |
|
1370 |
||
1371 |
self.radioButton3 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, |
|
1372 |
label='Simultaneous Divergence', name='radioButton3', parent=self.MainPanel, |
|
1373 |
pos=wx.Point(24, 96), size=wx.Size(200, 24), style=0) |
|
1374 |
EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON3, self.OnTypeChanged) |
|
1375 |
self.radioButton3.SetValue(False) |
|
1376 |
||
1377 |
self.radioButton4 = wx.RadioButton(id=wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, |
|
1378 |
label='Simultaneous Convergence', name='radioButton4', parent=self.MainPanel, |
|
1379 |
pos=wx.Point(24, 120), size=wx.Size(200, 24), style=0) |
|
1380 |
EVT_RADIOBUTTON(self, wxID_DIVERGENCECREATEDIALOGRADIOBUTTON4, self.OnTypeChanged) |
|
1381 |
self.radioButton4.SetValue(False) |
|
1382 |
||
1383 |
self.staticText2 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT2, |
|
1384 |
label='Number of sequences:', name='staticText2', parent=self.MainPanel, |
|
1385 |
pos=wx.Point(24, 150), size=wx.Size(200, 17), style=0) |
|
1386 |
||
1387 |
self.Sequences = wx.SpinCtrl(id=wxID_DIVERGENCECREATEDIALOGSEQUENCES, |
|
1388 |
name='Sequences', parent=self.MainPanel, pos=wx.Point(24, 174), |
|
1389 |
size=wx.Size(200, 24), style=0, min=2, max=20) |
|
1390 |
EVT_SPINCTRL(self, wxID_DIVERGENCECREATEDIALOGSEQUENCES, self.OnSequencesChanged) |
|
1391 |
||
1392 |
self.staticText3 = wx.StaticText(id=wxID_DIVERGENCECREATEDIALOGSTATICTEXT3, |
|
1393 |
label='Preview:', name='staticText3', parent=self.MainPanel, |
|
1394 |
pos=wx.Point(250, 24), size=wx.Size(100, 17), style=0) |
|
1395 |
||
1396 |
self.Preview = wx.Panel(id=wxID_DIVERGENCECREATEDIALOGPREVIEW, |
|
1397 |
name='Preview', parent=self.MainPanel, pos=wx.Point(250, 48), |
|
1398 |
size=wx.Size(225, 150), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
|
1399 |
self.Preview.SetBackgroundColour(wxColour(255,255,255)) |
|
42 | 1400 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
27 | 1401 |
|
1402 |
self._init_sizers() |
|
1403 |
||
1404 |
def __init__(self, parent): |
|
1405 |
self._init_ctrls(parent) |
|
1406 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
|
1407 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
|
1408 |
||
1409 |
self.Divergence = None |
|
1410 |
self.MinSize = (0, 0) |
|
1411 |
||
1412 |
EVT_PAINT(self, self.OnPaint) |
|
1413 |
||
1414 |
def GetValues(self): |
|
1415 |
values = {} |
|
1416 |
if self.radioButton1.GetValue(): |
|
1417 |
values["type"] = SELECTION_DIVERGENCE |
|
1418 |
elif self.radioButton2.GetValue(): |
|
1419 |
values["type"] = SELECTION_CONVERGENCE |
|
1420 |
elif self.radioButton3.GetValue(): |
|
1421 |
values["type"] = SIMULTANEOUS_DIVERGENCE |
|
1422 |
else: |
|
1423 |
values["type"] = SIMULTANEOUS_CONVERGENCE |
|
1424 |
values["number"] = self.Sequences.GetValue() |
|
1425 |
return values |
|
1426 |
||
1427 |
def SetMinSize(self, size): |
|
1428 |
self.MinSize = size |
|
1429 |
||
1430 |
def OnTypeChanged(self, event): |
|
1431 |
self.RefreshPreview() |
|
1432 |
event.Skip() |
|
1433 |
||
1434 |
def OnSequencesChanged(self, event): |
|
1435 |
self.RefreshPreview() |
|
1436 |
event.Skip() |
|
1437 |
||
1438 |
def RefreshPreview(self): |
|
1439 |
dc = wxClientDC(self.Preview) |
|
1440 |
dc.Clear() |
|
1441 |
if self.radioButton1.GetValue(): |
|
1442 |
self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue()) |
|
1443 |
elif self.radioButton2.GetValue(): |
|
1444 |
self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue()) |
|
1445 |
elif self.radioButton3.GetValue(): |
|
1446 |
self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_DIVERGENCE, self.Sequences.GetValue()) |
|
1447 |
else: |
|
1448 |
self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_CONVERGENCE, self.Sequences.GetValue()) |
|
1449 |
width, height = self.Divergence.GetSize() |
|
1450 |
min_width, min_height = max(width, self.MinSize[0]), max(height, self.MinSize[1]) |
|
1451 |
self.Divergence.SetSize(min_width, min_height) |
|
1452 |
clientsize = self.Preview.GetClientSize() |
|
1453 |
x = (clientsize.width - min_width) / 2 |
|
1454 |
y = (clientsize.height - min_height) / 2 |
|
1455 |
self.Divergence.SetPosition(x, y) |
|
1456 |
self.Divergence.Draw(dc) |
|
1457 |
||
1458 |
def OnPaint(self, event): |
|
1459 |
self.RefreshPreview() |
|
1460 |
||
1461 |
||
1462 |
#------------------------------------------------------------------------------- |
|
1463 |
# Action Block Dialog |
|
1464 |
#------------------------------------------------------------------------------- |
|
1465 |
||
1466 |
class ActionTable(wxPyGridTableBase): |
|
1467 |
||
1468 |
""" |
|
1469 |
A custom wxGrid Table using user supplied data |
|
1470 |
""" |
|
1471 |
def __init__(self, parent, data, colnames): |
|
1472 |
# The base class must be initialized *first* |
|
1473 |
wxPyGridTableBase.__init__(self) |
|
1474 |
self.data = data |
|
1475 |
self.colnames = colnames |
|
1476 |
self.Parent = parent |
|
1477 |
# XXX |
|
1478 |
# we need to store the row length and collength to |
|
1479 |
# see if the table has changed size |
|
1480 |
self._rows = self.GetNumberRows() |
|
1481 |
self._cols = self.GetNumberCols() |
|
1482 |
||
1483 |
def GetNumberCols(self): |
|
1484 |
return len(self.colnames) |
|
1485 |
||
1486 |
def GetNumberRows(self): |
|
1487 |
return len(self.data) |
|
1488 |
||
1489 |
def GetColLabelValue(self, col): |
|
1490 |
if col < len(self.colnames): |
|
1491 |
return self.colnames[col] |
|
1492 |
||
1493 |
def GetRowLabelValues(self, row): |
|
1494 |
return row |
|
1495 |
||
1496 |
def GetValue(self, row, col): |
|
1497 |
if row < self.GetNumberRows(): |
|
1498 |
name = str(self.data[row].get(self.GetColLabelValue(col), "")) |
|
1499 |
return name |
|
1500 |
||
1501 |
def GetValueByName(self, row, colname): |
|
1502 |
return self.data[row].get(colname) |
|
1503 |
||
1504 |
def SetValue(self, row, col, value): |
|
1505 |
if col < len(self.colnames): |
|
1506 |
self.data[row][self.GetColLabelValue(col)] = value |
|
1507 |
||
1508 |
def ResetView(self, grid): |
|
1509 |
""" |
|
1510 |
(wxGrid) -> Reset the grid view. Call this to |
|
1511 |
update the grid if rows and columns have been added or deleted |
|
1512 |
""" |
|
1513 |
grid.BeginBatch() |
|
1514 |
for current, new, delmsg, addmsg in [ |
|
1515 |
(self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED), |
|
1516 |
(self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED), |
|
1517 |
]: |
|
1518 |
if new < current: |
|
1519 |
msg = wxGridTableMessage(self,delmsg,new,current-new) |
|
1520 |
grid.ProcessTableMessage(msg) |
|
1521 |
elif new > current: |
|
1522 |
msg = wxGridTableMessage(self,addmsg,new-current) |
|
1523 |
grid.ProcessTableMessage(msg) |
|
1524 |
self.UpdateValues(grid) |
|
1525 |
grid.EndBatch() |
|
1526 |
||
1527 |
self._rows = self.GetNumberRows() |
|
1528 |
self._cols = self.GetNumberCols() |
|
1529 |
# update the column rendering scheme |
|
1530 |
self._updateColAttrs(grid) |
|
1531 |
||
1532 |
# update the scrollbars and the displayed part of the grid |
|
1533 |
grid.AdjustScrollbars() |
|
1534 |
grid.ForceRefresh() |
|
1535 |
||
1536 |
def UpdateValues(self, grid): |
|
1537 |
"""Update all displayed values""" |
|
1538 |
# This sends an event to the grid table to update all of the values |
|
1539 |
msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES) |
|
1540 |
grid.ProcessTableMessage(msg) |
|
1541 |
||
1542 |
def _updateColAttrs(self, grid): |
|
1543 |
""" |
|
1544 |
wxGrid -> update the column attributes to add the |
|
1545 |
appropriate renderer given the column name. |
|
1546 |
||
1547 |
Otherwise default to the default renderer. |
|
1548 |
""" |
|
1549 |
||
1550 |
for col in range(self.GetNumberCols()): |
|
1551 |
attr = wxGridCellAttr() |
|
1552 |
attr.SetAlignment(self.Parent.ColAlignements[col], wxALIGN_CENTRE) |
|
1553 |
grid.SetColAttr(col, attr) |
|
1554 |
grid.SetColSize(col, self.Parent.ColSizes[col]) |
|
1555 |
||
1556 |
typelist = None |
|
1557 |
accesslist = None |
|
1558 |
for row in range(self.GetNumberRows()): |
|
1559 |
for col in range(self.GetNumberCols()): |
|
1560 |
editor = None |
|
1561 |
renderer = None |
|
1562 |
readonly = False |
|
1563 |
colname = self.GetColLabelValue(col) |
|
1564 |
if colname == "Qualifier": |
|
1565 |
editor = wxGridCellChoiceEditor() |
|
1566 |
editor.SetParameters(self.Parent.QualifierList) |
|
1567 |
if colname == "Duration": |
|
1568 |
editor = wxGridCellTextEditor() |
|
1569 |
renderer = wxGridCellStringRenderer() |
|
1570 |
if self.Parent.DurationList[self.data[row]["Qualifier"]]: |
|
1571 |
readonly = False |
|
1572 |
else: |
|
1573 |
readonly = True |
|
1574 |
self.data[row]["Duration"] = "" |
|
1575 |
elif colname == "Type": |
|
1576 |
editor = wxGridCellChoiceEditor() |
|
1577 |
editor.SetParameters(self.Parent.TypeList) |
|
1578 |
elif colname == "Value": |
|
1579 |
type = self.data[row]["Type"] |
|
1580 |
if type == "Action": |
|
1581 |
editor = wxGridCellChoiceEditor() |
|
1582 |
editor.SetParameters(self.Parent.ActionList) |
|
1583 |
elif type == "Variable": |
|
1584 |
editor = wxGridCellChoiceEditor() |
|
1585 |
editor.SetParameters(self.Parent.VariableList) |
|
1586 |
elif type == "Inline": |
|
1587 |
editor = wxGridCellTextEditor() |
|
1588 |
renderer = wxGridCellStringRenderer() |
|
1589 |
elif colname == "Indicator": |
|
1590 |
editor = wxGridCellChoiceEditor() |
|
1591 |
editor.SetParameters(self.Parent.VariableList) |
|
1592 |
||
1593 |
grid.SetCellEditor(row, col, editor) |
|
1594 |
grid.SetCellRenderer(row, col, renderer) |
|
1595 |
grid.SetReadOnly(row, col, readonly) |
|
1596 |
||
1597 |
grid.SetCellBackgroundColour(row, col, wxWHITE) |
|
1598 |
||
1599 |
def SetData(self, data): |
|
1600 |
self.data = data |
|
1601 |
||
1602 |
def GetData(self): |
|
1603 |
return self.data |
|
1604 |
||
1605 |
def GetCurrentIndex(self): |
|
1606 |
return self.CurrentIndex |
|
1607 |
||
1608 |
def SetCurrentIndex(self, index): |
|
1609 |
self.CurrentIndex = index |
|
1610 |
||
1611 |
def AppendRow(self, row_content): |
|
1612 |
self.data.append(row_content) |
|
1613 |
||
1614 |
def RemoveRow(self, row_index): |
|
1615 |
self.data.pop(row_index) |
|
1616 |
||
1617 |
def MoveRow(self, row_index, move, grid): |
|
1618 |
new_index = max(0, min(row_index + move, len(self.data) - 1)) |
|
1619 |
if new_index != row_index: |
|
1620 |
self.data.insert(new_index, self.data.pop(row_index)) |
|
1621 |
grid.SetGridCursor(new_index, grid.GetGridCursorCol()) |
|
1622 |
||
1623 |
def Empty(self): |
|
1624 |
self.data = [] |
|
1625 |
self.editors = [] |
|
1626 |
||
1627 |
[wxID_ACTIONBLOCKDIALOG, wxID_ACTIONBLOCKDIALOGMAINPANEL, |
|
1628 |
wxID_ACTIONBLOCKDIALOGVARIABLESGRID, wxID_ACTIONBLOCKDIALOGSTATICTEXT1, |
|
1629 |
wxID_ACTIONBLOCKDIALOGADDBUTTON,wxID_ACTIONBLOCKDIALOGDELETEBUTTON, |
|
1630 |
wxID_ACTIONBLOCKDIALOGUPBUTTON, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, |
|
1631 |
] = [wx.NewId() for _init_ctrls in range(8)] |
|
1632 |
||
1633 |
class ActionBlockDialog(wx.Dialog): |
|
1634 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
1635 |
# generated method, don't edit |
|
1636 |
||
1637 |
parent.AddWindow(self.MainPanel, 0, border=0, flag=0) |
|
1638 |
||
1639 |
def _init_sizers(self): |
|
1640 |
# generated method, don't edit |
|
1641 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
1642 |
||
1643 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1644 |
||
1645 |
self.SetSizer(self.flexGridSizer1) |
|
1646 |
||
1647 |
def _init_ctrls(self, prnt): |
|
1648 |
# generated method, don't edit |
|
1649 |
wx.Dialog.__init__(self, id=wxID_ACTIONBLOCKDIALOG, |
|
1650 |
name='ActionBlockDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1651 |
size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE, |
|
1652 |
title='Edit action block properties') |
|
1653 |
self.SetClientSize(wx.Size(500, 300)) |
|
1654 |
||
1655 |
self.MainPanel = wx.Panel(id=wxID_ACTIONBLOCKDIALOGMAINPANEL, |
|
1656 |
name='MainPanel', parent=self, pos=wx.Point(0, 0), |
|
1657 |
size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL) |
|
1658 |
self.MainPanel.SetAutoLayout(True) |
|
1659 |
||
1660 |
self.staticText1 = wx.StaticText(id=wxID_ACTIONBLOCKDIALOGSTATICTEXT1, |
|
1661 |
label='Actions:', name='staticText1', parent=self.MainPanel, |
|
1662 |
pos=wx.Point(24, 24), size=wx.Size(95, 17), style=0) |
|
1663 |
||
1664 |
self.ActionsGrid = wx.grid.Grid(id=wxID_ACTIONBLOCKDIALOGVARIABLESGRID, |
|
1665 |
name='ActionsGrid', parent=self.MainPanel, pos=wx.Point(24, 44), |
|
1666 |
size=wx.Size(450, 150), style=wxVSCROLL) |
|
1667 |
self.ActionsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
|
1668 |
'Sans')) |
|
1669 |
self.ActionsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
|
1670 |
False, 'Sans')) |
|
1671 |
self.ActionsGrid.DisableDragGridSize() |
|
1672 |
self.ActionsGrid.EnableScrolling(False, True) |
|
1673 |
EVT_GRID_CELL_CHANGE(self.ActionsGrid, self.OnActionsGridCellChange) |
|
1674 |
||
1675 |
self.AddButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGADDBUTTON, label='Add', |
|
1676 |
name='AddButton', parent=self.MainPanel, pos=wx.Point(245, 204), |
|
1677 |
size=wx.Size(72, 32), style=0) |
|
1678 |
EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGADDBUTTON, self.OnAddButton) |
|
1679 |
||
1680 |
self.DeleteButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDELETEBUTTON, label='Delete', |
|
1681 |
name='DeleteButton', parent=self.MainPanel, pos=wx.Point(325, 204), |
|
1682 |
size=wx.Size(72, 32), style=0) |
|
1683 |
EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDELETEBUTTON, self.OnDeleteButton) |
|
1684 |
||
1685 |
self.UpButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGUPBUTTON, label='^', |
|
1686 |
name='UpButton', parent=self.MainPanel, pos=wx.Point(405, 204), |
|
1687 |
size=wx.Size(32, 32), style=0) |
|
1688 |
EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGUPBUTTON, self.OnUpButton) |
|
1689 |
||
1690 |
self.DownButton = wx.Button(id=wxID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v', |
|
1691 |
name='DownButton', parent=self.MainPanel, pos=wx.Point(445, 204), |
|
1692 |
size=wx.Size(32, 32), style=0) |
|
1693 |
EVT_BUTTON(self, wxID_ACTIONBLOCKDIALOGDOWNBUTTON, self.OnDownButton) |
|
1694 |
||
1695 |
self._init_sizers() |
|
1696 |
||
1697 |
def __init__(self, parent): |
|
1698 |
self._init_ctrls(parent) |
|
1699 |
self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE) |
|
1700 |
self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT) |
|
1701 |
||
1702 |
self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""} |
|
1703 |
self.Table = ActionTable(self, [], ["Qualifier","Duration","Type","Value","Indicator"]) |
|
1704 |
self.TypeList = "Action,Variable,Inline" |
|
1705 |
self.ColSizes = [60, 90, 80, 110, 80] |
|
1706 |
self.ColAlignements = [wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT] |
|
1707 |
||
1708 |
self.ActionsGrid.SetTable(self.Table) |
|
1709 |
self.ActionsGrid.SetRowLabelSize(0) |
|
1710 |
||
1711 |
self.Table.ResetView(self.ActionsGrid) |
|
1712 |
||
1713 |
def OnAddButton(self, event): |
|
1714 |
self.Table.AppendRow(self.DefaultValue.copy()) |
|
1715 |
self.Table.ResetView(self.ActionsGrid) |
|
1716 |
event.Skip() |
|
1717 |
||
1718 |
def OnDeleteButton(self, event): |
|
1719 |
row = self.ActionsGrid.GetGridCursorRow() |
|
1720 |
self.Table.RemoveRow(row) |
|
1721 |
self.Table.ResetView(self.ActionsGrid) |
|
1722 |
event.Skip() |
|
1723 |
||
1724 |
def OnUpButton(self, event): |
|
1725 |
row = self.ActionsGrid.GetGridCursorRow() |
|
1726 |
self.Table.MoveRow(row, -1, self.ActionsGrid) |
|
1727 |
self.Table.ResetView(self.ActionsGrid) |
|
1728 |
event.Skip() |
|
1729 |
||
1730 |
def OnDownButton(self, event): |
|
1731 |
row = self.ActionsGrid.GetGridCursorRow() |
|
1732 |
self.Table.MoveRow(row, 1, self.ActionsGrid) |
|
1733 |
self.Table.ResetView(self.ActionsGrid) |
|
1734 |
event.Skip() |
|
1735 |
||
1736 |
def OnActionsGridCellChange(self, event): |
|
1737 |
self.Table.ResetView(self.ActionsGrid) |
|
1738 |
event.Skip() |
|
1739 |
||
1740 |
def SetQualifierList(self, list): |
|
1741 |
self.QualifierList = "" |
|
1742 |
sep = "" |
|
1743 |
for qualifier in list.keys(): |
|
1744 |
self.QualifierList += "%s%s"%(sep, qualifier) |
|
1745 |
sep = "," |
|
1746 |
self.DurationList = list |
|
1747 |
||
1748 |
def SetVariableList(self, list): |
|
1749 |
self.VariableList = "" |
|
1750 |
sep = "" |
|
1751 |
for variable in list: |
|
1752 |
self.VariableList += "%s%s"%(sep, variable["Name"]) |
|
1753 |
sep = "," |
|
1754 |
||
1755 |
def SetActionList(self, list): |
|
1756 |
self.ActionList = "" |
|
1757 |
sep = "" |
|
1758 |
for action in list: |
|
1759 |
self.ActionList += "%s%s"%(sep, action) |
|
1760 |
sep = "," |
|
1761 |
||
1762 |
def SetValues(self, actions): |
|
1763 |
for action in actions: |
|
1764 |
row = {"Qualifier" : action["qualifier"], "Value" : action["value"]} |
|
1765 |
if action["type"] == "reference": |
|
1766 |
if action["value"] in self.ActionList: |
|
1767 |
row["Type"] = "Action" |
|
1768 |
elif action["value"] in self.VariableList: |
|
1769 |
row["Type"] = "Variable" |
|
1770 |
else: |
|
1771 |
row["Type"] = "Inline" |
|
1772 |
else: |
|
1773 |
row["Type"] = "Inline" |
|
1774 |
if "duration" in action: |
|
1775 |
row["Duration"] = action["duration"] |
|
1776 |
else: |
|
1777 |
row["Duration"] = "" |
|
1778 |
if "indicator" in action: |
|
1779 |
row["Indicator"] = action["indicator"] |
|
1780 |
else: |
|
1781 |
row["Indicator"] = "" |
|
1782 |
self.Table.AppendRow(row) |
|
1783 |
self.Table.ResetView(self.ActionsGrid) |
|
1784 |
||
1785 |
def GetValues(self): |
|
1786 |
values = [] |
|
1787 |
for data in self.Table.GetData(): |
|
1788 |
action = {"qualifier" : data["Qualifier"], "value" : data["Value"]} |
|
1789 |
if data["Type"] in ["Action", "Variable"]: |
|
1790 |
action["type"] = "reference" |
|
1791 |
else: |
|
1792 |
action["type"] = "inline" |
|
1793 |
if data["Duration"] != "": |
|
1794 |
action["duration"] = data["Duration"] |
|
1795 |
if data["Indicator"] != "": |
|
1796 |
action["indicator"] = data["Indicator"] |
|
1797 |
values.append(action) |
|
1798 |
return values |
|
1799 |
||
1800 |
||
1801 |
#------------------------------------------------------------------------------- |
|
1802 |
# Edit Step Name Dialog |
|
1803 |
#------------------------------------------------------------------------------- |
|
1804 |
||
1805 |
class StepNameDialog(wxTextEntryDialog): |
|
1806 |
||
1807 |
def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", |
|
1808 |
style = wxOK|wxCANCEL|wxCENTRE, pos = wxDefaultPosition): |
|
1809 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
|
1810 |
||
1811 |
self.PouNames = [] |
|
1812 |
self.Variables = [] |
|
1813 |
self.StepNames = [] |
|
1814 |
||
1815 |
EVT_BUTTON(self, self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId(), self.OnOK) |
|
1816 |
||
1817 |
def OnOK(self, event): |
|
1818 |
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
1819 |
if step_name == "": |
|
1820 |
message = wxMessageDialog(self, "You must type a name!", "Error", wxOK|wxICON_ERROR) |
|
1821 |
message.ShowModal() |
|
1822 |
message.Destroy() |
|
1823 |
elif not TestIdentifier(step_name): |
|
1824 |
message = wxMessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wxOK|wxICON_ERROR) |
|
1825 |
message.ShowModal() |
|
1826 |
message.Destroy() |
|
1827 |
elif step_name.upper() in IEC_KEYWORDS: |
|
1828 |
message = wxMessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wxOK|wxICON_ERROR) |
|
1829 |
message.ShowModal() |
|
1830 |
message.Destroy() |
|
1831 |
elif step_name.upper() in self.PouNames: |
|
1832 |
message = wxMessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR) |
|
1833 |
message.ShowModal() |
|
1834 |
message.Destroy() |
|
1835 |
elif step_name.upper() in self.Variables: |
|
1836 |
message = wxMessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wxOK|wxICON_ERROR) |
|
1837 |
message.ShowModal() |
|
1838 |
message.Destroy() |
|
1839 |
elif step_name.upper() in self.StepNames: |
|
1840 |
message = wxMessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wxOK|wxICON_ERROR) |
|
1841 |
message.ShowModal() |
|
1842 |
message.Destroy() |
|
1843 |
else: |
|
1844 |
self.EndModal(wxID_OK) |
|
1845 |
||
1846 |
def SetPouNames(self, pou_names): |
|
1847 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
1848 |
||
1849 |
def SetVariables(self, variables): |
|
1850 |
self.Variables = [var["Name"].upper() for var in variables] |
|
1851 |
||
1852 |
def SetStepNames(self, step_names): |
|
1853 |
self.StepNames = [step_name.upper() for step_name in step_names] |
|
1854 |
||
42 | 1855 |
def GetValue(self): |
1856 |
return self.GetSizer().GetItem(1).GetWindow().GetValue() |