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