author | lbessard |
Mon, 15 Sep 2008 13:37:03 +0200 | |
changeset 270 | 351d134babd7 |
parent 269 | 34eff05909b0 |
child 271 | 4405cd3abbdb |
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, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
37 |
ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
38 |
ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
39 |
ID_BLOCKPROPERTIESDIALOGSTATICTEXT3, ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
40 |
ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, ID_BLOCKPROPERTIESDIALOGSTATICTEXT6, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
41 |
] = [wx.NewId() for _init_ctrls in range(14)] |
27 | 42 |
|
43 |
[CATEGORY, BLOCK] = range(2) |
|
44 |
||
45 |
class BlockPropertiesDialog(wx.Dialog): |
|
113 | 46 |
|
47 |
if wx.VERSION < (2, 6, 0): |
|
48 |
def Bind(self, event, function, id = None): |
|
49 |
if id is not None: |
|
50 |
event(self, id, function) |
|
51 |
else: |
|
52 |
event(self, function) |
|
53 |
||
27 | 54 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
55 |
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
|
56 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
58 | 57 |
|
58 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
|
59 |
parent.AddGrowableCol(0) |
|
60 |
parent.AddGrowableRow(0) |
|
61 |
||
62 |
def _init_coll_MainSizer_Items(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
63 |
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
|
64 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) |
58 | 65 |
|
66 |
def _init_coll_LeftBoxSizer_Items(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
67 |
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
|
68 |
parent.AddWindow(self.TypeDesc, 1, border=0, flag=wx.GROW) |
58 | 69 |
|
70 |
def _init_coll_RightGridSizer_Items(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
71 |
parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
72 |
parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
73 |
parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
58 | 74 |
|
75 |
def _init_coll_RightGridSizer_Growables(self, parent): |
|
76 |
parent.AddGrowableCol(0) |
|
77 |
parent.AddGrowableRow(2) |
|
78 |
||
79 |
def _init_coll_RightUpGridSizer_Items(self, parent): |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
80 |
parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP) |
95 | 81 |
parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
82 |
parent.AddWindow(self.staticText3, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
83 |
parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
84 |
parent.AddWindow(self.staticText4, 0, border=4, flag=wx.GROW|wx.TOP) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
85 |
parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
86 |
parent.AddWindow(self.staticText5, 0, border=4, flag=wx.GROW|wx.TOP) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
87 |
parent.AddWindow(self.ExecutionControl, 0, border=0, flag=wx.GROW) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
88 |
|
27 | 89 |
def _init_sizers(self): |
58 | 90 |
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
|
91 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
92 |
self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL) |
58 | 93 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
94 |
self.RightUpGridSizer = wx.GridSizer(cols=2, hgap=5, rows=4, vgap=5) |
58 | 95 |
|
27 | 96 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
58 | 97 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
98 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
99 |
self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
|
100 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
|
101 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
|
102 |
self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer) |
|
103 |
||
27 | 104 |
self.SetSizer(self.flexGridSizer1) |
105 |
||
106 |
def _init_ctrls(self, prnt): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
107 |
wx.Dialog.__init__(self, id=ID_BLOCKPROPERTIESDIALOG, |
27 | 108 |
name='BlockPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
109 |
size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
27 | 110 |
title='Block Properties') |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
111 |
self.SetClientSize(wx.Size(600, 400)) |
27 | 112 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
113 |
self.staticbox1 = wx.StaticBox(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT1, |
58 | 114 |
label='Type:', name='staticBox1', parent=self, |
115 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
|
27 | 116 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
117 |
self.staticText2 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
58 | 118 |
label='Name:', name='staticText2', parent=self, |
119 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 120 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
121 |
self.staticText3 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT2, |
58 | 122 |
label='Inputs:', name='staticText4', parent=self, |
123 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 124 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
125 |
self.staticText4 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT4, |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
126 |
label='Execution Order:', name='staticText4', parent=self, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
127 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
128 |
|
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
129 |
self.staticText5 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT5, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
130 |
label='Execution Control:', name='staticText5', parent=self, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
131 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
132 |
|
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
133 |
self.staticText6 = wx.StaticText(id=ID_BLOCKPROPERTIESDIALOGSTATICTEXT6, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
134 |
label='Preview:', name='staticText6', parent=self, |
58 | 135 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 136 |
|
95 | 137 |
if wx.Platform == '__WXMSW__': |
138 |
treestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
|
139 |
else: |
|
140 |
treestyle = 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
|
141 |
self.TypeTree = wx.TreeCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPETREE, |
58 | 142 |
name='TypeTree', parent=self, pos=wx.Point(0, 0), |
105
d8284a8f1934
Bug on linux in BlockPropertiesDialog (root visible) fixed
lbessard
parents:
101
diff
changeset
|
143 |
size=wx.Size(0, 0), style=treestyle) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
144 |
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
|
145 |
id=ID_BLOCKPROPERTIESDIALOGTYPETREE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
146 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
147 |
self.TypeDesc = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGTYPEDESC, |
58 | 148 |
name='TypeDesc', parent=self, pos=wx.Point(0, 0), |
149 |
size=wx.Size(0, 0), style=wx.TE_READONLY|wx.TE_MULTILINE) |
|
27 | 150 |
|
95 | 151 |
self.BlockName = wx.TextCtrl(id=ID_BLOCKPROPERTIESDIALOGNAME, value='', |
152 |
name='BlockName', parent=self, pos=wx.Point(0, 0), |
|
58 | 153 |
size=wx.Size(0, 24), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
154 |
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
|
155 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
156 |
self.Inputs = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGINPUTS, |
58 | 157 |
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
|
158 |
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
|
159 |
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
|
160 |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
161 |
self.ExecutionOrder = wx.SpinCtrl(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
162 |
name='ExecutionOrder', parent=self, pos=wx.Point(0, 0), |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
163 |
size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
164 |
self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONORDER) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
165 |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
166 |
self.ExecutionControl = wx.CheckBox(id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
167 |
name='ExecutionControl', parent=self, pos=wx.Point(0, 0), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
168 |
size=wx.Size(0, 24), style=0) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
169 |
self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, id=ID_BLOCKPROPERTIESDIALOGEXECUTIONCONTROL) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
170 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
171 |
self.Preview = wx.Panel(id=ID_BLOCKPROPERTIESDIALOGPREVIEW, |
58 | 172 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
173 |
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
|
174 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
42 | 175 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
145 | 176 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
177 |
setattr(self.Preview, "GetBlockType", self.Controler.GetBlockType) |
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
178 |
setattr(self.Preview, "IsOfType", self.Controler.IsOfType) |
27 | 179 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
180 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
113 | 181 |
if wx.VERSION >= (2, 5, 0): |
182 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
|
183 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
184 |
else: |
|
185 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
186 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
58 | 187 |
|
27 | 188 |
self._init_sizers() |
189 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
190 |
def __init__(self, parent, controler): |
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
191 |
self.Controler = controler |
27 | 192 |
self._init_ctrls(parent) |
95 | 193 |
self.BlockName.SetValue("") |
194 |
self.BlockName.Enable(False) |
|
27 | 195 |
self.Inputs.Enable(False) |
196 |
self.Block = None |
|
197 |
self.MinBlockSize = None |
|
113 | 198 |
self.First = True |
70 | 199 |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
200 |
self.staticText5.Hide() |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
201 |
self.ExecutionControl.Hide() |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
202 |
|
70 | 203 |
self.PouNames = [] |
204 |
self.PouElementNames = [] |
|
27 | 205 |
|
165 | 206 |
def SetPreviewFont(self, font): |
207 |
self.Preview.SetFont(font) |
|
208 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
209 |
def FindTreeItem(self, root, name, inputs = None): |
27 | 210 |
if root.IsOk(): |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
211 |
pydata = self.TypeTree.GetPyData(root) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
212 |
if inputs and "inputs" in pydata: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
213 |
same_inputs = pydata["inputs"] == inputs |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
214 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
215 |
same_inputs = True |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
216 |
if self.TypeTree.GetItemText(root) == name and same_inputs: |
27 | 217 |
return root |
218 |
else: |
|
113 | 219 |
if wx.VERSION < (2, 6, 0): |
220 |
item, root_cookie = self.TypeTree.GetFirstChild(root, 0) |
|
221 |
else: |
|
222 |
item, root_cookie = self.TypeTree.GetFirstChild(root) |
|
27 | 223 |
while item.IsOk(): |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
224 |
result = self.FindTreeItem(item, name, inputs) |
27 | 225 |
if result: |
226 |
return result |
|
227 |
item, root_cookie = self.TypeTree.GetNextChild(root, root_cookie) |
|
228 |
return None |
|
229 |
||
230 |
def OnOK(self, event): |
|
231 |
error = [] |
|
232 |
selected = self.TypeTree.GetSelection() |
|
95 | 233 |
block_name = self.BlockName.GetValue() |
234 |
name_enabled = self.BlockName.IsEnabled() |
|
27 | 235 |
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
|
236 |
message = wx.MessageDialog(self, "Form isn't complete. Valid block type must be selected!", "Error", wx.OK|wx.ICON_ERROR) |
27 | 237 |
message.ShowModal() |
238 |
message.Destroy() |
|
70 | 239 |
elif name_enabled and block_name == "": |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
240 |
message = wx.MessageDialog(self, "Form isn't complete. Name must be filled!", "Error", wx.OK|wx.ICON_ERROR) |
27 | 241 |
message.ShowModal() |
242 |
message.Destroy() |
|
70 | 243 |
elif name_enabled and not TestIdentifier(block_name): |
244 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%block_name, "Error", wx.OK|wx.ICON_ERROR) |
|
245 |
message.ShowModal() |
|
246 |
message.Destroy() |
|
247 |
elif name_enabled and block_name.upper() in IEC_KEYWORDS: |
|
248 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%block_name, "Error", wx.OK|wx.ICON_ERROR) |
|
249 |
message.ShowModal() |
|
250 |
message.Destroy() |
|
251 |
elif name_enabled and block_name.upper() in self.PouNames: |
|
252 |
message = wx.MessageDialog(self, "\"%s\" pou already exists!"%block_name, "Error", wx.OK|wx.ICON_ERROR) |
|
253 |
message.ShowModal() |
|
254 |
message.Destroy() |
|
255 |
elif name_enabled and block_name.upper() in self.PouElementNames: |
|
256 |
message = wx.MessageDialog(self, "\"%s\" element for this pou already exists!"%block_name, "Error", wx.OK|wx.ICON_ERROR) |
|
257 |
message.ShowModal() |
|
258 |
message.Destroy() |
|
27 | 259 |
else: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
260 |
self.EndModal(wx.ID_OK) |
27 | 261 |
|
262 |
def SetBlockList(self, blocktypes): |
|
95 | 263 |
if wx.Platform == '__WXMSW__': |
264 |
root = self.TypeTree.AddRoot("Block Types") |
|
265 |
else: |
|
266 |
root = self.TypeTree.AddRoot("") |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
267 |
self.TypeTree.SetPyData(root, {"type" : CATEGORY}) |
27 | 268 |
for category in blocktypes: |
269 |
category_item = self.TypeTree.AppendItem(root, category["name"]) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
270 |
self.TypeTree.SetPyData(category_item, {"type" : CATEGORY}) |
27 | 271 |
for blocktype in category["list"]: |
272 |
blocktype_item = self.TypeTree.AppendItem(category_item, blocktype["name"]) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
273 |
self.TypeTree.SetPyData(blocktype_item, {"type" : BLOCK, "inputs" : tuple([type for name, type, modifier in blocktype["inputs"]])}) |
95 | 274 |
if wx.Platform == '__WXMSW__': |
275 |
self.TypeTree.Expand(root) |
|
27 | 276 |
|
277 |
def SetMinBlockSize(self, size): |
|
278 |
self.MinBlockSize = size |
|
279 |
||
70 | 280 |
def SetPouNames(self, pou_names): |
281 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
282 |
||
283 |
def SetPouElementNames(self, element_names): |
|
284 |
self.PouElementNames = [element_name.upper() for element_name in element_names] |
|
285 |
||
27 | 286 |
def SetValues(self, values): |
287 |
for name, value in values.items(): |
|
288 |
if name == "type": |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
289 |
inputs = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
290 |
if "inputs" in values: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
291 |
inputs = values["inputs"] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
292 |
item = self.FindTreeItem(self.TypeTree.GetRootItem(), value, inputs) |
27 | 293 |
if item: |
294 |
self.TypeTree.SelectItem(item) |
|
295 |
elif name == "name": |
|
95 | 296 |
self.BlockName.SetValue(value) |
27 | 297 |
elif name == "extension": |
298 |
self.Inputs.SetValue(value) |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
299 |
elif name == "executionOrder": |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
300 |
self.ExecutionOrder.SetValue(value) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
301 |
elif name == "executionControl": |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
302 |
self.ExecutionControl.SetValue(value) |
27 | 303 |
self.RefreshPreview() |
304 |
||
305 |
def GetValues(self): |
|
306 |
values = {} |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
307 |
item = self.TypeTree.GetSelection() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
308 |
values["type"] = self.TypeTree.GetItemText(item) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
309 |
values["inputs"] = self.TypeTree.GetPyData(item)["inputs"] |
95 | 310 |
if self.BlockName.GetValue() != "": |
311 |
values["name"] = self.BlockName.GetValue() |
|
27 | 312 |
values["width"], values["height"] = self.Block.GetSize() |
313 |
values["extension"] = self.Inputs.GetValue() |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
314 |
values["executionOrder"] = self.ExecutionOrder.GetValue() |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
315 |
values["executionControl"] = self.ExecutionControl.GetValue() |
27 | 316 |
return values |
317 |
||
318 |
def OnTypeTreeItemSelected(self, event): |
|
95 | 319 |
self.BlockName.SetValue("") |
27 | 320 |
selected = event.GetItem() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
321 |
pydata = self.TypeTree.GetPyData(selected) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
322 |
if pydata["type"] != CATEGORY: |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
323 |
blocktype = self.Controler.GetBlockType(self.TypeTree.GetItemText(selected), pydata["inputs"]) |
27 | 324 |
if blocktype: |
325 |
self.Inputs.SetValue(len(blocktype["inputs"])) |
|
326 |
self.Inputs.Enable(blocktype["extensible"]) |
|
95 | 327 |
self.BlockName.Enable(blocktype["type"] != "function") |
27 | 328 |
self.TypeDesc.SetValue(blocktype["comment"]) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
329 |
wx.CallAfter(self.RefreshPreview) |
27 | 330 |
else: |
95 | 331 |
self.BlockName.Enable(False) |
27 | 332 |
self.Inputs.Enable(False) |
333 |
self.Inputs.SetValue(2) |
|
334 |
self.TypeDesc.SetValue("") |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
335 |
wx.CallAfter(self.ErasePreview) |
27 | 336 |
else: |
95 | 337 |
self.BlockName.Enable(False) |
27 | 338 |
self.Inputs.Enable(False) |
339 |
self.Inputs.SetValue(2) |
|
340 |
self.TypeDesc.SetValue("") |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
341 |
wx.CallAfter(self.ErasePreview) |
27 | 342 |
event.Skip() |
343 |
||
344 |
def OnNameChanged(self, event): |
|
95 | 345 |
if self.BlockName.IsEnabled(): |
27 | 346 |
self.RefreshPreview() |
347 |
event.Skip() |
|
348 |
||
349 |
def OnInputsChanged(self, event): |
|
350 |
if self.Inputs.IsEnabled(): |
|
351 |
self.RefreshPreview() |
|
352 |
event.Skip() |
|
353 |
||
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
354 |
def OnExecutionOrderChanged(self, event): |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
355 |
self.RefreshPreview() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
356 |
event.Skip() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
357 |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
358 |
def OnExecutionControlChanged(self, event): |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
359 |
self.RefreshPreview() |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
360 |
event.Skip() |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
361 |
|
27 | 362 |
def ErasePreview(self): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
363 |
dc = wx.ClientDC(self.Preview) |
27 | 364 |
dc.Clear() |
365 |
self.Block = None |
|
366 |
||
367 |
def RefreshPreview(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
368 |
dc = wx.ClientDC(self.Preview) |
165 | 369 |
dc.SetFont(self.Preview.GetFont()) |
27 | 370 |
dc.Clear() |
371 |
item = self.TypeTree.GetSelection() |
|
80 | 372 |
if item.IsOk(): |
373 |
pydata = self.TypeTree.GetPyData(item) |
|
374 |
if pydata["type"] == CATEGORY: |
|
375 |
self.Block = None |
|
27 | 376 |
else: |
80 | 377 |
blocktype = self.TypeTree.GetItemText(item) |
378 |
if blocktype: |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
379 |
self.Block = FBD_Block(self.Preview, blocktype, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
380 |
self.BlockName.GetValue(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
381 |
extension = self.Inputs.GetValue(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
382 |
inputs = pydata["inputs"], |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
383 |
executionControl = self.ExecutionControl.GetValue(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
384 |
executionOrder = self.ExecutionOrder.GetValue()) |
80 | 385 |
width, height = self.MinBlockSize |
386 |
min_width, min_height = self.Block.GetMinSize() |
|
387 |
width, height = max(min_width, width), max(min_height, height) |
|
388 |
self.Block.SetSize(width, height) |
|
389 |
clientsize = self.Preview.GetClientSize() |
|
390 |
x = (clientsize.width - width) / 2 |
|
391 |
y = (clientsize.height - height) / 2 |
|
392 |
self.Block.SetPosition(x, y) |
|
393 |
self.Block.Draw(dc) |
|
394 |
else: |
|
395 |
self.Block = None |
|
27 | 396 |
|
397 |
def OnPaint(self, event): |
|
113 | 398 |
if self.Block is not None: |
27 | 399 |
self.RefreshPreview() |
95 | 400 |
event.Skip() |
27 | 401 |
|
402 |
#------------------------------------------------------------------------------- |
|
403 |
# Create New Variable Dialog |
|
404 |
#------------------------------------------------------------------------------- |
|
405 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
406 |
[ID_VARIABLEPROPERTIESDIALOG, ID_VARIABLEPROPERTIESDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
407 |
ID_VARIABLEPROPERTIESDIALOGNAME, ID_VARIABLEPROPERTIESDIALOGCLASS, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
408 |
ID_VARIABLEPROPERTIESDIALOGPREVIEW, ID_VARIABLEPROPERTIESDIALOGEXPRESSION, |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
409 |
ID_VARIABLEPROPERTIESDIALOGEXECUTIONORDER, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
410 |
ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
411 |
ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, ID_VARIABLEPROPERTIESDIALOGSTATICTEXT5 |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
412 |
] = [wx.NewId() for _init_ctrls in range(12)] |
27 | 413 |
|
414 |
class VariablePropertiesDialog(wx.Dialog): |
|
113 | 415 |
|
416 |
if wx.VERSION < (2, 6, 0): |
|
417 |
def Bind(self, event, function, id = None): |
|
418 |
if id is not None: |
|
419 |
event(self, id, function) |
|
420 |
else: |
|
421 |
event(self, function) |
|
422 |
||
27 | 423 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
424 |
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
|
425 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
58 | 426 |
|
427 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
|
428 |
parent.AddGrowableCol(0) |
|
429 |
parent.AddGrowableRow(0) |
|
430 |
||
431 |
def _init_coll_MainSizer_Items(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
432 |
parent.AddSizer(self.TopSizer, 0, border=0, flag=wx.GROW) |
128 | 433 |
parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
434 |
parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
58 | 435 |
|
436 |
def _init_coll_MainSizer_Growables(self, parent): |
|
437 |
parent.AddGrowableCol(0) |
|
438 |
parent.AddGrowableRow(2) |
|
439 |
||
440 |
def _init_coll_TopSizer_Items(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
441 |
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
|
442 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) |
58 | 443 |
|
444 |
def _init_coll_LeftGridSizer_Items(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
parent.AddWindow(self.Expression, 0, border=0, flag=wx.GROW) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
449 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
450 |
parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
451 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
58 | 452 |
|
453 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
|
454 |
parent.AddGrowableCol(0) |
|
455 |
parent.AddGrowableRow(2) |
|
456 |
||
457 |
def _init_coll_RightGridSizer_Items(self, parent): |
|
128 | 458 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
95 | 459 |
parent.AddWindow(self.VariableName, 0, border=0, flag=wx.GROW) |
58 | 460 |
|
461 |
def _init_coll_RightGridSizer_Growables(self, parent): |
|
462 |
parent.AddGrowableCol(0) |
|
463 |
parent.AddGrowableRow(1) |
|
464 |
||
27 | 465 |
def _init_sizers(self): |
58 | 466 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
467 |
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
|
468 |
self.TopSizer = wx.BoxSizer(wx.HORIZONTAL) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
469 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) |
58 | 470 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 471 |
|
472 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
58 | 473 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
474 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
475 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
|
476 |
self._init_coll_TopSizer_Items(self.TopSizer) |
|
477 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
|
478 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
|
479 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
|
480 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
|
481 |
||
27 | 482 |
self.SetSizer(self.flexGridSizer1) |
483 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
484 |
def _init_ctrls(self, prnt, ctrler): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
485 |
wx.Dialog.__init__(self, id=ID_VARIABLEPROPERTIESDIALOG, |
27 | 486 |
name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
487 |
size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE, |
27 | 488 |
title='Variable Properties') |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
489 |
self.SetClientSize(wx.Size(400, 380)) |
27 | 490 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
491 |
self.staticText1 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT1, |
58 | 492 |
label='Class:', name='staticText1', parent=self, |
493 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
27 | 494 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
495 |
self.staticText2 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT2, |
58 | 496 |
label='Expression:', name='staticText2', parent=self, |
497 |
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
|
498 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
499 |
self.staticText3 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT3, |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
500 |
label='Execution Order:', name='staticText3', parent=self, |
58 | 501 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 502 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
503 |
self.staticText4 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT4, |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
504 |
label='Name:', name='staticText4', parent=self, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
505 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
506 |
|
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
507 |
self.staticText5 = wx.StaticText(id=ID_VARIABLEPROPERTIESDIALOGSTATICTEXT5, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
508 |
label='Preview:', name='staticText5', parent=self, |
58 | 509 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 510 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
511 |
self.Class = wx.Choice(id=ID_VARIABLEPROPERTIESDIALOGCLASS, |
58 | 512 |
name='Class', parent=self, pos=wx.Point(0, 0), |
513 |
size=wx.Size(0, 24), style=0) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
514 |
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
|
515 |
|
95 | 516 |
self.VariableName = wx.ListBox(id=ID_VARIABLEPROPERTIESDIALOGNAME, |
58 | 517 |
name='Name', parent=self, pos=wx.Point(0, 0), |
518 |
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
|
519 |
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
|
520 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
521 |
self.Expression = wx.TextCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXPRESSION, |
58 | 522 |
name='Expression', parent=self, pos=wx.Point(0, 0), |
523 |
size=wx.Size(0, 24), style=0) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
524 |
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
|
525 |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
526 |
self.ExecutionOrder = wx.SpinCtrl(id=ID_VARIABLEPROPERTIESDIALOGEXECUTIONORDER, |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
527 |
name='ExecutionOrder', parent=self, pos=wx.Point(0, 0), |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
528 |
size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
529 |
self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_VARIABLEPROPERTIESDIALOGEXECUTIONORDER) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
530 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
531 |
self.Spacer = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGSPACER, |
58 | 532 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
533 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
534 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
535 |
self.Preview = wx.Panel(id=ID_VARIABLEPROPERTIESDIALOGPREVIEW, |
58 | 536 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
537 |
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
|
538 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
42 | 539 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
145 | 540 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
541 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
27 | 542 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
543 |
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
|
544 |
|
113 | 545 |
if wx.VERSION >= (2, 5, 0): |
546 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
547 |
else: |
|
548 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
549 |
||
27 | 550 |
self._init_sizers() |
551 |
||
251
cc5377a296ea
Fix bug in popup menu and function block types in Variable Panel
lbessard
parents:
226
diff
changeset
|
552 |
def __init__(self, parent, controler, transition = ""): |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
553 |
self._init_ctrls(parent, controler) |
251
cc5377a296ea
Fix bug in popup menu and function block types in Variable Panel
lbessard
parents:
226
diff
changeset
|
554 |
self.Transition = transition |
27 | 555 |
self.Variable = None |
556 |
self.VarList = [] |
|
557 |
self.MinVariableSize = None |
|
558 |
self.RefreshNameList() |
|
559 |
||
560 |
for choice in ["Input", "Output", "InOut"]: |
|
561 |
self.Class.Append(choice) |
|
562 |
self.Class.SetStringSelection("Input") |
|
563 |
||
165 | 564 |
def SetPreviewFont(self, font): |
565 |
self.Preview.SetFont(font) |
|
566 |
||
27 | 567 |
def RefreshNameList(self): |
95 | 568 |
selected = self.VariableName.GetStringSelection() |
569 |
self.VariableName.Clear() |
|
570 |
self.VariableName.Append("") |
|
27 | 571 |
for name, var_type, value_type in self.VarList: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
572 |
if var_type in ["Local","Temp","Global","External"]: |
95 | 573 |
self.VariableName.Append(name) |
27 | 574 |
elif var_type == "Input" and self.Class.GetStringSelection() == "Input": |
95 | 575 |
self.VariableName.Append(name) |
27 | 576 |
elif var_type == "Output" and self.Class.GetStringSelection() == "Output": |
255
068935254b28
Bug with output variable and transition test fixed
lbessard
parents:
251
diff
changeset
|
577 |
if self.Transition == "" or name == self.Transition: |
251
cc5377a296ea
Fix bug in popup menu and function block types in Variable Panel
lbessard
parents:
226
diff
changeset
|
578 |
self.VariableName.Append(name) |
27 | 579 |
elif var_type == "InOut" and self.Class.GetStringSelection() == "InOut": |
255
068935254b28
Bug with output variable and transition test fixed
lbessard
parents:
251
diff
changeset
|
580 |
if self.Transition == "" or name == self.Transition: |
251
cc5377a296ea
Fix bug in popup menu and function block types in Variable Panel
lbessard
parents:
226
diff
changeset
|
581 |
self.VariableName.Append(name) |
95 | 582 |
if self.VariableName.FindString(selected) != wx.NOT_FOUND: |
583 |
self.VariableName.SetStringSelection(selected) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
584 |
else: |
95 | 585 |
self.VariableName.SetStringSelection("") |
586 |
self.VariableName.Enable(self.VariableName.GetCount() > 0) |
|
27 | 587 |
|
588 |
def SetMinVariableSize(self, size): |
|
589 |
self.MinVariableSize = size |
|
590 |
||
591 |
def SetVariables(self, vars): |
|
592 |
self.VarList = vars |
|
593 |
self.RefreshNameList() |
|
594 |
||
595 |
def SetValues(self, values): |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
596 |
value_type = values.get("type", None) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
597 |
value_name = values.get("name", None) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
598 |
if value_type: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
599 |
if value_type == INPUT: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
600 |
self.Class.SetStringSelection("Input") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
601 |
if value_type == OUTPUT: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
602 |
self.Class.SetStringSelection("Output") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
603 |
if value_type == INOUT: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
604 |
self.Class.SetStringSelection("InOut") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
605 |
self.RefreshNameList() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
606 |
if value_name: |
95 | 607 |
if self.VariableName.FindString(value_name) != wx.NOT_FOUND: |
608 |
self.VariableName.SetStringSelection(value_name) |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
609 |
self.Expression.Enable(False) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
610 |
else: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
45
diff
changeset
|
611 |
self.Expression.SetValue(value_name) |
95 | 612 |
self.VariableName.Enable(False) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
613 |
if "executionOrder" in values: |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
614 |
self.ExecutionOrder.SetValue(values["executionOrder"]) |
27 | 615 |
self.RefreshPreview() |
616 |
||
617 |
def GetValues(self): |
|
618 |
values = {} |
|
619 |
classtype = self.Class.GetStringSelection() |
|
620 |
if classtype == "Input": |
|
621 |
values["type"] = INPUT |
|
622 |
elif classtype == "Output": |
|
623 |
values["type"] = OUTPUT |
|
624 |
elif classtype == "InOut": |
|
625 |
values["type"] = INOUT |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
626 |
expression = self.Expression.GetValue() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
627 |
if self.Expression.IsEnabled() and expression != "": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
628 |
values["name"] = expression |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
629 |
else: |
95 | 630 |
values["name"] = self.VariableName.GetStringSelection() |
101
3f06a178b960
Fixed crash while draging connector from pins with undefined types
etisserant
parents:
96
diff
changeset
|
631 |
values["value_type"] = None |
27 | 632 |
for var_name, var_type, value_type in self.VarList: |
633 |
if var_name == values["name"]: |
|
634 |
values["value_type"] = value_type |
|
635 |
values["width"], values["height"] = self.Variable.GetSize() |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
636 |
values["executionOrder"] = self.ExecutionOrder.GetValue() |
27 | 637 |
return values |
638 |
||
639 |
def OnClassChanged(self, event): |
|
640 |
self.RefreshNameList() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
641 |
if self.Class.GetStringSelection() == "Input": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
642 |
self.Expression.Enable(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
643 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
644 |
self.Expression.Enable(False) |
27 | 645 |
self.RefreshPreview() |
646 |
event.Skip() |
|
647 |
||
648 |
def OnNameChanged(self, event): |
|
95 | 649 |
if self.VariableName.GetStringSelection() != "": |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
650 |
self.Expression.Enable(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
651 |
elif self.Class.GetStringSelection() == "Input": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
652 |
self.Expression.Enable(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
653 |
self.RefreshPreview() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
654 |
event.Skip() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
655 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
656 |
def OnExpressionChanged(self, event): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
657 |
if self.Expression.GetValue() != "": |
95 | 658 |
self.VariableName.Enable(False) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
659 |
else: |
95 | 660 |
self.VariableName.Enable(True) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
661 |
self.RefreshPreview() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
662 |
event.Skip() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
663 |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
664 |
def OnExecutionOrderChanged(self, event): |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
665 |
self.RefreshPreview() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
666 |
event.Skip() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
667 |
|
27 | 668 |
def RefreshPreview(self): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
669 |
dc = wx.ClientDC(self.Preview) |
165 | 670 |
dc.SetFont(self.Preview.GetFont()) |
27 | 671 |
dc.Clear() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
672 |
expression = self.Expression.GetValue() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
673 |
if self.Expression.IsEnabled() and expression != "": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
674 |
name = expression |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
675 |
else: |
95 | 676 |
name = self.VariableName.GetStringSelection() |
27 | 677 |
type = "" |
678 |
for var_name, var_type, value_type in self.VarList: |
|
679 |
if var_name == name: |
|
680 |
type = value_type |
|
681 |
classtype = self.Class.GetStringSelection() |
|
682 |
if classtype == "Input": |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
683 |
self.Variable = FBD_Variable(self.Preview, INPUT, name, type, executionOrder = self.ExecutionOrder.GetValue()) |
27 | 684 |
elif classtype == "Output": |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
685 |
self.Variable = FBD_Variable(self.Preview, OUTPUT, name, type, executionOrder = self.ExecutionOrder.GetValue()) |
27 | 686 |
elif classtype == "InOut": |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
113
diff
changeset
|
687 |
self.Variable = FBD_Variable(self.Preview, INOUT, name, type, executionOrder = self.ExecutionOrder.GetValue()) |
27 | 688 |
width, height = self.MinVariableSize |
689 |
min_width, min_height = self.Variable.GetMinSize() |
|
690 |
width, height = max(min_width, width), max(min_height, height) |
|
691 |
self.Variable.SetSize(width, height) |
|
692 |
clientsize = self.Preview.GetClientSize() |
|
693 |
x = (clientsize.width - width) / 2 |
|
694 |
y = (clientsize.height - height) / 2 |
|
695 |
self.Variable.SetPosition(x, y) |
|
696 |
self.Variable.Draw(dc) |
|
697 |
||
698 |
def OnPaint(self, event): |
|
699 |
self.RefreshPreview() |
|
95 | 700 |
event.Skip() |
27 | 701 |
|
702 |
#------------------------------------------------------------------------------- |
|
703 |
# Create New Connection Dialog |
|
704 |
#------------------------------------------------------------------------------- |
|
705 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
706 |
[ID_CONNECTIONPROPERTIESDIALOG, ID_CONNECTIONPROPERTIESDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
707 |
ID_CONNECTIONPROPERTIESDIALOGNAME, ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
708 |
ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, ID_CONNECTIONPROPERTIESDIALOGPREVIEW, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
709 |
ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
710 |
ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, |
27 | 711 |
] = [wx.NewId() for _init_ctrls in range(9)] |
712 |
||
713 |
class ConnectionPropertiesDialog(wx.Dialog): |
|
113 | 714 |
|
715 |
if wx.VERSION < (2, 6, 0): |
|
716 |
def Bind(self, event, function, id = None): |
|
717 |
if id is not None: |
|
718 |
event(self, id, function) |
|
719 |
else: |
|
720 |
event(self, function) |
|
721 |
||
27 | 722 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
723 |
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
|
724 |
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
|
725 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
726 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
727 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
728 |
parent.AddGrowableRow(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
729 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
730 |
def _init_coll_MainSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
731 |
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
|
732 |
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
|
733 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
734 |
def _init_coll_LeftGridSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
735 |
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
|
736 |
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
|
737 |
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
|
738 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
95 | 739 |
parent.AddWindow(self.ConnectionName, 0, border=0, flag=wx.GROW) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
740 |
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
|
741 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
742 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
743 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
744 |
parent.AddGrowableRow(5) |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
745 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
746 |
def _init_coll_RightGridSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
747 |
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
|
748 |
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
|
749 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
750 |
def _init_coll_RightGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
751 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
752 |
parent.AddGrowableRow(1) |
27 | 753 |
|
754 |
def _init_sizers(self): |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
755 |
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
|
756 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
757 |
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
|
758 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 759 |
|
760 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
761 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
762 |
self._init_coll_MainSizer_Items(self.MainSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
763 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
764 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
765 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
766 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 767 |
|
768 |
self.SetSizer(self.flexGridSizer1) |
|
769 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
770 |
def _init_ctrls(self, prnt, ctrler): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
771 |
wx.Dialog.__init__(self, id=ID_CONNECTIONPROPERTIESDIALOG, |
27 | 772 |
name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
773 |
size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE, |
|
774 |
title='Connection Properties') |
|
775 |
self.SetClientSize(wx.Size(350, 220)) |
|
776 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
777 |
self.staticText1 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
778 |
label='Type:', name='staticText1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
779 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 780 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
781 |
self.staticText2 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
782 |
label='Name:', name='staticText2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
783 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 784 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
785 |
self.staticText3 = wx.StaticText(id=ID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
786 |
label='Preview:', name='staticText3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
787 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 788 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
789 |
self.radioButton1 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
790 |
label='Connector', name='radioButton1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
791 |
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
|
792 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1) |
27 | 793 |
self.radioButton1.SetValue(True) |
794 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
795 |
self.radioButton2 = wx.RadioButton(id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
796 |
label='Continuation', name='radioButton2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
797 |
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
|
798 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2) |
27 | 799 |
self.radioButton2.SetValue(False) |
800 |
||
95 | 801 |
self.ConnectionName = wx.TextCtrl(id=ID_CONNECTIONPROPERTIESDIALOGNAME, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
802 |
name='Name', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
803 |
size=wx.Size(0, 24), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
804 |
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
|
805 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
806 |
self.Preview = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGPREVIEW, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
807 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
808 |
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
|
809 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
42 | 810 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
145 | 811 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
812 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
27 | 813 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
814 |
self.Spacer = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGSPACER, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
815 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
816 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
817 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
818 |
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
|
819 |
|
113 | 820 |
if wx.VERSION >= (2, 5, 0): |
821 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
822 |
else: |
|
823 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
824 |
|
27 | 825 |
self._init_sizers() |
826 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
827 |
def __init__(self, parent, controler): |
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
828 |
self._init_ctrls(parent, controler) |
27 | 829 |
self.Connection = None |
830 |
self.MinConnectionSize = None |
|
165 | 831 |
|
832 |
def SetPreviewFont(self, font): |
|
833 |
self.Preview.SetFont(font) |
|
834 |
||
27 | 835 |
def SetMinConnectionSize(self, size): |
836 |
self.MinConnectionSize = size |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
837 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
838 |
def SetValues(self, values): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
839 |
for name, value in values.items(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
840 |
if name == "type": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
841 |
if value == CONNECTOR: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
842 |
self.radioButton1.SetValue(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
843 |
elif value == CONTINUATION: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
844 |
self.radioButton2.SetValue(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
845 |
elif name == "name": |
95 | 846 |
self.ConnectionName.SetValue(value) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
847 |
self.RefreshPreview() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
848 |
|
27 | 849 |
def GetValues(self): |
850 |
values = {} |
|
851 |
if self.radioButton1.GetValue(): |
|
852 |
values["type"] = CONNECTOR |
|
853 |
else: |
|
854 |
values["type"] = CONTINUATION |
|
95 | 855 |
values["name"] = self.ConnectionName.GetValue() |
27 | 856 |
values["width"], values["height"] = self.Connection.GetSize() |
857 |
return values |
|
858 |
||
859 |
def OnTypeChanged(self, event): |
|
860 |
self.RefreshPreview() |
|
861 |
event.Skip() |
|
862 |
||
863 |
def OnNameChanged(self, event): |
|
864 |
self.RefreshPreview() |
|
865 |
event.Skip() |
|
866 |
||
867 |
def RefreshPreview(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
868 |
dc = wx.ClientDC(self.Preview) |
165 | 869 |
dc.SetFont(self.Preview.GetFont()) |
27 | 870 |
dc.Clear() |
871 |
if self.radioButton1.GetValue(): |
|
95 | 872 |
self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.ConnectionName.GetValue()) |
27 | 873 |
else: |
95 | 874 |
self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.ConnectionName.GetValue()) |
27 | 875 |
width, height = self.MinConnectionSize |
876 |
min_width, min_height = self.Connection.GetMinSize() |
|
877 |
width, height = max(min_width, width), max(min_height, height) |
|
878 |
self.Connection.SetSize(width, height) |
|
879 |
clientsize = self.Preview.GetClientSize() |
|
880 |
x = (clientsize.width - width) / 2 |
|
881 |
y = (clientsize.height - height) / 2 |
|
882 |
self.Connection.SetPosition(x, y) |
|
883 |
self.Connection.Draw(dc) |
|
884 |
||
885 |
def OnPaint(self, event): |
|
886 |
self.RefreshPreview() |
|
95 | 887 |
event.Skip() |
27 | 888 |
|
889 |
#------------------------------------------------------------------------------- |
|
890 |
# Edit Ladder Element Properties Dialog |
|
891 |
#------------------------------------------------------------------------------- |
|
892 |
||
893 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
894 |
[ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
895 |
ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
896 |
ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
897 |
ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGRADIOBUTTON5, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
898 |
ID_LDELEMENTDIALOGRADIOBUTTON6, ID_LDELEMENTDIALOGPREVIEW, |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
899 |
ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
900 |
ID_LDELEMENTDIALOGSTATICTEXT3, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
901 |
] = [wx.NewId() for _init_ctrls in range(13)] |
27 | 902 |
|
903 |
class LDElementDialog(wx.Dialog): |
|
113 | 904 |
|
905 |
if wx.VERSION < (2, 6, 0): |
|
906 |
def Bind(self, event, function, id = None): |
|
907 |
if id is not None: |
|
908 |
event(self, id, function) |
|
909 |
else: |
|
910 |
event(self, function) |
|
911 |
||
27 | 912 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
913 |
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
|
914 |
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
|
915 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
916 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
917 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
918 |
parent.AddGrowableRow(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
919 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
920 |
def _init_coll_MainSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
921 |
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
|
922 |
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
|
923 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
924 |
def _init_coll_LeftGridSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
925 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
926 |
parent.AddSizer(self.RadioButtonSizer, 0, border=0, flag=wx.GROW) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
927 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
928 |
parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
929 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
930 |
|
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
931 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
932 |
parent.AddGrowableCol(0) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
933 |
parent.AddGrowableRow(7) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
934 |
|
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
935 |
def _init_coll_RadioButtonSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
936 |
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
|
937 |
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
|
938 |
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
|
939 |
parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
940 |
parent.AddWindow(self.radioButton5, 0, border=0, flag=wx.GROW) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
941 |
parent.AddWindow(self.radioButton6, 0, border=0, flag=wx.GROW) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
942 |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
943 |
def _init_coll_RightGridSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
944 |
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
|
945 |
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
|
946 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
947 |
def _init_coll_RightGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
948 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
949 |
parent.AddGrowableRow(1) |
27 | 950 |
|
951 |
def _init_sizers(self): |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
952 |
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
|
953 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
954 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
955 |
self.RadioButtonSizer = wx.BoxSizer(wx.VERTICAL) |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
956 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 957 |
|
958 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
959 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
960 |
self._init_coll_MainSizer_Items(self.MainSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
961 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
962 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
963 |
self._init_coll_RadioButtonSizer_Items(self.RadioButtonSizer) |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
964 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
965 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 966 |
|
967 |
self.SetSizer(self.flexGridSizer1) |
|
968 |
||
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
969 |
def _init_ctrls(self, prnt, ctrler, title, extra_size = 0): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
970 |
wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG, |
71 | 971 |
name='LDElementDialog', parent=prnt, pos=wx.Point(376, 223), |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
972 |
size=wx.Size(350, 260 + extra_size), style=wx.DEFAULT_DIALOG_STYLE, |
27 | 973 |
title=title) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
974 |
self.SetClientSize(wx.Size(350, 260 + extra_size)) |
27 | 975 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
976 |
self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
977 |
label='Modifier:', name='staticText1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
978 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 979 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
980 |
self.staticText2 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT2, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
981 |
label='Name:', name='staticText2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
982 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 983 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
984 |
self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
985 |
label='Preview:', name='staticText3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
986 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 987 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
988 |
self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
989 |
label="Normal", name='radioButton1', parent=self, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
990 |
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
|
991 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1) |
27 | 992 |
self.radioButton1.SetValue(True) |
993 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
994 |
self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
995 |
label="Negated", name='radioButton2', parent=self, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
996 |
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
|
997 |
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
|
998 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
999 |
self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1000 |
label="Set", name='radioButton3', parent=self, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1001 |
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
|
1002 |
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
|
1003 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1004 |
self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4, |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1005 |
label="Reset", name='radioButton4', parent=self, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1006 |
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
|
1007 |
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
|
1008 |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1009 |
self.radioButton5 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON5, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1010 |
label="Rising Edge", name='radioButton5', parent=self, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1011 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1012 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON5) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1013 |
|
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1014 |
self.radioButton6 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON6, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1015 |
label="Falling Edge", name='radioButton6', parent=self, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1016 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1017 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON6) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1018 |
|
95 | 1019 |
self.ElementName = wx.Choice(id=ID_LDELEMENTDIALOGNAME, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1020 |
name='Name', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1021 |
size=wx.Size(0, 24), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1022 |
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
|
1023 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1024 |
self.Preview = wx.Panel(id=ID_LDELEMENTDIALOGPREVIEW, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1025 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1026 |
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
|
1027 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
42 | 1028 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
145 | 1029 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1030 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
27 | 1031 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1032 |
self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1033 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1034 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1035 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1036 |
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
|
1037 |
|
113 | 1038 |
if wx.VERSION >= (2, 5, 0): |
1039 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
1040 |
else: |
|
1041 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1042 |
|
27 | 1043 |
self._init_sizers() |
1044 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1045 |
def __init__(self, parent, controler, type): |
27 | 1046 |
self.Type = type |
1047 |
if type == "contact": |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1048 |
self._init_ctrls(parent, controler, "Edit Contact Values") |
27 | 1049 |
self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1050 |
self.radioButton3.Hide() |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1051 |
self.radioButton4.Hide() |
27 | 1052 |
elif type == "coil": |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1053 |
self._init_ctrls(parent, controler, "Edit Coil Values", 50) |
27 | 1054 |
self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1055 |
|
165 | 1056 |
|
1057 |
def SetPreviewFont(self, font): |
|
1058 |
self.Preview.SetFont(font) |
|
1059 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1060 |
def SetElementSize(self, size): |
27 | 1061 |
min_width, min_height = self.Element.GetMinSize() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1062 |
width, height = max(min_width, size[0]), max(min_height, size[1]) |
27 | 1063 |
self.Element.SetSize(width, height) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1064 |
|
27 | 1065 |
def SetVariables(self, vars): |
95 | 1066 |
self.ElementName.Clear() |
27 | 1067 |
for name in vars: |
95 | 1068 |
self.ElementName.Append(name) |
1069 |
self.ElementName.Enable(self.ElementName.GetCount() > 0) |
|
27 | 1070 |
|
1071 |
def SetValues(self, values): |
|
1072 |
for name, value in values.items(): |
|
1073 |
if name == "name": |
|
1074 |
self.Element.SetName(value) |
|
95 | 1075 |
self.ElementName.SetStringSelection(value) |
27 | 1076 |
elif name == "type": |
1077 |
self.Element.SetType(value) |
|
1078 |
if self.Type == "contact": |
|
1079 |
if value == CONTACT_NORMAL: |
|
1080 |
self.radioButton1.SetValue(True) |
|
1081 |
elif value == CONTACT_REVERSE: |
|
1082 |
self.radioButton2.SetValue(True) |
|
1083 |
elif value == CONTACT_RISING: |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1084 |
self.radioButton5.SetValue(True) |
27 | 1085 |
elif value == CONTACT_FALLING: |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1086 |
self.radioButton6.SetValue(True) |
27 | 1087 |
elif self.Type == "coil": |
1088 |
if value == COIL_NORMAL: |
|
1089 |
self.radioButton1.SetValue(True) |
|
1090 |
elif value == COIL_REVERSE: |
|
1091 |
self.radioButton2.SetValue(True) |
|
1092 |
elif value == COIL_SET: |
|
1093 |
self.radioButton3.SetValue(True) |
|
1094 |
elif value == COIL_RESET: |
|
1095 |
self.radioButton4.SetValue(True) |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1096 |
elif value == COIL_RISING: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1097 |
self.radioButton5.SetValue(True) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1098 |
elif value == COIL_FALLING: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1099 |
self.radioButton6.SetValue(True) |
27 | 1100 |
|
1101 |
def GetValues(self): |
|
1102 |
values = {} |
|
1103 |
values["name"] = self.Element.GetName() |
|
1104 |
values["type"] = self.Element.GetType() |
|
1105 |
values["width"], values["height"] = self.Element.GetSize() |
|
1106 |
return values |
|
1107 |
||
1108 |
def OnTypeChanged(self, event): |
|
1109 |
if self.Type == "contact": |
|
1110 |
if self.radioButton1.GetValue(): |
|
1111 |
self.Element.SetType(CONTACT_NORMAL) |
|
1112 |
elif self.radioButton2.GetValue(): |
|
1113 |
self.Element.SetType(CONTACT_REVERSE) |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1114 |
elif self.radioButton5.GetValue(): |
27 | 1115 |
self.Element.SetType(CONTACT_RISING) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1116 |
elif self.radioButton6.GetValue(): |
27 | 1117 |
self.Element.SetType(CONTACT_FALLING) |
1118 |
elif self.Type == "coil": |
|
1119 |
if self.radioButton1.GetValue(): |
|
1120 |
self.Element.SetType(COIL_NORMAL) |
|
1121 |
elif self.radioButton2.GetValue(): |
|
1122 |
self.Element.SetType(COIL_REVERSE) |
|
1123 |
elif self.radioButton3.GetValue(): |
|
1124 |
self.Element.SetType(COIL_SET) |
|
1125 |
elif self.radioButton4.GetValue(): |
|
1126 |
self.Element.SetType(COIL_RESET) |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1127 |
elif self.radioButton5.GetValue(): |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1128 |
self.Element.SetType(COIL_RISING) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1129 |
elif self.radioButton6.GetValue(): |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
255
diff
changeset
|
1130 |
self.Element.SetType(COIL_FALLING) |
27 | 1131 |
self.RefreshPreview() |
1132 |
event.Skip() |
|
1133 |
||
1134 |
def OnNameChanged(self, event): |
|
95 | 1135 |
self.Element.SetName(self.ElementName.GetStringSelection()) |
27 | 1136 |
self.RefreshPreview() |
1137 |
event.Skip() |
|
1138 |
||
1139 |
def RefreshPreview(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1140 |
dc = wx.ClientDC(self.Preview) |
165 | 1141 |
dc.SetFont(self.Preview.GetFont()) |
27 | 1142 |
dc.Clear() |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1143 |
clientsize = self.Preview.GetClientSize() |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1144 |
width, height = self.Element.GetSize() |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1145 |
self.Element.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2) |
27 | 1146 |
self.Element.Draw(dc) |
1147 |
||
1148 |
def OnPaint(self, event): |
|
1149 |
self.RefreshPreview() |
|
1150 |
event.Skip() |
|
1151 |
||
1152 |
||
1153 |
#------------------------------------------------------------------------------- |
|
1154 |
# Edit Ladder Power Rail Properties Dialog |
|
1155 |
#------------------------------------------------------------------------------- |
|
1156 |
||
1157 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1158 |
[ID_LDPOWERRAILDIALOG, ID_LDPOWERRAILDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1159 |
ID_LDPOWERRAILDIALOGTYPE, ID_LDPOWERRAILDIALOGRADIOBUTTON1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1160 |
ID_LDPOWERRAILDIALOGRADIOBUTTON2, ID_LDPOWERRAILDIALOGPREVIEW, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1161 |
ID_LDPOWERRAILDIALOGSTATICTEXT1, ID_LDPOWERRAILDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1162 |
ID_LDPOWERRAILDIALOGSTATICTEXT3, ID_LDPOWERRAILDIALOGPINNUMBER, |
27 | 1163 |
] = [wx.NewId() for _init_ctrls in range(10)] |
1164 |
||
1165 |
class LDPowerRailDialog(wx.Dialog): |
|
113 | 1166 |
|
1167 |
if wx.VERSION < (2, 6, 0): |
|
1168 |
def Bind(self, event, function, id = None): |
|
1169 |
if id is not None: |
|
1170 |
event(self, id, function) |
|
1171 |
else: |
|
1172 |
event(self, function) |
|
1173 |
||
27 | 1174 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1175 |
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
|
1176 |
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
|
1177 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1178 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1179 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1180 |
parent.AddGrowableRow(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1181 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1182 |
def _init_coll_MainSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1183 |
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
|
1184 |
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
|
1185 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1186 |
def _init_coll_LeftGridSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1187 |
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
|
1188 |
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
|
1189 |
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
|
1190 |
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
|
1191 |
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
|
1192 |
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
|
1193 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1194 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1195 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1196 |
parent.AddGrowableRow(5) |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1197 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1198 |
def _init_coll_RightGridSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1199 |
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
|
1200 |
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
|
1201 |
|
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1202 |
def _init_coll_RightGridSizer_Growables(self, parent): |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1203 |
parent.AddGrowableCol(0) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1204 |
parent.AddGrowableRow(1) |
27 | 1205 |
|
1206 |
def _init_sizers(self): |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1207 |
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
|
1208 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1209 |
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
|
1210 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 1211 |
|
1212 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1213 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1214 |
self._init_coll_MainSizer_Items(self.MainSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1215 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1216 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1217 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1218 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 1219 |
|
1220 |
self.SetSizer(self.flexGridSizer1) |
|
1221 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1222 |
def _init_ctrls(self, prnt, ctrler): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1223 |
wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG, |
27 | 1224 |
name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223), |
1225 |
size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, |
|
1226 |
title='Power Rail Properties') |
|
1227 |
self.SetClientSize(wx.Size(350, 260)) |
|
1228 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1229 |
self.staticText1 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT1, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1230 |
label='Type:', name='staticText1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1231 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 1232 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1233 |
self.staticText2 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT2, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1234 |
label='Pin number:', name='staticText2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1235 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 1236 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1237 |
self.staticText3 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT3, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1238 |
label='Preview:', name='staticText3', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1239 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
27 | 1240 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1241 |
self.radioButton1 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON1, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1242 |
label='Left PowerRail', name='radioButton1', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1243 |
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
|
1244 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1) |
27 | 1245 |
self.radioButton1.SetValue(True) |
1246 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1247 |
self.radioButton2 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON2, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1248 |
label='Right PowerRail', name='radioButton2', parent=self, |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1249 |
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
|
1250 |
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
|
1251 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1252 |
self.PinNumber = wx.SpinCtrl(id=ID_LDPOWERRAILDIALOGPINNUMBER, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1253 |
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
|
1254 |
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
|
1255 |
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
|
1256 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1257 |
self.Preview = wx.Panel(id=ID_LDPOWERRAILDIALOGPREVIEW, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1258 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1259 |
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
|
1260 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
42 | 1261 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
145 | 1262 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1263 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
27 | 1264 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1265 |
self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER, |
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1266 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1267 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1268 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1269 |
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
|
1270 |
|
113 | 1271 |
if wx.VERSION >= (2, 5, 0): |
1272 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
1273 |
else: |
|
1274 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1275 |
|
27 | 1276 |
self._init_sizers() |
1277 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1278 |
def __init__(self, parent, controler, type = LEFTRAIL, number = 1): |
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1279 |
self._init_ctrls(parent, controler) |
27 | 1280 |
self.Type = type |
1281 |
if type == LEFTRAIL: |
|
1282 |
self.radioButton1.SetValue(True) |
|
1283 |
elif type == RIGHTRAIL: |
|
1284 |
self.radioButton2.SetValue(True) |
|
1285 |
self.PinNumber.SetValue(number) |
|
1286 |
||
1287 |
self.PowerRailMinSize = (0, 0) |
|
1288 |
self.PowerRail = None |
|
1289 |
||
165 | 1290 |
def SetPreviewFont(self, font): |
1291 |
self.Preview.SetFont(font) |
|
1292 |
||
27 | 1293 |
def SetMinSize(self, size): |
1294 |
self.PowerRailMinSize = size |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1295 |
self.RefreshPreview() |
27 | 1296 |
|
1297 |
def GetValues(self): |
|
1298 |
values = {} |
|
1299 |
values["type"] = self.Type |
|
1300 |
values["number"] = self.PinNumber.GetValue() |
|
1301 |
values["width"], values["height"] = self.PowerRail.GetSize() |
|
1302 |
return values |
|
1303 |
||
1304 |
def OnTypeChanged(self, event): |
|
1305 |
if self.radioButton1.GetValue(): |
|
1306 |
self.Type = LEFTRAIL |
|
1307 |
elif self.radioButton2.GetValue(): |
|
1308 |
self.Type = RIGHTRAIL |
|
1309 |
self.RefreshPreview() |
|
1310 |
event.Skip() |
|
1311 |
||
1312 |
def OnPinNumberChanged(self, event): |
|
1313 |
self.RefreshPreview() |
|
1314 |
event.Skip() |
|
1315 |
||
1316 |
def RefreshPreview(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1317 |
dc = wx.ClientDC(self.Preview) |
165 | 1318 |
dc.SetFont(self.Preview.GetFont()) |
27 | 1319 |
dc.Clear() |
1320 |
self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())]) |
|
96 | 1321 |
min_width, min_height = 2, LD_LINE_SIZE * self.PinNumber.GetValue() |
27 | 1322 |
width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1]) |
1323 |
self.PowerRail.SetSize(width, height) |
|
62
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1324 |
clientsize = self.Preview.GetClientSize() |
1908c45f21ef
Adding sizer on some Dialogs for making them resizable
lbessard
parents:
58
diff
changeset
|
1325 |
self.PowerRail.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2) |
27 | 1326 |
self.PowerRail.Draw(dc) |
1327 |
||
1328 |
def OnPaint(self, event): |
|
1329 |
self.RefreshPreview() |
|
1330 |
event.Skip() |
|
1331 |
||
1332 |
||
1333 |
#------------------------------------------------------------------------------- |
|
71 | 1334 |
# Edit Step Content Dialog |
1335 |
#------------------------------------------------------------------------------- |
|
1336 |
||
1337 |
[ID_STEPCONTENTDIALOG, ID_STEPCONTENTDIALOGSPACER, |
|
1338 |
ID_STEPCONTENTDIALOGNAME, ID_STEPCONTENTDIALOGPREVIEW, |
|
1339 |
ID_STEPCONTENTDIALOGCHECKBOX1, ID_STEPCONTENTDIALOGCHECKBOX2, |
|
1340 |
ID_STEPCONTENTDIALOGCHECKBOX3, ID_STEPCONTENTDIALOGSTATICTEXT1, |
|
1341 |
ID_STEPCONTENTDIALOGSTATICTEXT2, ID_STEPCONTENTDIALOGSTATICTEXT3, |
|
1342 |
] = [wx.NewId() for _init_ctrls in range(10)] |
|
1343 |
||
1344 |
class StepContentDialog(wx.Dialog): |
|
113 | 1345 |
|
1346 |
if wx.VERSION < (2, 6, 0): |
|
1347 |
def Bind(self, event, function, id = None): |
|
1348 |
if id is not None: |
|
1349 |
event(self, id, function) |
|
1350 |
else: |
|
1351 |
event(self, function) |
|
1352 |
||
71 | 1353 |
def _init_coll_flexGridSizer1_Items(self, parent): |
1354 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
1355 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
1356 |
||
1357 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
|
1358 |
parent.AddGrowableCol(0) |
|
1359 |
parent.AddGrowableRow(0) |
|
1360 |
||
1361 |
def _init_coll_MainSizer_Items(self, parent): |
|
1362 |
parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) |
|
1363 |
parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) |
|
1364 |
||
1365 |
def _init_coll_LeftGridSizer_Items(self, parent): |
|
1366 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
|
95 | 1367 |
parent.AddWindow(self.StepName, 0, border=0, flag=wx.GROW) |
71 | 1368 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
1369 |
parent.AddWindow(self.checkBox1, 0, border=0, flag=wx.GROW) |
|
1370 |
parent.AddWindow(self.checkBox2, 0, border=0, flag=wx.GROW) |
|
1371 |
parent.AddWindow(self.checkBox3, 0, border=0, flag=wx.GROW) |
|
1372 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
|
1373 |
||
1374 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
|
1375 |
parent.AddGrowableCol(0) |
|
1376 |
parent.AddGrowableRow(6) |
|
1377 |
||
1378 |
def _init_coll_RightGridSizer_Items(self, parent): |
|
1379 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
|
1380 |
parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) |
|
1381 |
||
1382 |
def _init_coll_RightGridSizer_Growables(self, parent): |
|
1383 |
parent.AddGrowableCol(0) |
|
1384 |
parent.AddGrowableRow(1) |
|
1385 |
||
1386 |
def _init_sizers(self): |
|
1387 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
|
1388 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
1389 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) |
|
1390 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
|
1391 |
||
1392 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
1393 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
|
1394 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
1395 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
|
1396 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
|
1397 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
|
1398 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
|
1399 |
||
1400 |
self.SetSizer(self.flexGridSizer1) |
|
1401 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1402 |
def _init_ctrls(self, prnt, ctrler): |
71 | 1403 |
wx.Dialog.__init__(self, id=ID_STEPCONTENTDIALOG, |
1404 |
name='StepContentDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1405 |
size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE, |
|
1406 |
title='Edit Step') |
|
1407 |
self.SetClientSize(wx.Size(400, 250)) |
|
1408 |
||
1409 |
self.staticText1 = wx.StaticText(id=ID_STEPCONTENTDIALOGSTATICTEXT1, |
|
1410 |
label='Name:', name='staticText1', parent=self, |
|
1411 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
1412 |
||
1413 |
self.staticText2 = wx.StaticText(id=ID_STEPCONTENTDIALOGSTATICTEXT2, |
|
1414 |
label='Connectors:', name='staticText2', parent=self, |
|
1415 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
1416 |
||
1417 |
self.staticText3 = wx.StaticText(id=ID_STEPCONTENTDIALOGSTATICTEXT3, |
|
1418 |
label='Preview:', name='staticText4', parent=self, |
|
1419 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
1420 |
||
95 | 1421 |
self.StepName = wx.TextCtrl(id=ID_STEPCONTENTDIALOGNAME, |
71 | 1422 |
name='Name', parent=self, pos=wx.Point(0, 0), |
1423 |
size=wx.Size(0, 24), style=0) |
|
1424 |
self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_STEPCONTENTDIALOGNAME) |
|
1425 |
||
1426 |
self.checkBox1 = wx.CheckBox(id=ID_STEPCONTENTDIALOGCHECKBOX1, |
|
1427 |
label="Input", name='checkBox1', parent=self, |
|
1428 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
|
1429 |
self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_STEPCONTENTDIALOGCHECKBOX1) |
|
1430 |
||
1431 |
self.checkBox2 = wx.CheckBox(id=ID_STEPCONTENTDIALOGCHECKBOX2, |
|
1432 |
label="Output", name='checkBox2', parent=self, |
|
1433 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
|
1434 |
self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_STEPCONTENTDIALOGCHECKBOX2) |
|
1435 |
||
1436 |
self.checkBox3 = wx.CheckBox(id=ID_STEPCONTENTDIALOGCHECKBOX3, |
|
1437 |
label="Action", name='checkBox3', parent=self, |
|
1438 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
|
1439 |
self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_STEPCONTENTDIALOGCHECKBOX3) |
|
1440 |
||
1441 |
self.Spacer = wx.Panel(id=ID_STEPCONTENTDIALOGSPACER, |
|
1442 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
|
1443 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
1444 |
||
1445 |
self.Preview = wx.Panel(id=ID_STEPCONTENTDIALOGPREVIEW, |
|
1446 |
name='Preview', parent=self, pos=wx.Point(0, 0), |
|
1447 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) |
|
1448 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
|
1449 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
|
1450 |
setattr(self.Preview, "RefreshStepModel", lambda x:None) |
|
145 | 1451 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1452 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
71 | 1453 |
|
1454 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
|
113 | 1455 |
if wx.VERSION >= (2, 5, 0): |
1456 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
|
1457 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
1458 |
else: |
|
1459 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
1460 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
1461 |
||
71 | 1462 |
self._init_sizers() |
1463 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1464 |
def __init__(self, parent, controler, initial = False): |
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1465 |
self._init_ctrls(parent, controler) |
71 | 1466 |
self.Step = None |
1467 |
self.Initial = initial |
|
1468 |
self.MinStepSize = None |
|
1469 |
||
1470 |
self.PouNames = [] |
|
1471 |
self.Variables = [] |
|
1472 |
self.StepNames = [] |
|
1473 |
||
165 | 1474 |
def SetPreviewFont(self, font): |
1475 |
self.Preview.SetFont(font) |
|
1476 |
||
71 | 1477 |
def OnOK(self, event): |
95 | 1478 |
step_name = self.StepName.GetValue() |
71 | 1479 |
if step_name == "": |
1480 |
message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR) |
|
1481 |
message.ShowModal() |
|
1482 |
message.Destroy() |
|
1483 |
elif not TestIdentifier(step_name): |
|
1484 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
|
1485 |
message.ShowModal() |
|
1486 |
message.Destroy() |
|
1487 |
elif step_name.upper() in IEC_KEYWORDS: |
|
1488 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
|
1489 |
message.ShowModal() |
|
1490 |
message.Destroy() |
|
1491 |
elif step_name.upper() in self.PouNames: |
|
1492 |
message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
|
1493 |
message.ShowModal() |
|
1494 |
message.Destroy() |
|
1495 |
elif step_name.upper() in self.Variables: |
|
1496 |
message = wx.MessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
|
1497 |
message.ShowModal() |
|
1498 |
message.Destroy() |
|
1499 |
elif step_name.upper() in self.StepNames: |
|
1500 |
message = wx.MessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
|
1501 |
message.ShowModal() |
|
1502 |
message.Destroy() |
|
1503 |
else: |
|
1504 |
self.EndModal(wx.ID_OK) |
|
1505 |
||
1506 |
def SetMinStepSize(self, size): |
|
1507 |
self.MinStepSize = size |
|
1508 |
||
1509 |
def SetPouNames(self, pou_names): |
|
1510 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
1511 |
||
1512 |
def SetVariables(self, variables): |
|
1513 |
self.Variables = [var["Name"].upper() for var in variables] |
|
1514 |
||
1515 |
def SetStepNames(self, step_names): |
|
1516 |
self.StepNames = [step_name.upper() for step_name in step_names] |
|
1517 |
||
1518 |
def SetValues(self, values): |
|
1519 |
value_name = values.get("name", None) |
|
1520 |
if value_name: |
|
95 | 1521 |
self.StepName.SetValue(value_name) |
71 | 1522 |
else: |
95 | 1523 |
self.StepName.SetValue("") |
71 | 1524 |
self.checkBox1.SetValue(values.get("input", False)) |
1525 |
self.checkBox2.SetValue(values.get("output", False)) |
|
1526 |
self.checkBox3.SetValue(values.get("action", False)) |
|
1527 |
self.RefreshPreview() |
|
1528 |
||
1529 |
def GetValues(self): |
|
1530 |
values = {} |
|
95 | 1531 |
values["name"] = self.StepName.GetValue() |
71 | 1532 |
values["input"] = self.checkBox1.IsChecked() |
1533 |
values["output"] = self.checkBox2.IsChecked() |
|
1534 |
values["action"] = self.checkBox3.IsChecked() |
|
1535 |
values["width"], values["height"] = self.Step.GetSize() |
|
1536 |
return values |
|
1537 |
||
1538 |
def OnConnectorsChanged(self, event): |
|
1539 |
self.RefreshPreview() |
|
1540 |
event.Skip() |
|
1541 |
||
1542 |
def OnNameChanged(self, event): |
|
1543 |
self.RefreshPreview() |
|
1544 |
event.Skip() |
|
1545 |
||
1546 |
def RefreshPreview(self): |
|
1547 |
dc = wx.ClientDC(self.Preview) |
|
165 | 1548 |
dc.SetFont(self.Preview.GetFont()) |
71 | 1549 |
dc.Clear() |
95 | 1550 |
self.Step = SFC_Step(self.Preview, self.StepName.GetValue(), self.Initial) |
71 | 1551 |
if self.checkBox1.IsChecked(): |
1552 |
self.Step.AddInput() |
|
1553 |
else: |
|
1554 |
self.Step.RemoveInput() |
|
1555 |
if self.checkBox2.IsChecked(): |
|
1556 |
self.Step.AddOutput() |
|
1557 |
else: |
|
1558 |
self.Step.RemoveOutput() |
|
1559 |
if self.checkBox3.IsChecked(): |
|
1560 |
self.Step.AddAction() |
|
1561 |
else: |
|
1562 |
self.Step.RemoveAction() |
|
1563 |
width, height = self.MinStepSize |
|
1564 |
min_width, min_height = self.Step.GetMinSize() |
|
1565 |
width, height = max(min_width, width), max(min_height, height) |
|
1566 |
self.Step.SetSize(width, height) |
|
1567 |
clientsize = self.Preview.GetClientSize() |
|
1568 |
x = (clientsize.width - width) / 2 |
|
1569 |
y = (clientsize.height - height) / 2 |
|
1570 |
self.Step.SetPosition(x, y) |
|
1571 |
self.Step.Draw(dc) |
|
1572 |
||
1573 |
def OnPaint(self, event): |
|
1574 |
self.RefreshPreview() |
|
95 | 1575 |
event.Skip() |
71 | 1576 |
|
1577 |
#------------------------------------------------------------------------------- |
|
27 | 1578 |
# Edit Transition Content Dialog |
1579 |
#------------------------------------------------------------------------------- |
|
1580 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1581 |
[ID_TRANSITIONCONTENTDIALOG, ID_TRANSITIONCONTENTDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1582 |
ID_TRANSITIONCONTENTDIALOGREFERENCE, ID_TRANSITIONCONTENTDIALOGINLINE, |
80 | 1583 |
ID_TRANSITIONCONTENTDIALOGPRIORITY, ID_TRANSITIONCONTENTDIALOGPREVIEW, |
1584 |
ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, |
|
1585 |
ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, |
|
1586 |
ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, ID_TRANSITIONCONTENTDIALOGSTATICTEXT3, |
|
1587 |
] = [wx.NewId() for _init_ctrls in range(12)] |
|
27 | 1588 |
|
1589 |
class TransitionContentDialog(wx.Dialog): |
|
113 | 1590 |
|
1591 |
if wx.VERSION < (2, 6, 0): |
|
1592 |
def Bind(self, event, function, id = None): |
|
1593 |
if id is not None: |
|
1594 |
event(self, id, function) |
|
1595 |
else: |
|
1596 |
event(self, function) |
|
1597 |
||
27 | 1598 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1599 |
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
|
1600 |
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
|
1601 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1602 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1603 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1604 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1605 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1606 |
def _init_coll_MainSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1607 |
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
|
1608 |
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
|
1609 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1610 |
def _init_coll_LeftGridSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1611 |
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
|
1612 |
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
|
1613 |
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
|
1614 |
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
|
1615 |
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
|
1616 |
parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) |
80 | 1617 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
1618 |
parent.AddWindow(self.Priority, 0, border=0, flag=wx.GROW) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1619 |
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
|
1620 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1621 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1622 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1623 |
parent.AddGrowableRow(6) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1624 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1625 |
def _init_coll_RightGridSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1626 |
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
|
1627 |
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
|
1628 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1629 |
def _init_coll_RightGridSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1630 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1631 |
parent.AddGrowableRow(1) |
27 | 1632 |
|
1633 |
def _init_sizers(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1634 |
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
|
1635 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
80 | 1636 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1637 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 1638 |
|
1639 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1640 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1641 |
self._init_coll_MainSizer_Items(self.MainSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1642 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1643 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1644 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1645 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 1646 |
|
1647 |
self.SetSizer(self.flexGridSizer1) |
|
1648 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1649 |
def _init_ctrls(self, prnt, ctrler): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1650 |
wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG, |
27 | 1651 |
name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), |
80 | 1652 |
size=wx.Size(350, 300), style=wx.DEFAULT_DIALOG_STYLE, |
27 | 1653 |
title='Edit transition') |
80 | 1654 |
self.SetClientSize(wx.Size(350, 300)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1655 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1656 |
self.staticText1 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1657 |
label='Type:', name='staticText1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1658 |
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
|
1659 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1660 |
self.staticText2 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1661 |
label='Preview:', name='staticText2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1662 |
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
|
1663 |
|
80 | 1664 |
self.staticText3 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT3, |
1665 |
label='Priority:', name='staticText3', parent=self, |
|
1666 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
|
1667 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1668 |
self.radioButton1 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1669 |
label='Reference', name='radioButton1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1670 |
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
|
1671 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1) |
27 | 1672 |
self.radioButton1.SetValue(True) |
1673 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1674 |
self.Reference = wx.Choice(id=ID_TRANSITIONCONTENTDIALOGREFERENCE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1675 |
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
|
1676 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1677 |
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
|
1678 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1679 |
self.radioButton2 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1680 |
label='Inline', name='radioButton2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1681 |
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
|
1682 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2) |
27 | 1683 |
self.radioButton2.SetValue(False) |
1684 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1685 |
self.Inline = wx.TextCtrl(id=ID_TRANSITIONCONTENTDIALOGINLINE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1686 |
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
|
1687 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1688 |
self.Bind(wx.EVT_TEXT, self.OnInlineChanged, id=ID_TRANSITIONCONTENTDIALOGINLINE) |
108 | 1689 |
self.Inline.Enable(False) |
1690 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1691 |
self.radioButton3 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1692 |
label='Connection', name='radioButton3', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1693 |
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
|
1694 |
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
|
1695 |
self.radioButton3.SetValue(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1696 |
if not self.Connection: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1697 |
self.radioButton3.Hide() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1698 |
|
80 | 1699 |
self.Priority = wx.SpinCtrl(id=ID_TRANSITIONCONTENTDIALOGPRIORITY, |
1700 |
name='Priority', parent=self, pos=wx.Point(0, 0), |
|
1701 |
size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) |
|
1702 |
self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, id=ID_TRANSITIONCONTENTDIALOGPRIORITY) |
|
1703 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1704 |
self.Preview = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGPREVIEW, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1705 |
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
|
1706 |
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
|
1707 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1708 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1709 |
setattr(self.Preview, "RefreshTransitionModel", lambda x:None) |
145 | 1710 |
setattr(self.Preview, "GetScaling", lambda:None) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1711 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1712 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1713 |
self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1714 |
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
|
1715 |
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
|
1716 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1717 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
113 | 1718 |
if wx.VERSION >= (2, 5, 0): |
1719 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
|
1720 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
1721 |
else: |
|
1722 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
1723 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1724 |
|
27 | 1725 |
self._init_sizers() |
1726 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1727 |
def __init__(self, parent, controler, connection): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1728 |
self.Connection = connection |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1729 |
self._init_ctrls(parent, controler) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1730 |
self.Transition = None |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1731 |
self.MinTransitionSize = None |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1732 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1733 |
self.Element = SFC_Transition(self.Preview) |
165 | 1734 |
|
1735 |
def SetPreviewFont(self, font): |
|
1736 |
self.Preview.SetFont(font) |
|
1737 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1738 |
def SetElementSize(self, size): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1739 |
min_width, min_height = self.Element.GetMinSize() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1740 |
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
|
1741 |
self.Element.SetSize(width, height) |
27 | 1742 |
|
1743 |
def OnOK(self, event): |
|
1744 |
error = [] |
|
1745 |
if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "": |
|
1746 |
error.append("Reference") |
|
1747 |
if self.radioButton2.GetValue() and self.Inline.GetValue() == "": |
|
1748 |
error.append("Inline") |
|
1749 |
if len(error) > 0: |
|
1750 |
text = "" |
|
1751 |
for i, item in enumerate(error): |
|
1752 |
if i == 0: |
|
1753 |
text += item |
|
1754 |
elif i == len(error) - 1: |
|
1755 |
text += " and %s"%item |
|
1756 |
else: |
|
1757 |
text += ", %s"%item |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1758 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
27 | 1759 |
message.ShowModal() |
1760 |
message.Destroy() |
|
1761 |
else: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1762 |
self.EndModal(wx.ID_OK) |
27 | 1763 |
|
1764 |
def OnTypeChanged(self, event): |
|
1765 |
if self.radioButton1.GetValue(): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1766 |
self.Element.SetType("reference", self.Reference.GetStringSelection()) |
27 | 1767 |
self.Reference.Enable(True) |
1768 |
self.Inline.Enable(False) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1769 |
elif self.radioButton2.GetValue(): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1770 |
self.Element.SetType("inline", self.Inline.GetValue()) |
27 | 1771 |
self.Reference.Enable(False) |
1772 |
self.Inline.Enable(True) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1773 |
else: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1774 |
self.Element.SetType("connection") |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1775 |
self.Reference.Enable(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1776 |
self.Inline.Enable(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1777 |
self.RefreshPreview() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1778 |
event.Skip() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1779 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1780 |
def OnReferenceChanged(self, event): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1781 |
self.Element.SetType("reference", self.Reference.GetStringSelection()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1782 |
self.RefreshPreview() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1783 |
event.Skip() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1784 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1785 |
def OnInlineChanged(self, event): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1786 |
self.Element.SetType("inline", self.Inline.GetValue()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1787 |
self.RefreshPreview() |
27 | 1788 |
event.Skip() |
1789 |
||
80 | 1790 |
def OnPriorityChanged(self, event): |
1791 |
self.Element.SetPriority(int(self.Priority.GetValue())) |
|
1792 |
self.RefreshPreview() |
|
1793 |
event.Skip() |
|
1794 |
||
27 | 1795 |
def SetTransitions(self, transitions): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1796 |
self.Reference.Append("") |
27 | 1797 |
for transition in transitions: |
1798 |
self.Reference.Append(transition) |
|
1799 |
||
1800 |
def SetValues(self, values): |
|
1801 |
if values["type"] == "reference": |
|
1802 |
self.radioButton1.SetValue(True) |
|
1803 |
self.radioButton2.SetValue(False) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1804 |
self.radioButton3.SetValue(False) |
27 | 1805 |
self.Reference.Enable(True) |
1806 |
self.Inline.Enable(False) |
|
1807 |
self.Reference.SetStringSelection(values["value"]) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1808 |
self.Element.SetType("reference", values["value"]) |
27 | 1809 |
elif values["type"] == "inline": |
1810 |
self.radioButton1.SetValue(False) |
|
1811 |
self.radioButton2.SetValue(True) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1812 |
self.radioButton3.SetValue(False) |
27 | 1813 |
self.Reference.Enable(False) |
1814 |
self.Inline.Enable(True) |
|
1815 |
self.Inline.SetValue(values["value"]) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1816 |
self.Element.SetType("inline", values["value"]) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1817 |
elif values["type"] == "connection" and self.Connection: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1818 |
self.radioButton1.SetValue(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1819 |
self.radioButton2.SetValue(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1820 |
self.radioButton3.SetValue(True) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1821 |
self.Reference.Enable(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1822 |
self.Inline.Enable(False) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1823 |
self.Element.SetType("connection") |
108 | 1824 |
self.Priority.SetValue(values["priority"]) |
80 | 1825 |
self.Element.SetPriority(values["priority"]) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1826 |
self.RefreshPreview() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1827 |
|
27 | 1828 |
def GetValues(self): |
80 | 1829 |
values = {"priority" : int(self.Priority.GetValue())} |
27 | 1830 |
if self.radioButton1.GetValue(): |
1831 |
values["type"] = "reference" |
|
1832 |
values["value"] = self.Reference.GetStringSelection() |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1833 |
elif self.radioButton2.GetValue(): |
27 | 1834 |
values["type"] = "inline" |
1835 |
values["value"] = self.Inline.GetValue() |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1836 |
else: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1837 |
values["type"] = "connection" |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1838 |
values["value"] = None |
27 | 1839 |
return values |
1840 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1841 |
def RefreshPreview(self): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1842 |
dc = wx.ClientDC(self.Preview) |
165 | 1843 |
dc.SetFont(self.Preview.GetFont()) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1844 |
dc.Clear() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1845 |
clientsize = self.Preview.GetClientSize() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1846 |
posx, posy = self.Element.GetPosition() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1847 |
rect = self.Element.GetBoundingBox() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1848 |
diffx, diffy = posx - rect.x, posy - rect.y |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1849 |
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
|
1850 |
self.Element.Draw(dc) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1851 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1852 |
def OnPaint(self, event): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1853 |
self.RefreshPreview() |
95 | 1854 |
event.Skip() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1855 |
|
27 | 1856 |
#------------------------------------------------------------------------------- |
1857 |
# Create New Divergence Dialog |
|
1858 |
#------------------------------------------------------------------------------- |
|
1859 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1860 |
[ID_DIVERGENCECREATEDIALOG, ID_DIVERGENCECREATEDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1861 |
ID_DIVERGENCECREATEDIALOGRADIOBUTTON1, ID_DIVERGENCECREATEDIALOGRADIOBUTTON2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1862 |
ID_DIVERGENCECREATEDIALOGRADIOBUTTON3, ID_DIVERGENCECREATEDIALOGRADIOBUTTON4, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1863 |
ID_DIVERGENCECREATEDIALOGSEQUENCES, ID_DIVERGENCECREATEDIALOGPREVIEW, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1864 |
ID_DIVERGENCECREATEDIALOGSTATICTEXT1, ID_DIVERGENCECREATEDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1865 |
ID_DIVERGENCECREATEDIALOGSTATICTEXT3, |
27 | 1866 |
] = [wx.NewId() for _init_ctrls in range(11)] |
1867 |
||
1868 |
class DivergenceCreateDialog(wx.Dialog): |
|
113 | 1869 |
|
1870 |
if wx.VERSION < (2, 6, 0): |
|
1871 |
def Bind(self, event, function, id = None): |
|
1872 |
if id is not None: |
|
1873 |
event(self, id, function) |
|
1874 |
else: |
|
1875 |
event(self, function) |
|
1876 |
||
27 | 1877 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1878 |
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
|
1879 |
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
|
1880 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1881 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1882 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1883 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1884 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1885 |
def _init_coll_MainSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1886 |
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
|
1887 |
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
|
1888 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1889 |
def _init_coll_LeftGridSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1890 |
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
|
1891 |
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
|
1892 |
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
|
1893 |
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
|
1894 |
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
|
1895 |
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
|
1896 |
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
|
1897 |
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
|
1898 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1899 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1900 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1901 |
parent.AddGrowableRow(7) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1902 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1903 |
def _init_coll_RightGridSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1904 |
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
|
1905 |
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
|
1906 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1907 |
def _init_coll_RightGridSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1908 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1909 |
parent.AddGrowableRow(1) |
27 | 1910 |
|
1911 |
def _init_sizers(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1912 |
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
|
1913 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1914 |
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
|
1915 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
27 | 1916 |
|
1917 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1918 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1919 |
self._init_coll_MainSizer_Items(self.MainSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1920 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1921 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1922 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1923 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
27 | 1924 |
|
1925 |
self.SetSizer(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1926 |
|
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1927 |
def _init_ctrls(self, prnt, ctrler): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1928 |
wx.Dialog.__init__(self, id=ID_DIVERGENCECREATEDIALOG, |
27 | 1929 |
name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223), |
1930 |
size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE, |
|
1931 |
title='Create a new divergence or convergence') |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1932 |
self.SetClientSize(wx.Size(500, 300)) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1933 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1934 |
self.staticText1 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1935 |
label='Type:', name='staticText1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1936 |
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
|
1937 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1938 |
self.radioButton1 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1939 |
label='Selection Divergence', name='radioButton1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1940 |
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
|
1941 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON1) |
27 | 1942 |
self.radioButton1.SetValue(True) |
1943 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1944 |
self.radioButton2 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1945 |
label='Selection Convergence', name='radioButton2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1946 |
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
|
1947 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON2) |
27 | 1948 |
self.radioButton2.SetValue(False) |
1949 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1950 |
self.radioButton3 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1951 |
label='Simultaneous Divergence', name='radioButton3', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1952 |
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
|
1953 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON3) |
27 | 1954 |
self.radioButton3.SetValue(False) |
1955 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1956 |
self.radioButton4 = wx.RadioButton(id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1957 |
label='Simultaneous Convergence', name='radioButton4', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1958 |
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
|
1959 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_DIVERGENCECREATEDIALOGRADIOBUTTON4) |
27 | 1960 |
self.radioButton4.SetValue(False) |
1961 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1962 |
self.staticText2 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1963 |
label='Number of sequences:', name='staticText2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1964 |
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
|
1965 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1966 |
self.Sequences = wx.SpinCtrl(id=ID_DIVERGENCECREATEDIALOGSEQUENCES, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1967 |
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
|
1968 |
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
|
1969 |
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
|
1970 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1971 |
self.staticText3 = wx.StaticText(id=ID_DIVERGENCECREATEDIALOGSTATICTEXT3, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1972 |
label='Preview:', name='staticText3', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1973 |
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
|
1974 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1975 |
self.Preview = wx.Panel(id=ID_DIVERGENCECREATEDIALOGPREVIEW, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1976 |
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
|
1977 |
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
|
1978 |
self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) |
42 | 1979 |
setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) |
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1980 |
setattr(self.Preview, "IsOfType", ctrler.IsOfType) |
27 | 1981 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1982 |
self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1983 |
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
|
1984 |
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
|
1985 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1986 |
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
|
1987 |
|
113 | 1988 |
if wx.VERSION >= (2, 5, 0): |
1989 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
|
1990 |
else: |
|
1991 |
wx.EVT_PAINT(self.Preview, self.OnPaint) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
1992 |
|
27 | 1993 |
self._init_sizers() |
1994 |
||
226
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1995 |
def __init__(self, parent, controler): |
6a2f7ddd2e50
Moving Data types and POU types informations into project model
lbessard
parents:
165
diff
changeset
|
1996 |
self._init_ctrls(parent, controler) |
27 | 1997 |
|
1998 |
self.Divergence = None |
|
1999 |
self.MinSize = (0, 0) |
|
165 | 2000 |
|
2001 |
def SetPreviewFont(self, font): |
|
2002 |
self.Preview.SetFont(font) |
|
2003 |
||
27 | 2004 |
def GetValues(self): |
2005 |
values = {} |
|
2006 |
if self.radioButton1.GetValue(): |
|
2007 |
values["type"] = SELECTION_DIVERGENCE |
|
2008 |
elif self.radioButton2.GetValue(): |
|
2009 |
values["type"] = SELECTION_CONVERGENCE |
|
2010 |
elif self.radioButton3.GetValue(): |
|
2011 |
values["type"] = SIMULTANEOUS_DIVERGENCE |
|
2012 |
else: |
|
2013 |
values["type"] = SIMULTANEOUS_CONVERGENCE |
|
2014 |
values["number"] = self.Sequences.GetValue() |
|
2015 |
return values |
|
2016 |
||
2017 |
def SetMinSize(self, size): |
|
2018 |
self.MinSize = size |
|
2019 |
||
2020 |
def OnTypeChanged(self, event): |
|
2021 |
self.RefreshPreview() |
|
2022 |
event.Skip() |
|
2023 |
||
2024 |
def OnSequencesChanged(self, event): |
|
2025 |
self.RefreshPreview() |
|
2026 |
event.Skip() |
|
2027 |
||
2028 |
def RefreshPreview(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2029 |
dc = wx.ClientDC(self.Preview) |
165 | 2030 |
dc.SetFont(self.Preview.GetFont()) |
27 | 2031 |
dc.Clear() |
2032 |
if self.radioButton1.GetValue(): |
|
2033 |
self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue()) |
|
2034 |
elif self.radioButton2.GetValue(): |
|
2035 |
self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue()) |
|
2036 |
elif self.radioButton3.GetValue(): |
|
2037 |
self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_DIVERGENCE, self.Sequences.GetValue()) |
|
2038 |
else: |
|
2039 |
self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_CONVERGENCE, self.Sequences.GetValue()) |
|
2040 |
width, height = self.Divergence.GetSize() |
|
2041 |
min_width, min_height = max(width, self.MinSize[0]), max(height, self.MinSize[1]) |
|
2042 |
self.Divergence.SetSize(min_width, min_height) |
|
2043 |
clientsize = self.Preview.GetClientSize() |
|
2044 |
x = (clientsize.width - min_width) / 2 |
|
2045 |
y = (clientsize.height - min_height) / 2 |
|
2046 |
self.Divergence.SetPosition(x, y) |
|
2047 |
self.Divergence.Draw(dc) |
|
2048 |
||
2049 |
def OnPaint(self, event): |
|
2050 |
self.RefreshPreview() |
|
95 | 2051 |
event.Skip() |
27 | 2052 |
|
2053 |
||
2054 |
#------------------------------------------------------------------------------- |
|
2055 |
# Action Block Dialog |
|
2056 |
#------------------------------------------------------------------------------- |
|
2057 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2058 |
class ActionTable(wx.grid.PyGridTableBase): |
27 | 2059 |
|
2060 |
""" |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2061 |
A custom wx.Grid Table using user supplied data |
27 | 2062 |
""" |
2063 |
def __init__(self, parent, data, colnames): |
|
2064 |
# The base class must be initialized *first* |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2065 |
wx.grid.PyGridTableBase.__init__(self) |
27 | 2066 |
self.data = data |
2067 |
self.colnames = colnames |
|
2068 |
self.Parent = parent |
|
2069 |
# XXX |
|
2070 |
# we need to store the row length and collength to |
|
2071 |
# see if the table has changed size |
|
2072 |
self._rows = self.GetNumberRows() |
|
2073 |
self._cols = self.GetNumberCols() |
|
2074 |
||
2075 |
def GetNumberCols(self): |
|
2076 |
return len(self.colnames) |
|
2077 |
||
2078 |
def GetNumberRows(self): |
|
2079 |
return len(self.data) |
|
2080 |
||
2081 |
def GetColLabelValue(self, col): |
|
2082 |
if col < len(self.colnames): |
|
2083 |
return self.colnames[col] |
|
2084 |
||
2085 |
def GetRowLabelValues(self, row): |
|
2086 |
return row |
|
2087 |
||
2088 |
def GetValue(self, row, col): |
|
2089 |
if row < self.GetNumberRows(): |
|
2090 |
name = str(self.data[row].get(self.GetColLabelValue(col), "")) |
|
2091 |
return name |
|
2092 |
||
2093 |
def GetValueByName(self, row, colname): |
|
2094 |
return self.data[row].get(colname) |
|
2095 |
||
2096 |
def SetValue(self, row, col, value): |
|
2097 |
if col < len(self.colnames): |
|
2098 |
self.data[row][self.GetColLabelValue(col)] = value |
|
2099 |
||
2100 |
def ResetView(self, grid): |
|
2101 |
""" |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2102 |
(wx.Grid) -> Reset the grid view. Call this to |
27 | 2103 |
update the grid if rows and columns have been added or deleted |
2104 |
""" |
|
2105 |
grid.BeginBatch() |
|
2106 |
for current, new, delmsg, addmsg in [ |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2107 |
(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
|
2108 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
27 | 2109 |
]: |
2110 |
if new < current: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2111 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
27 | 2112 |
grid.ProcessTableMessage(msg) |
2113 |
elif new > current: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2114 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
27 | 2115 |
grid.ProcessTableMessage(msg) |
2116 |
self.UpdateValues(grid) |
|
2117 |
grid.EndBatch() |
|
2118 |
||
2119 |
self._rows = self.GetNumberRows() |
|
2120 |
self._cols = self.GetNumberCols() |
|
2121 |
# update the column rendering scheme |
|
2122 |
self._updateColAttrs(grid) |
|
2123 |
||
2124 |
# update the scrollbars and the displayed part of the grid |
|
2125 |
grid.AdjustScrollbars() |
|
2126 |
grid.ForceRefresh() |
|
2127 |
||
2128 |
def UpdateValues(self, grid): |
|
2129 |
"""Update all displayed values""" |
|
2130 |
# 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
|
2131 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
27 | 2132 |
grid.ProcessTableMessage(msg) |
2133 |
||
2134 |
def _updateColAttrs(self, grid): |
|
2135 |
""" |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2136 |
wx.Grid -> update the column attributes to add the |
27 | 2137 |
appropriate renderer given the column name. |
2138 |
||
2139 |
Otherwise default to the default renderer. |
|
2140 |
""" |
|
2141 |
||
2142 |
for col in range(self.GetNumberCols()): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2143 |
attr = wx.grid.GridCellAttr() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2144 |
attr.SetAlignment(self.Parent.ColAlignements[col], wx.ALIGN_CENTRE) |
27 | 2145 |
grid.SetColAttr(col, attr) |
2146 |
grid.SetColSize(col, self.Parent.ColSizes[col]) |
|
2147 |
||
2148 |
typelist = None |
|
2149 |
accesslist = None |
|
2150 |
for row in range(self.GetNumberRows()): |
|
2151 |
for col in range(self.GetNumberCols()): |
|
2152 |
editor = None |
|
2153 |
renderer = None |
|
2154 |
readonly = False |
|
2155 |
colname = self.GetColLabelValue(col) |
|
2156 |
if colname == "Qualifier": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2157 |
editor = wx.grid.GridCellChoiceEditor() |
27 | 2158 |
editor.SetParameters(self.Parent.QualifierList) |
2159 |
if colname == "Duration": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2160 |
editor = wx.grid.GridCellTextEditor() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2161 |
renderer = wx.grid.GridCellStringRenderer() |
27 | 2162 |
if self.Parent.DurationList[self.data[row]["Qualifier"]]: |
2163 |
readonly = False |
|
2164 |
else: |
|
2165 |
readonly = True |
|
2166 |
self.data[row]["Duration"] = "" |
|
2167 |
elif colname == "Type": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2168 |
editor = wx.grid.GridCellChoiceEditor() |
27 | 2169 |
editor.SetParameters(self.Parent.TypeList) |
2170 |
elif colname == "Value": |
|
2171 |
type = self.data[row]["Type"] |
|
2172 |
if type == "Action": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2173 |
editor = wx.grid.GridCellChoiceEditor() |
27 | 2174 |
editor.SetParameters(self.Parent.ActionList) |
2175 |
elif type == "Variable": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2176 |
editor = wx.grid.GridCellChoiceEditor() |
27 | 2177 |
editor.SetParameters(self.Parent.VariableList) |
2178 |
elif type == "Inline": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2179 |
editor = wx.grid.GridCellTextEditor() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2180 |
renderer = wx.grid.GridCellStringRenderer() |
27 | 2181 |
elif colname == "Indicator": |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2182 |
editor = wx.grid.GridCellChoiceEditor() |
27 | 2183 |
editor.SetParameters(self.Parent.VariableList) |
2184 |
||
2185 |
grid.SetCellEditor(row, col, editor) |
|
2186 |
grid.SetCellRenderer(row, col, renderer) |
|
2187 |
grid.SetReadOnly(row, col, readonly) |
|
2188 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2189 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
27 | 2190 |
|
2191 |
def SetData(self, data): |
|
2192 |
self.data = data |
|
2193 |
||
2194 |
def GetData(self): |
|
2195 |
return self.data |
|
2196 |
||
2197 |
def GetCurrentIndex(self): |
|
2198 |
return self.CurrentIndex |
|
2199 |
||
2200 |
def SetCurrentIndex(self, index): |
|
2201 |
self.CurrentIndex = index |
|
2202 |
||
2203 |
def AppendRow(self, row_content): |
|
2204 |
self.data.append(row_content) |
|
2205 |
||
2206 |
def RemoveRow(self, row_index): |
|
2207 |
self.data.pop(row_index) |
|
2208 |
||
2209 |
def MoveRow(self, row_index, move, grid): |
|
2210 |
new_index = max(0, min(row_index + move, len(self.data) - 1)) |
|
2211 |
if new_index != row_index: |
|
2212 |
self.data.insert(new_index, self.data.pop(row_index)) |
|
2213 |
grid.SetGridCursor(new_index, grid.GetGridCursorCol()) |
|
2214 |
||
2215 |
def Empty(self): |
|
2216 |
self.data = [] |
|
2217 |
self.editors = [] |
|
2218 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2219 |
[ID_ACTIONBLOCKDIALOG, ID_ACTIONBLOCKDIALOGVARIABLESGRID, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2220 |
ID_ACTIONBLOCKDIALOGSTATICTEXT1, ID_ACTIONBLOCKDIALOGADDBUTTON, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2221 |
ID_ACTIONBLOCKDIALOGDELETEBUTTON, ID_ACTIONBLOCKDIALOGUPBUTTON, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2222 |
ID_ACTIONBLOCKDIALOGDOWNBUTTON, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2223 |
] = [wx.NewId() for _init_ctrls in range(7)] |
27 | 2224 |
|
2225 |
class ActionBlockDialog(wx.Dialog): |
|
113 | 2226 |
|
2227 |
if wx.VERSION < (2, 6, 0): |
|
2228 |
def Bind(self, event, function, id = None): |
|
2229 |
if id is not None: |
|
2230 |
event(self, id, function) |
|
2231 |
else: |
|
2232 |
event(self, function) |
|
2233 |
||
27 | 2234 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2235 |
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
|
2236 |
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
|
2237 |
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
|
2238 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2239 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2240 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2241 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2242 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2243 |
def _init_coll_TopSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2244 |
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
|
2245 |
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
|
2246 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2247 |
def _init_coll_TopSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2248 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2249 |
parent.AddGrowableRow(1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2250 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2251 |
def _init_coll_GridButtonSizer_Items(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2252 |
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
|
2253 |
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
|
2254 |
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
|
2255 |
parent.AddWindow(self.DownButton, 0, border=10, flag=wx.GROW|wx.LEFT) |
27 | 2256 |
|
2257 |
def _init_sizers(self): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2258 |
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
|
2259 |
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
|
2260 |
self.GridButtonSizer = wx.BoxSizer(wx.HORIZONTAL) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2261 |
|
27 | 2262 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2263 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2264 |
self._init_coll_TopSizer_Items(self.TopSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2265 |
self._init_coll_TopSizer_Growables(self.TopSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2266 |
self._init_coll_GridButtonSizer_Items(self.GridButtonSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2267 |
|
27 | 2268 |
self.SetSizer(self.flexGridSizer1) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2269 |
|
27 | 2270 |
def _init_ctrls(self, prnt): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2271 |
wx.Dialog.__init__(self, id=ID_ACTIONBLOCKDIALOG, |
27 | 2272 |
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
|
2273 |
size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
27 | 2274 |
title='Edit action block properties') |
2275 |
self.SetClientSize(wx.Size(500, 300)) |
|
2276 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2277 |
self.staticText1 = wx.StaticText(id=ID_ACTIONBLOCKDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2278 |
label='Actions:', name='staticText1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2279 |
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
|
2280 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2281 |
self.ActionsGrid = wx.grid.Grid(id=ID_ACTIONBLOCKDIALOGVARIABLESGRID, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2282 |
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
|
2283 |
size=wx.Size(0, 0), style=wx.VSCROLL) |
27 | 2284 |
self.ActionsGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
2285 |
'Sans')) |
|
2286 |
self.ActionsGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
|
2287 |
False, 'Sans')) |
|
2288 |
self.ActionsGrid.DisableDragGridSize() |
|
2289 |
self.ActionsGrid.EnableScrolling(False, True) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2290 |
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
|
2291 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2292 |
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
|
2293 |
name='AddButton', parent=self, pos=wx.Point(0, 0), |
27 | 2294 |
size=wx.Size(72, 32), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2295 |
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
|
2296 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2297 |
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
|
2298 |
name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
27 | 2299 |
size=wx.Size(72, 32), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2300 |
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
|
2301 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2302 |
self.UpButton = wx.Button(id=ID_ACTIONBLOCKDIALOGUPBUTTON, label='^', |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2303 |
name='UpButton', parent=self, pos=wx.Point(0, 0), |
27 | 2304 |
size=wx.Size(32, 32), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2305 |
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
|
2306 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2307 |
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
|
2308 |
name='DownButton', parent=self, pos=wx.Point(0, 0), |
27 | 2309 |
size=wx.Size(32, 32), style=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2310 |
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
|
2311 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2312 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
113 | 2313 |
if wx.VERSION >= (2, 5, 0): |
2314 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
|
2315 |
else: |
|
2316 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
2317 |
||
27 | 2318 |
self._init_sizers() |
2319 |
||
2320 |
def __init__(self, parent): |
|
2321 |
self._init_ctrls(parent) |
|
2322 |
||
2323 |
self.DefaultValue = {"Qualifier" : "N", "Duration" : "", "Type" : "Action", "Value" : "", "Indicator" : ""} |
|
2324 |
self.Table = ActionTable(self, [], ["Qualifier","Duration","Type","Value","Indicator"]) |
|
2325 |
self.TypeList = "Action,Variable,Inline" |
|
2326 |
self.ColSizes = [60, 90, 80, 110, 80] |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2327 |
self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
27 | 2328 |
|
2329 |
self.ActionsGrid.SetTable(self.Table) |
|
2330 |
self.ActionsGrid.SetRowLabelSize(0) |
|
2331 |
||
2332 |
self.Table.ResetView(self.ActionsGrid) |
|
2333 |
||
108 | 2334 |
def OnOK(self, event): |
2335 |
self.ActionsGrid.SetGridCursor(0, 0) |
|
2336 |
self.EndModal(wx.ID_OK) |
|
2337 |
||
27 | 2338 |
def OnAddButton(self, event): |
2339 |
self.Table.AppendRow(self.DefaultValue.copy()) |
|
2340 |
self.Table.ResetView(self.ActionsGrid) |
|
2341 |
event.Skip() |
|
2342 |
||
2343 |
def OnDeleteButton(self, event): |
|
2344 |
row = self.ActionsGrid.GetGridCursorRow() |
|
2345 |
self.Table.RemoveRow(row) |
|
2346 |
self.Table.ResetView(self.ActionsGrid) |
|
2347 |
event.Skip() |
|
2348 |
||
2349 |
def OnUpButton(self, event): |
|
2350 |
row = self.ActionsGrid.GetGridCursorRow() |
|
2351 |
self.Table.MoveRow(row, -1, self.ActionsGrid) |
|
2352 |
self.Table.ResetView(self.ActionsGrid) |
|
2353 |
event.Skip() |
|
2354 |
||
2355 |
def OnDownButton(self, event): |
|
2356 |
row = self.ActionsGrid.GetGridCursorRow() |
|
2357 |
self.Table.MoveRow(row, 1, self.ActionsGrid) |
|
2358 |
self.Table.ResetView(self.ActionsGrid) |
|
2359 |
event.Skip() |
|
2360 |
||
2361 |
def OnActionsGridCellChange(self, event): |
|
2362 |
self.Table.ResetView(self.ActionsGrid) |
|
2363 |
event.Skip() |
|
2364 |
||
2365 |
def SetQualifierList(self, list): |
|
154 | 2366 |
self.QualifierList = "," + ",".join(list) |
27 | 2367 |
self.DurationList = list |
2368 |
||
2369 |
def SetVariableList(self, list): |
|
154 | 2370 |
self.VariableList = "," + ",".join([variable["Name"] for variable in list]) |
2371 |
||
27 | 2372 |
def SetActionList(self, list): |
154 | 2373 |
self.ActionList = "," + ",".join(list) |
27 | 2374 |
|
2375 |
def SetValues(self, actions): |
|
2376 |
for action in actions: |
|
2377 |
row = {"Qualifier" : action["qualifier"], "Value" : action["value"]} |
|
2378 |
if action["type"] == "reference": |
|
2379 |
if action["value"] in self.ActionList: |
|
2380 |
row["Type"] = "Action" |
|
2381 |
elif action["value"] in self.VariableList: |
|
2382 |
row["Type"] = "Variable" |
|
2383 |
else: |
|
2384 |
row["Type"] = "Inline" |
|
2385 |
else: |
|
2386 |
row["Type"] = "Inline" |
|
2387 |
if "duration" in action: |
|
2388 |
row["Duration"] = action["duration"] |
|
2389 |
else: |
|
2390 |
row["Duration"] = "" |
|
2391 |
if "indicator" in action: |
|
2392 |
row["Indicator"] = action["indicator"] |
|
2393 |
else: |
|
2394 |
row["Indicator"] = "" |
|
2395 |
self.Table.AppendRow(row) |
|
2396 |
self.Table.ResetView(self.ActionsGrid) |
|
2397 |
||
2398 |
def GetValues(self): |
|
2399 |
values = [] |
|
2400 |
for data in self.Table.GetData(): |
|
2401 |
action = {"qualifier" : data["Qualifier"], "value" : data["Value"]} |
|
2402 |
if data["Type"] in ["Action", "Variable"]: |
|
2403 |
action["type"] = "reference" |
|
2404 |
else: |
|
2405 |
action["type"] = "inline" |
|
2406 |
if data["Duration"] != "": |
|
2407 |
action["duration"] = data["Duration"] |
|
2408 |
if data["Indicator"] != "": |
|
2409 |
action["indicator"] = data["Indicator"] |
|
2410 |
values.append(action) |
|
2411 |
return values |
|
2412 |
||
2413 |
||
2414 |
#------------------------------------------------------------------------------- |
|
2415 |
# Edit Step Name Dialog |
|
2416 |
#------------------------------------------------------------------------------- |
|
2417 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2418 |
class StepNameDialog(wx.TextEntryDialog): |
27 | 2419 |
|
113 | 2420 |
if wx.VERSION < (2, 6, 0): |
2421 |
def Bind(self, event, function, id = None): |
|
2422 |
if id is not None: |
|
2423 |
event(self, id, function) |
|
2424 |
else: |
|
2425 |
event(self, function) |
|
2426 |
||
2427 |
||
27 | 2428 |
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
|
2429 |
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): |
27 | 2430 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
2431 |
||
2432 |
self.PouNames = [] |
|
2433 |
self.Variables = [] |
|
2434 |
self.StepNames = [] |
|
123 | 2435 |
if wx.VERSION >= (2, 8, 0): |
2436 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) |
|
2437 |
elif wx.VERSION >= (2, 6, 0): |
|
113 | 2438 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) |
2439 |
else: |
|
2440 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
2441 |
||
27 | 2442 |
def OnOK(self, event): |
2443 |
step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
2444 |
if step_name == "": |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2445 |
message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR) |
27 | 2446 |
message.ShowModal() |
2447 |
message.Destroy() |
|
2448 |
elif not TestIdentifier(step_name): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2449 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
27 | 2450 |
message.ShowModal() |
2451 |
message.Destroy() |
|
2452 |
elif step_name.upper() in IEC_KEYWORDS: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2453 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
27 | 2454 |
message.ShowModal() |
2455 |
message.Destroy() |
|
2456 |
elif step_name.upper() in self.PouNames: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2457 |
message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
27 | 2458 |
message.ShowModal() |
2459 |
message.Destroy() |
|
2460 |
elif step_name.upper() in self.Variables: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2461 |
message = wx.MessageDialog(self, "A variable with \"%s\" as name exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
27 | 2462 |
message.ShowModal() |
2463 |
message.Destroy() |
|
2464 |
elif step_name.upper() in self.StepNames: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2465 |
message = wx.MessageDialog(self, "\"%s\" step already exists!"%step_name, "Error", wx.OK|wx.ICON_ERROR) |
27 | 2466 |
message.ShowModal() |
2467 |
message.Destroy() |
|
2468 |
else: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
62
diff
changeset
|
2469 |
self.EndModal(wx.ID_OK) |
27 | 2470 |
|
2471 |
def SetPouNames(self, pou_names): |
|
2472 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
2473 |
||
2474 |
def SetVariables(self, variables): |
|
2475 |
self.Variables = [var["Name"].upper() for var in variables] |
|
2476 |
||
2477 |
def SetStepNames(self, step_names): |
|
2478 |
self.StepNames = [step_name.upper() for step_name in step_names] |
|
2479 |
||
42 | 2480 |
def GetValue(self): |
2481 |
return self.GetSizer().GetItem(1).GetWindow().GetValue() |