author | lbessard |
Fri, 22 Aug 2008 13:49:22 +0200 | |
changeset 235 | 7b58a3b5b6ec |
parent 231 | fc2d6cbb8b39 |
child 239 | d12779e971bd |
permissions | -rw-r--r-- |
0 | 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 |
0 | 8 |
# |
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
5 | 12 |
#modify it under the terms of the GNU General Public |
0 | 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. |
0 | 20 |
# |
5 | 21 |
#You should have received a copy of the GNU General Public |
0 | 22 |
#License along with this library; if not, write to the Free Software |
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
from datetime import datetime |
|
120 | 26 |
import wx, wx.grid |
27 |
||
28 |
if wx.VERSION >= (2, 8, 0): |
|
29 |
import wx.aui |
|
0 | 30 |
|
31 |
from SFCViewer import * |
|
32 |
from LDViewer import * |
|
33 |
from Viewer import * |
|
27 | 34 |
from TextViewer import * |
35 |
from RessourceEditor import * |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
36 |
from DataTypeEditor import * |
0 | 37 |
from PLCControler import * |
107 | 38 |
from plcopen.structures import LOCATIONDATATYPES |
0 | 39 |
|
40 |
import os, re, platform, sys, time, traceback, getopt |
|
41 |
||
190 | 42 |
base_folder = os.path.split(sys.path[0])[0] |
43 |
sys.path.append(base_folder) |
|
44 |
from docutils import * |
|
45 |
||
218 | 46 |
from types import TupleType |
47 |
||
0 | 48 |
__version__ = "$Revision$" |
49 |
||
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
50 |
CWD = os.path.split(os.path.realpath(__file__))[0] |
0 | 51 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
52 |
[ID_PLCOPENEDITOR, ID_PLCOPENEDITORTREENOTEBOOK, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
53 |
ID_PLCOPENEDITORTYPESTREE, ID_PLCOPENEDITORINSTANCESTREE, |
121 | 54 |
ID_PLCOPENEDITORMAINSPLITTER, ID_PLCOPENEDITORSECONDSPLITTER, |
55 |
ID_PLCOPENEDITOREDITORPANEL, ID_PLCOPENEDITORTABSOPENED, |
|
56 |
ID_PLCOPENEDITORTOOLBAR, ID_PLCOPENEDITORDEFAULTTOOLBAR, |
|
57 |
ID_PLCOPENEDITORSFCTOOLBAR, ID_PLCOPENEDITORFBDTOOLBAR, |
|
58 |
ID_PLCOPENEDITORLDTOOLBAR, |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
59 |
] = [wx.NewId() for _init_ctrls in range(13)] |
6 | 60 |
|
185 | 61 |
[ID_PLCOPENEDITORFILEMENUGENERATE, |
62 |
] = [wx.NewId() for _init_coll_FileMenu_Items in range(1)] |
|
63 |
||
64 |
[ID_PLCOPENEDITOREDITMENUADDDATATYPE, ID_PLCOPENEDITOREDITMENUADDFUNCTION, |
|
65 |
ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, ID_PLCOPENEDITOREDITMENUADDPROGRAM, |
|
66 |
ID_PLCOPENEDITOREDITMENUADDCONFIGURATION, |
|
67 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(5)] |
|
0 | 68 |
|
27 | 69 |
|
70 |
#------------------------------------------------------------------------------- |
|
71 |
# ToolBars definitions |
|
72 |
#------------------------------------------------------------------------------- |
|
73 |
||
74 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
75 |
[ID_PLCOPENEDITORTOOLBARSELECTION, ID_PLCOPENEDITORTOOLBARCOMMENT, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
76 |
ID_PLCOPENEDITORTOOLBARVARIABLE, ID_PLCOPENEDITORTOOLBARBLOCK, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
77 |
ID_PLCOPENEDITORTOOLBARCONNECTION, ID_PLCOPENEDITORTOOLBARWIRE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
78 |
ID_PLCOPENEDITORTOOLBARPOWERRAIL, ID_PLCOPENEDITORTOOLBARRUNG, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
79 |
ID_PLCOPENEDITORTOOLBARCOIL, ID_PLCOPENEDITORTOOLBARCONTACT, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
80 |
ID_PLCOPENEDITORTOOLBARBRANCH, ID_PLCOPENEDITORTOOLBARINITIALSTEP, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
81 |
ID_PLCOPENEDITORTOOLBARSTEP, ID_PLCOPENEDITORTOOLBARTRANSITION, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
82 |
ID_PLCOPENEDITORTOOLBARACTIONBLOCK, ID_PLCOPENEDITORTOOLBARDIVERGENCE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
83 |
ID_PLCOPENEDITORTOOLBARJUMP, |
27 | 84 |
] = [wx.NewId() for _init_coll_DefaultToolBar_Items in range(17)] |
85 |
||
86 |
ToolBarItems = { |
|
184
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
87 |
"FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
88 |
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
89 |
"add_comment.png", "Create a new comment"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
90 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
91 |
ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
92 |
"add_variable.png", "Create a new variable"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
93 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
94 |
ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
95 |
"add_block.png", "Create a new block"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
96 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
97 |
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
98 |
"add_connection.png", "Create a new connection")], |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
99 |
"LD" : [(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
100 |
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
101 |
"add_comment.png", "Create a new comment"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
102 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
103 |
ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
104 |
"add_powerrail.png", "Create a new power rail"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
105 |
(False, DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
106 |
ID_PLCOPENEDITORTOOLBARRUNG, "OnRungTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
107 |
"add_rung.png", "Create a new rung"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
108 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
109 |
ID_PLCOPENEDITORTOOLBARCOIL, "OnCoilTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
110 |
"add_coil.png", "Create a new coil"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
111 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
112 |
ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
113 |
"add_contact.png", "Create a new contact"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
114 |
(False, DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
115 |
ID_PLCOPENEDITORTOOLBARBRANCH, "OnBranchTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
116 |
"add_branch.png", "Create a new branch"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
117 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
118 |
ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
119 |
"add_variable.png", "Create a new variable"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
120 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
121 |
ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
122 |
"add_block.png", "Create a new block"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
123 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
124 |
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
125 |
"add_connection.png", "Create a new connection")], |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
126 |
"SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
127 |
ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
128 |
"add_comment.png", "Create a new comment"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
129 |
(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
130 |
ID_PLCOPENEDITORTOOLBARINITIALSTEP, "OnInitialStepTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
131 |
"add_initial_step.png", "Create a new initial step"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
132 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
133 |
ID_PLCOPENEDITORTOOLBARSTEP, "OnStepTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
134 |
"add_step.png", "Create a new step"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
135 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
136 |
ID_PLCOPENEDITORTOOLBARTRANSITION, "OnTransitionTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
137 |
"add_transition.png", "Create a new transition"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
138 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
139 |
ID_PLCOPENEDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
140 |
"add_action.png", "Create a new action block"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
141 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
142 |
ID_PLCOPENEDITORTOOLBARDIVERGENCE, "OnDivergenceTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
143 |
"add_divergence.png", "Create a new divergence"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
144 |
(False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
145 |
ID_PLCOPENEDITORTOOLBARJUMP, "OnJumpTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
146 |
"add_jump.png", "Create a new jump"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
147 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
148 |
ID_PLCOPENEDITORTOOLBARVARIABLE, "OnVariableTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
149 |
"add_variable.png", "Create a new variable"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
150 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
151 |
ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
152 |
"add_block.png", "Create a new block"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
153 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
154 |
ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
155 |
"add_connection.png", "Create a new connection"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
156 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
157 |
ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
158 |
"add_powerrail.png", "Create a new power rail"), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
159 |
(True, FREEDRAWING_MODE, |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
160 |
ID_PLCOPENEDITORTOOLBARCONTACT, "OnContactTool", |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
161 |
"add_contact.png", "Create a new contact")], |
82 | 162 |
"ST" : [], |
163 |
"IL" : [] |
|
27 | 164 |
} |
165 |
||
203 | 166 |
def GenerateBitmap(icon1_name, icon2_name = None): |
167 |
if icon2_name is None: |
|
168 |
return wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
|
169 |
else: |
|
170 |
icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
|
171 |
icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name)) |
|
172 |
width = icon1.GetWidth() + icon2.GetWidth() - 1 |
|
173 |
height = max(icon1.GetHeight(), icon2.GetHeight()) |
|
174 |
tmp_bitmap = wx.EmptyBitmap(width, height) |
|
175 |
dc = wx.MemoryDC() |
|
176 |
dc.SelectObject(tmp_bitmap) |
|
177 |
dc.Clear() |
|
178 |
dc.DrawBitmap(icon1, 0, 0) |
|
179 |
dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0) |
|
180 |
return tmp_bitmap |
|
181 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
182 |
def AppendMenu(parent, help, id, kind, text): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
183 |
if wx.VERSION >= (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
184 |
parent.Append(help=help, id=id, kind=kind, text=text) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
185 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
186 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
187 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
188 |
class PLCOpenEditor(wx.Frame): |
0 | 189 |
|
163 | 190 |
CopyBuffer = None |
191 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
192 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
193 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
194 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
195 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
196 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
197 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
198 |
|
185 | 199 |
def _init_coll_MenuBar_Menus(self, parent): |
220 | 200 |
parent.Append(menu=self.FileMenu, title=u'File') |
0 | 201 |
parent.Append(menu=self.EditMenu, title=u'Edit') |
202 |
parent.Append(menu=self.HelpMenu, title=u'Help') |
|
203 |
||
185 | 204 |
def _init_coll_FileMenu_Items(self, parent): |
220 | 205 |
if self.ModeSolo: |
206 |
AppendMenu(parent, help='', id=wx.ID_NEW, |
|
207 |
kind=wx.ITEM_NORMAL, text=u'New\tCTRL+N') |
|
208 |
AppendMenu(parent, help='', id=wx.ID_OPEN, |
|
209 |
kind=wx.ITEM_NORMAL, text=u'Open\tCTRL+O') |
|
185 | 210 |
AppendMenu(parent, help='', id=wx.ID_CLOSE, |
211 |
kind=wx.ITEM_NORMAL, text=u'Close Tab\tCTRL+W') |
|
220 | 212 |
if self.ModeSolo: |
213 |
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
|
214 |
kind=wx.ITEM_NORMAL, text=u'Close Project') |
|
215 |
parent.AppendSeparator() |
|
185 | 216 |
AppendMenu(parent, help='', id=wx.ID_SAVE, |
217 |
kind=wx.ITEM_NORMAL, text=u'Save\tCTRL+S') |
|
220 | 218 |
if self.ModeSolo: |
219 |
AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
|
220 |
kind=wx.ITEM_NORMAL, text=u'Save As...\tCTRL+SHIFT+S') |
|
221 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORFILEMENUGENERATE, |
|
222 |
kind=wx.ITEM_NORMAL, text=u'Generate Program\tCTRL+G') |
|
223 |
parent.AppendSeparator() |
|
213 | 224 |
AppendMenu(parent, help='', id=wx.ID_PAGE_SETUP, |
225 |
kind=wx.ITEM_NORMAL, text=u'Page Setup') |
|
226 |
AppendMenu(parent, help='', id=wx.ID_PREVIEW, |
|
227 |
kind=wx.ITEM_NORMAL, text=u'Preview') |
|
228 |
AppendMenu(parent, help='', id=wx.ID_PRINT, |
|
229 |
kind=wx.ITEM_NORMAL, text=u'Print') |
|
230 |
parent.AppendSeparator() |
|
185 | 231 |
AppendMenu(parent, help='', id=wx.ID_PROPERTIES, |
232 |
kind=wx.ITEM_NORMAL, text=u'Properties') |
|
221 | 233 |
parent.AppendSeparator() |
220 | 234 |
if self.ModeSolo: |
235 |
AppendMenu(parent, help='', id=wx.ID_EXIT, |
|
236 |
kind=wx.ITEM_NORMAL, text=u'Quit\tCTRL+Q') |
|
221 | 237 |
else: |
238 |
AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL, |
|
239 |
kind=wx.ITEM_NORMAL, text=u'Close\tCTRL+Q') |
|
240 |
||
241 |
if self.ModeSolo: |
|
242 |
self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
|
243 |
self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
|
185 | 244 |
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE) |
221 | 245 |
if self.ModeSolo: |
246 |
self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
|
185 | 247 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
221 | 248 |
if self.ModeSolo: |
249 |
self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS) |
|
250 |
self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu, |
|
251 |
id=ID_PLCOPENEDITORFILEMENUGENERATE) |
|
213 | 252 |
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP) |
253 |
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW) |
|
254 |
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT) |
|
185 | 255 |
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
221 | 256 |
if self.ModeSolo: |
257 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
|
258 |
else: |
|
259 |
self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_CLOSE_ALL) |
|
185 | 260 |
|
261 |
def _init_coll_EditMenu_Items(self, parent): |
|
262 |
AppendMenu(parent, help='', id=wx.ID_REFRESH, |
|
263 |
kind=wx.ITEM_NORMAL, text=u'Refresh\tCTRL+R') |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
264 |
if not self.ModeSolo: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
265 |
AppendMenu(parent, help='', id=wx.ID_CLEAR, |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
266 |
kind=wx.ITEM_NORMAL, text=u'Clear Errors\tCTRL+K') |
185 | 267 |
AppendMenu(parent, help='', id=wx.ID_UNDO, |
268 |
kind=wx.ITEM_NORMAL, text=u'Undo\tCTRL+Z') |
|
269 |
AppendMenu(parent, help='', id=wx.ID_REDO, |
|
270 |
kind=wx.ITEM_NORMAL, text=u'Redo\tCTRL+Y') |
|
271 |
parent.AppendSeparator() |
|
272 |
AppendMenu(parent, help='', id=wx.ID_CUT, |
|
273 |
kind=wx.ITEM_NORMAL, text=u'Cut\tCTRL+X') |
|
274 |
AppendMenu(parent, help='', id=wx.ID_COPY, |
|
275 |
kind=wx.ITEM_NORMAL, text=u'Copy\tCTRL+C') |
|
276 |
AppendMenu(parent, help='', id=wx.ID_PASTE, |
|
277 |
kind=wx.ITEM_NORMAL, text=u'Paste\tCTRL+V') |
|
278 |
parent.AppendSeparator() |
|
279 |
addmenu = wx.Menu(title='') |
|
280 |
parent.AppendMenu(wx.ID_ADD, "Add Element", addmenu) |
|
281 |
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDDATATYPE, |
|
282 |
kind=wx.ITEM_NORMAL, text=u'Data Type') |
|
283 |
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTION, |
|
284 |
kind=wx.ITEM_NORMAL, text=u'Function') |
|
285 |
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, |
|
286 |
kind=wx.ITEM_NORMAL, text=u'Function Block') |
|
287 |
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDPROGRAM, |
|
288 |
kind=wx.ITEM_NORMAL, text=u'Program') |
|
289 |
AppendMenu(addmenu, help='', id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION, |
|
290 |
kind=wx.ITEM_NORMAL, text=u'Configuration') |
|
291 |
AppendMenu(parent, help='', id=wx.ID_DELETE, |
|
292 |
kind=wx.ITEM_NORMAL, text=u'Delete') |
|
293 |
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
294 |
if not self.ModeSolo: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
295 |
self.Bind(wx.EVT_MENU, self.OnClearErrorsMenu, id=wx.ID_CLEAR) |
185 | 296 |
self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO) |
297 |
self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO) |
|
298 |
self.Bind(wx.EVT_MENU, self.OnCutMenu, id=wx.ID_CUT) |
|
299 |
self.Bind(wx.EVT_MENU, self.OnCopyMenu, id=wx.ID_COPY) |
|
300 |
self.Bind(wx.EVT_MENU, self.OnPasteMenu, id=wx.ID_PASTE) |
|
301 |
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, |
|
302 |
id=ID_PLCOPENEDITOREDITMENUADDDATATYPE) |
|
303 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("function"), |
|
304 |
id=ID_PLCOPENEDITOREDITMENUADDFUNCTION) |
|
305 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("functionBlock"), |
|
306 |
id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK) |
|
307 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("program"), |
|
308 |
id=ID_PLCOPENEDITOREDITMENUADDPROGRAM) |
|
309 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, |
|
310 |
id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION) |
|
311 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE) |
|
312 |
||
0 | 313 |
def _init_coll_HelpMenu_Items(self, parent): |
185 | 314 |
AppendMenu(parent, help='', id=wx.ID_HELP, |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
315 |
kind=wx.ITEM_NORMAL, text=u'PLCOpenEditor\tF1') |
223
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
316 |
#AppendMenu(parent, help='', id=wx.ID_HELP_CONTENTS, |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
317 |
# kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2') |
190 | 318 |
#AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT, |
319 |
# kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3') |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
320 |
if self.ModeSolo: |
185 | 321 |
AppendMenu(parent, help='', id=wx.ID_ABOUT, |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
322 |
kind=wx.ITEM_NORMAL, text=u'About') |
190 | 323 |
self.Bind(wx.EVT_MENU, self.OnPLCOpenEditorMenu, id=wx.ID_HELP) |
223
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
324 |
#self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, id=wx.ID_HELP_CONTENTS) |
190 | 325 |
self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
0 | 326 |
|
327 |
def _init_utils(self): |
|
185 | 328 |
self.MenuBar = wx.MenuBar() |
0 | 329 |
|
220 | 330 |
self.FileMenu = wx.Menu(title='') |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
331 |
self.EditMenu = wx.Menu(title='') |
0 | 332 |
self.HelpMenu = wx.Menu(title='') |
163 | 333 |
|
185 | 334 |
self._init_coll_MenuBar_Menus(self.MenuBar) |
220 | 335 |
self._init_coll_FileMenu_Items(self.FileMenu) |
0 | 336 |
self._init_coll_EditMenu_Items(self.EditMenu) |
337 |
self._init_coll_HelpMenu_Items(self.HelpMenu) |
|
163 | 338 |
|
0 | 339 |
def _init_ctrls(self, prnt): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
340 |
wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name=u'PLCOpenEditor', |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
341 |
parent=prnt, pos=wx.DefaultPosition, size=wx.Size(1000, 600), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
342 |
style=wx.DEFAULT_FRAME_STYLE, title=u'PLCOpenEditor') |
0 | 343 |
self._init_utils() |
344 |
self.SetClientSize(wx.Size(1000, 600)) |
|
185 | 345 |
self.SetMenuBar(self.MenuBar) |
92
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
346 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
347 |
|
120 | 348 |
if wx.VERSION >= (2, 8, 0): |
349 |
self.AUIManager = wx.aui.AuiManager(self) |
|
121 | 350 |
self.AUIManager.SetDockSizeConstraint(0.5, 0.5) |
120 | 351 |
self.Panes = {} |
352 |
||
353 |
if wx.VERSION < (2, 8, 0): |
|
354 |
self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER, |
|
355 |
name='MainSplitter', parent=self, point=wx.Point(0, 0), |
|
356 |
size=wx.Size(0, 0), style=wx.SP_3D) |
|
357 |
self.MainSplitter.SetNeedUpdating(True) |
|
358 |
self.MainSplitter.SetMinimumPaneSize(1) |
|
359 |
||
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
360 |
self.TreeNoteBook = wx.Notebook(id=ID_PLCOPENEDITORTREENOTEBOOK, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
361 |
name='TreeNoteBook', parent=self.MainSplitter, pos=wx.Point(0, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
362 |
0), size=wx.Size(0, 0), style=0) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
363 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
364 |
self.TreeNoteBook = wx.aui.AuiNotebook(self) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
365 |
self.AUIManager.AddPane(self.TreeNoteBook, wx.aui.AuiPaneInfo().Caption("Project").Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False)) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
366 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
367 |
self.TypesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORTYPESTREE, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
368 |
name='TypesTree', parent=self.TreeNoteBook, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
369 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), |
120 | 370 |
style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
371 |
self.TreeNoteBook.AddPage(self.TypesTree, "Types") |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
372 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
373 |
if wx.Platform == '__WXMSW__': |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
374 |
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnTypesTreeRightUp, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
375 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
376 |
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTypesTreeItemSelected, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
377 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
378 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
379 |
if wx.VERSION >= (2, 6, 0): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
380 |
self.TypesTree.Bind(wx.EVT_RIGHT_UP, self.OnTypesTreeRightUp) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
381 |
self.TypesTree.Bind(wx.EVT_LEFT_UP, self.OnTypesTreeLeftUp) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
382 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
383 |
wx.EVT_RIGHT_UP(self.TypesTree, self.OnTypesTreeRightUp) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
384 |
wx.EVT_LEFT_UP(self.TypesTree, self.OnTypesTreeLeftUp) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
385 |
self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnTypesTreeItemChanging, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
386 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
387 |
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTypesTreeBeginDrag, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
388 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
389 |
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnTypesTreeItemBeginEdit, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
390 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
391 |
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnTypesTreeItemEndEdit, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
392 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
393 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnTypesTreeItemActivated, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
394 |
id=ID_PLCOPENEDITORTYPESTREE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
395 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
396 |
self.InstancesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORINSTANCESTREE, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
397 |
name='InstancesTree', parent=self.TreeNoteBook, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
398 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), |
120 | 399 |
style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
400 |
self.TreeNoteBook.AddPage(self.InstancesTree, "Instances") |
95 | 401 |
|
120 | 402 |
if wx.VERSION < (2, 8, 0): |
403 |
self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER, |
|
404 |
ID_PLCOPENEDITORTOOLBAR, 'ToolBar') |
|
405 |
self.ToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
|
406 |
self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, |
|
407 |
wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object") |
|
408 |
self.ToolBar.Realize() |
|
409 |
else: |
|
410 |
ToolBar = wx.ToolBar(self, ID_PLCOPENEDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize, |
|
411 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
|
412 |
ToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
|
413 |
ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, |
|
414 |
wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object") |
|
415 |
ToolBar.Realize() |
|
416 |
self.Panes["ToolBar"] = ToolBar |
|
417 |
self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo(). |
|
418 |
Name("ToolBar").Caption("Toolbar"). |
|
419 |
ToolbarPane().Top(). |
|
420 |
LeftDockable(False).RightDockable(False)) |
|
421 |
||
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
422 |
self.Bind(wx.EVT_TOOL, self.OnSelectionTool, |
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
423 |
id=ID_PLCOPENEDITORTOOLBARSELECTION) |
120 | 424 |
|
425 |
if wx.VERSION < (2, 8, 0): |
|
121 | 426 |
self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER, |
427 |
name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0), |
|
428 |
size=wx.Size(0, 0), style=wx.SP_3D) |
|
429 |
self.SecondSplitter.SetMinimumPaneSize(1) |
|
430 |
||
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
431 |
self.MainSplitter.SplitVertically(self.TreeNoteBook, self.SecondSplitter, 200) |
121 | 432 |
|
120 | 433 |
self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED, |
121 | 434 |
name='TabsOpened', parent=self.SecondSplitter, pos=wx.Point(0, |
120 | 435 |
0), size=wx.Size(0, 0), style=0) |
121 | 436 |
if wx.VERSION >= (2, 6, 0): |
437 |
self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
|
438 |
self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED) |
|
439 |
else: |
|
440 |
wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED, |
|
441 |
self.OnPouSelectedChanged) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
442 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
443 |
self.TabsOpened = wx.aui.AuiNotebook(self) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
444 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
445 |
self.OnPouSelectedChanged) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
446 |
self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane()) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
447 |
|
121 | 448 |
if wx.VERSION < (2, 8, 0): |
145 | 449 |
self.VariablePanelIndexer = VariablePanelIndexer(self.SecondSplitter, self, self.Controler) |
121 | 450 |
|
451 |
self.SecondSplitter.SplitHorizontally(self.TabsOpened, self.VariablePanelIndexer, -200) |
|
452 |
else: |
|
145 | 453 |
self.VariablePanelIndexer = VariablePanelIndexer(self, self, self.Controler) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
454 |
self.AUIManager.AddPane(self.VariablePanelIndexer, wx.aui.AuiPaneInfo().Caption("Variables").Bottom().Layer(0).BestSize(wx.Size(800, 200)).CloseButton(False)) |
121 | 455 |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
456 |
self.AUIManager.Update() |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
457 |
|
92
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
458 |
def __init__(self, parent, controler = None, fileOpen = None): |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
459 |
self.ModeSolo = controler == None |
121 | 460 |
if self.ModeSolo: |
461 |
self.Controler = PLCControler() |
|
462 |
if fileOpen is not None: |
|
463 |
self.Controler.OpenXMLFile(fileOpen) |
|
464 |
else: |
|
465 |
self.Controler = controler |
|
466 |
||
0 | 467 |
self._init_ctrls(parent) |
468 |
||
185 | 469 |
self.SetIcon(wx.Icon(os.path.join(CWD,"Images","poe.ico"),wx.BITMAP_TYPE_ICO)) |
176 | 470 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
471 |
self.TypesTreeImageList = wx.ImageList(16, 16) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
472 |
self.InstancesTreeImageList = wx.ImageList(16, 16) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
473 |
self.TypesTreeImageDict = {} |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
474 |
self.InstancesTreeImageDict = {} |
184
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
475 |
for language in LANGUAGES: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
476 |
self.TypesTreeImageDict[language]=self.TypesTreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%language))) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
477 |
self.InstancesTreeImageDict[language]=self.InstancesTreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%language))) |
184
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
478 |
|
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
479 |
for imgname, itemtype in [ |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
480 |
#editables |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
481 |
("PROJECT", ITEM_PROJECT), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
482 |
#("POU", ITEM_POU), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
483 |
#("VARIABLE", ITEM_VARIABLE), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
484 |
("TRANSITION", ITEM_TRANSITION), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
485 |
("ACTION", ITEM_ACTION), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
486 |
("CONFIGURATION", ITEM_CONFIGURATION), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
487 |
("RESOURCE", ITEM_RESOURCE), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
488 |
("DATATYPE", ITEM_DATATYPE), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
489 |
# uneditables |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
490 |
("DATATYPES", ITEM_DATATYPES), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
491 |
("FUNCTION", ITEM_FUNCTION), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
492 |
("FUNCTIONBLOCK", ITEM_FUNCTIONBLOCK), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
493 |
("PROGRAM", ITEM_PROGRAM), |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
494 |
("VAR_LOCAL", ITEM_VAR_LOCAL), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
495 |
("VAR_LOCAL", ITEM_VAR_GLOBAL), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
496 |
("VAR_LOCAL", ITEM_VAR_EXTERNAL), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
497 |
("VAR_LOCAL", ITEM_VAR_TEMP), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
498 |
("VAR_INPUT", ITEM_VAR_INPUT), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
499 |
("VAR_OUTPUT", ITEM_VAR_OUTPUT), |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
500 |
("VAR_INOUT", ITEM_VAR_INOUT), |
184
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
501 |
("TRANSITIONS", ITEM_TRANSITIONS), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
502 |
("ACTIONS", ITEM_ACTIONS), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
503 |
("CONFIGURATIONS", ITEM_CONFIGURATIONS), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
504 |
("RESOURCES", ITEM_RESOURCES), |
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
505 |
("PROPERTIES", ITEM_PROPERTIES)]: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
506 |
self.TypesTreeImageDict[itemtype]=self.TypesTreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname))) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
507 |
self.InstancesTreeImageDict[itemtype]=self.InstancesTreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname))) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
508 |
self.TypesTree.AssignImageList(self.TypesTreeImageList) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
509 |
self.InstancesTree.AssignImageList(self.InstancesTreeImageList) |
9 | 510 |
|
6 | 511 |
self.CurrentToolBar = [] |
27 | 512 |
self.CurrentLanguage = "" |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
513 |
self.SelectedItem = None |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
514 |
self.Errors = [] |
71 | 515 |
self.DrawingMode = FREEDRAWING_MODE |
516 |
#self.DrawingMode = DRIVENDRAWING_MODE |
|
6 | 517 |
|
213 | 518 |
self.PrintData = wx.PrintData() |
519 |
self.PrintData.SetPaperId(wx.PAPER_A4) |
|
520 |
self.PrintData.SetPrintMode(wx.PRINT_MODE_PRINTER) |
|
521 |
self.PageSetupData = wx.PageSetupDialogData(self.PrintData) |
|
522 |
self.PageSetupData.SetMarginTopLeft(wx.Point(10, 15)) |
|
523 |
self.PageSetupData.SetMarginBottomRight(wx.Point(10, 20)) |
|
524 |
||
121 | 525 |
if not self.ModeSolo or fileOpen is not None: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
526 |
self.RefreshTypesTree() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
527 |
self.RefreshInstancesTree() |
121 | 528 |
|
0 | 529 |
self.RefreshFileMenu() |
530 |
self.RefreshEditMenu() |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
531 |
self.RefreshTitle() |
0 | 532 |
self.RefreshToolBar() |
533 |
||
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
534 |
def ResetSelectedItem(self): |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
535 |
self.SelectedItem = None |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
536 |
|
121 | 537 |
def OnPageClose(self, event): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
538 |
selected = self.TabsOpened.GetSelection() |
121 | 539 |
if selected >= 0: |
540 |
tagname = self.GetPage(selected).GetTagName() |
|
541 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
542 |
if self.TabsOpened.GetPageCount() > 0: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
543 |
new_index = min(selected, self.TabsOpened.GetPageCount() - 1) |
121 | 544 |
tagname = self.GetPage(new_index).GetTagName() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
545 |
self.TabsOpened.SetSelection(new_index) |
121 | 546 |
self.VariablePanelIndexer.ChangeVariablePanel(tagname) |
547 |
self.RefreshTitle() |
|
548 |
self.RefreshFileMenu() |
|
549 |
self.RefreshEditMenu() |
|
550 |
self.RefreshToolBar() |
|
551 |
event.Skip() |
|
552 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
553 |
def GetCopyBuffer(self): |
163 | 554 |
return PLCOpenEditor.CopyBuffer |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
555 |
|
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
556 |
def SetCopyBuffer(self, element): |
163 | 557 |
PLCOpenEditor.CopyBuffer = element |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
558 |
self.RefreshEditMenu() |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
559 |
|
27 | 560 |
def GetDrawingMode(self): |
561 |
return self.DrawingMode |
|
562 |
||
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
563 |
def RefreshTitle(self): |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
564 |
if self.Controler.HasOpenedProject() > 0: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
565 |
self.SetTitle("PLCOpenEditor - %s"%self.Controler.GetFilename()) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
566 |
else: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
567 |
self.SetTitle("PLCOpenEditor") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
568 |
|
27 | 569 |
def ShowProperties(self): |
570 |
old_values = self.Controler.GetProjectProperties() |
|
571 |
dialog = ProjectDialog(self) |
|
572 |
dialog.SetValues(old_values) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
573 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 574 |
new_values = dialog.GetValues() |
575 |
new_values["creationDateTime"] = old_values["creationDateTime"] |
|
145 | 576 |
if new_values != old_values: |
577 |
self.Controler.SetProjectProperties(None, new_values) |
|
578 |
self.RefreshTitle() |
|
579 |
self.RefreshFileMenu() |
|
580 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
581 |
self.RefreshTypesTree() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
582 |
for i in xrange(self.TabsOpened.GetPageCount()): |
145 | 583 |
editor = self.GetPage(i) |
584 |
editor.RefreshScaling() |
|
27 | 585 |
dialog.Destroy() |
586 |
||
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
587 |
def OnCloseFrame(self, event): |
107 | 588 |
if not self.ModeSolo and getattr(self, "_onclose", None) is not None: |
121 | 589 |
self.AUIManager.UnInit() |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
590 |
self._onclose() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
591 |
event.Skip() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
592 |
elif not self.Controler.ProjectIsSaved(): |
80 | 593 |
dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
594 |
answer = dialog.ShowModal() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
595 |
dialog.Destroy() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
596 |
if answer == wx.ID_YES: |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
597 |
self.SaveProject() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
598 |
event.Skip() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
599 |
elif answer == wx.ID_NO: |
80 | 600 |
self.Controler.Reset() |
121 | 601 |
self.AUIManager.UnInit() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
602 |
event.Skip() |
80 | 603 |
else: |
604 |
event.Veto() |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
605 |
else: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
606 |
event.Skip() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
607 |
|
163 | 608 |
#------------------------------------------------------------------------------- |
609 |
# Notebook Unified Functions |
|
610 |
#------------------------------------------------------------------------------- |
|
611 |
||
612 |
def DeleteAllPages(self): |
|
613 |
if wx.VERSION >= (2, 8, 0): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
614 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
615 |
self.TabsOpened.DeletePage(0) |
163 | 616 |
else: |
617 |
self.TabsOpened.DeleteAllPages() |
|
618 |
||
203 | 619 |
def SetPageBitmap(self, idx, bitmap): |
620 |
if wx.VERSION >= (2, 8, 0): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
621 |
return self.TabsOpened.SetPageBitmap(idx, bitmap) |
203 | 622 |
else: |
623 |
return self.TabsOpened.SetPageImage(idx, bitmap) |
|
624 |
||
163 | 625 |
|
626 |
#------------------------------------------------------------------------------- |
|
627 |
# File Menu Functions |
|
628 |
#------------------------------------------------------------------------------- |
|
629 |
||
630 |
def RefreshFileMenu(self): |
|
221 | 631 |
if self.Controler.HasOpenedProject(): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
632 |
selected = self.TabsOpened.GetSelection() |
221 | 633 |
if selected >= 0: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
634 |
graphic_viewer = isinstance(self.TabsOpened.GetPage(selected), Viewer) |
221 | 635 |
else: |
636 |
graphic_viewer = False |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
637 |
if self.TabsOpened.GetPageCount() > 0: |
221 | 638 |
self.FileMenu.Enable(wx.ID_CLOSE, True) |
639 |
if graphic_viewer: |
|
640 |
self.FileMenu.Enable(wx.ID_PREVIEW, True) |
|
641 |
self.FileMenu.Enable(wx.ID_PRINT, True) |
|
213 | 642 |
else: |
643 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
644 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
221 | 645 |
else: |
646 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
647 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
648 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
649 |
self.FileMenu.Enable(wx.ID_SAVE, True) |
|
650 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, True) |
|
651 |
self.FileMenu.Enable(wx.ID_PROPERTIES, True) |
|
652 |
if self.ModeSolo: |
|
185 | 653 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True) |
654 |
self.FileMenu.Enable(wx.ID_SAVEAS, True) |
|
655 |
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True) |
|
221 | 656 |
else: |
657 |
self.FileMenu.Enable(wx.ID_CLOSE, False) |
|
658 |
self.FileMenu.Enable(wx.ID_SAVE, False) |
|
659 |
self.FileMenu.Enable(wx.ID_PAGE_SETUP, False) |
|
660 |
self.FileMenu.Enable(wx.ID_PREVIEW, False) |
|
661 |
self.FileMenu.Enable(wx.ID_PRINT, False) |
|
662 |
self.FileMenu.Enable(wx.ID_PROPERTIES, False) |
|
663 |
if self.ModeSolo: |
|
185 | 664 |
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False) |
665 |
self.FileMenu.Enable(wx.ID_SAVEAS, False) |
|
666 |
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False) |
|
163 | 667 |
|
0 | 668 |
def OnNewProjectMenu(self, event): |
669 |
dialog = ProjectDialog(self) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
670 |
if dialog.ShowModal() == wx.ID_OK: |
145 | 671 |
properties = dialog.GetValues() |
672 |
self.Controler.CreateNewProject(properties) |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
673 |
self.RefreshTitle() |
0 | 674 |
self.RefreshFileMenu() |
675 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
676 |
self.RefreshTypesTree() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
677 |
self.RefreshInstancesTree() |
0 | 678 |
event.Skip() |
679 |
||
680 |
def OnOpenProjectMenu(self, event): |
|
144 | 681 |
if not self.Controler.ProjectIsSaved(): |
682 |
dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
|
683 |
answer = dialog.ShowModal() |
|
684 |
dialog.Destroy() |
|
685 |
if answer == wx.ID_YES: |
|
686 |
self.SaveProject() |
|
687 |
elif answer == wx.ID_CANCEL: |
|
688 |
return |
|
0 | 689 |
filepath = self.Controler.GetFilePath() |
690 |
if filepath != "": |
|
691 |
directory = os.path.dirname(filepath) |
|
692 |
else: |
|
693 |
directory = os.getcwd() |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
694 |
dialog = wx.FileDialog(self, "Choose a file", directory, "", "PLCOpen files (*.xml)|*.xml|All files|*.*", wx.OPEN) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
695 |
if dialog.ShowModal() == wx.ID_OK: |
0 | 696 |
filepath = dialog.GetPath() |
697 |
if os.path.isfile(filepath): |
|
144 | 698 |
self.DeleteAllPages() |
699 |
self.VariablePanelIndexer.RemoveAllPanels() |
|
0 | 700 |
self.Controler.OpenXMLFile(filepath) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
701 |
self.RefreshTypesTree() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
702 |
self.RefreshInstancesTree() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
703 |
self.RefreshTitle() |
0 | 704 |
self.RefreshFileMenu() |
705 |
self.RefreshEditMenu() |
|
706 |
self.RefreshToolBar() |
|
707 |
dialog.Destroy() |
|
708 |
event.Skip() |
|
709 |
||
710 |
def OnCloseTabMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
711 |
selected = self.TabsOpened.GetSelection() |
0 | 712 |
if selected >= 0: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
713 |
tagname = self.TabsOpened.GetPage(selected).GetTagName() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
714 |
self.TabsOpened.DeletePage(selected) |
121 | 715 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
716 |
if self.TabsOpened.GetPageCount() > 0: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
717 |
new_index = min(selected, self.TabsOpened.GetPageCount() - 1) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
718 |
tagname = self.TabsOpened.GetPage(new_index).GetTagName() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
719 |
self.TabsOpened.SetSelection(new_index) |
121 | 720 |
self.VariablePanelIndexer.ChangeVariablePanel(tagname) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
721 |
self.RefreshTitle() |
0 | 722 |
self.RefreshFileMenu() |
723 |
self.RefreshEditMenu() |
|
724 |
self.RefreshToolBar() |
|
725 |
event.Skip() |
|
726 |
||
727 |
def OnCloseProjectMenu(self, event): |
|
144 | 728 |
if not self.Controler.ProjectIsSaved(): |
729 |
dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Application", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
|
730 |
answer = dialog.ShowModal() |
|
731 |
dialog.Destroy() |
|
732 |
if answer == wx.ID_YES: |
|
733 |
self.SaveProject() |
|
734 |
elif answer == wx.ID_CANCEL: |
|
735 |
return |
|
121 | 736 |
self.DeleteAllPages() |
737 |
self.VariablePanelIndexer.RemoveAllPanels() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
738 |
self.TypesTree.DeleteAllItems() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
739 |
self.InstancesTree.DeleteAllItems() |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
740 |
self.Controler.Reset() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
741 |
self.RefreshTitle() |
0 | 742 |
self.RefreshFileMenu() |
743 |
self.RefreshEditMenu() |
|
744 |
self.RefreshToolBar() |
|
745 |
event.Skip() |
|
746 |
||
747 |
def OnSaveProjectMenu(self, event): |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
748 |
if not self.ModeSolo and getattr(self, "_onsave", None) != None: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
749 |
self._onsave() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
750 |
else: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
751 |
self.SaveProject() |
0 | 752 |
event.Skip() |
753 |
||
754 |
def OnSaveProjectAsMenu(self, event): |
|
755 |
self.SaveProjectAs() |
|
756 |
event.Skip() |
|
757 |
||
758 |
def OnGenerateProgramMenu(self, event): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
759 |
dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), self.Controler.GetProgramFilePath(), "ST files (*.st)|*.st|All files|*.*", wx.SAVE|wx.CHANGE_DIR) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
760 |
if dialog.ShowModal() == wx.ID_OK: |
4
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
761 |
filepath = dialog.GetPath() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
762 |
if os.path.isdir(os.path.dirname(filepath)): |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
763 |
result = self.Controler.GenerateProgram(filepath) |
171 | 764 |
if result is not None: |
765 |
message = wx.MessageDialog(self, "Can't generate program to file %s :\n%s"%(filepath, result), "Error", wx.OK|wx.ICON_ERROR) |
|
4
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
766 |
message.ShowModal() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
767 |
message.Destroy() |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
65
diff
changeset
|
768 |
else: |
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
65
diff
changeset
|
769 |
message = wx.MessageDialog(self, "Program was successfully generated!", "Done", wx.OK|wx.ICON_INFORMATION) |
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
65
diff
changeset
|
770 |
message.ShowModal() |
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
65
diff
changeset
|
771 |
message.Destroy() |
4
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
772 |
else: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
773 |
message = wx.MessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR) |
4
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
774 |
message.ShowModal() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
775 |
message.Destroy() |
2de7fd952fdd
Adding File Dialog for choosing path to generated program
lbessard
parents:
3
diff
changeset
|
776 |
dialog.Destroy() |
0 | 777 |
event.Skip() |
778 |
||
779 |
def SaveProject(self): |
|
780 |
result = self.Controler.SaveXMLFile() |
|
781 |
if not result: |
|
782 |
self.SaveProjectAs() |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
783 |
else: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
784 |
self.RefreshTitle() |
0 | 785 |
|
786 |
def SaveProjectAs(self): |
|
787 |
filepath = self.Controler.GetFilePath() |
|
788 |
if filepath != "": |
|
789 |
directory, filename = os.path.split(filepath) |
|
790 |
else: |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
791 |
directory, filename = os.getcwd(), "%(projectName)s.xml"%self.Controler.GetProjectProperties() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
792 |
dialog = wx.FileDialog(self, "Choose a file", directory, filename, "PLCOpen files (*.xml)|*.xml|All files|*.*", wx.SAVE|wx.OVERWRITE_PROMPT) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
793 |
if dialog.ShowModal() == wx.ID_OK: |
0 | 794 |
filepath = dialog.GetPath() |
795 |
if os.path.isdir(os.path.dirname(filepath)): |
|
796 |
result = self.Controler.SaveXMLFile(filepath) |
|
797 |
if not result: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
798 |
message = wx.MessageDialog(self, "Can't save project to file %s!"%filepath, "Error", wx.OK|wx.ICON_ERROR) |
0 | 799 |
message.ShowModal() |
800 |
message.Destroy() |
|
801 |
else: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
802 |
message = wx.MessageDialog(self, "%s is not a valid folder!"%os.path.dirname(filepath), "Error", wx.OK|wx.ICON_ERROR) |
0 | 803 |
message.ShowModal() |
804 |
message.Destroy() |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
805 |
self.RefreshTitle() |
0 | 806 |
dialog.Destroy() |
807 |
||
213 | 808 |
def OnPageSetupMenu(self, event): |
809 |
dialog = wx.PageSetupDialog(self, self.PageSetupData) |
|
810 |
if dialog.ShowModal() == wx.ID_OK: |
|
811 |
self.PageSetupData = wx.PageSetupDialogData(dialog.GetPageSetupData()) |
|
812 |
self.PrintData = wx.PrintData(self.PageSetupData.GetPrintData()) |
|
813 |
dialog.Destroy() |
|
814 |
event.Skip() |
|
815 |
||
816 |
def OnPreviewMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
817 |
selected = self.TabsOpened.GetSelection() |
213 | 818 |
if selected != -1: |
819 |
data = wx.PrintDialogData(self.PrintData) |
|
820 |
properties = self.Controler.GetProjectProperties() |
|
821 |
page_size = map(int, properties["pageSize"]) |
|
822 |
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight()) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
823 |
printout = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins, True) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
824 |
printout2 = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins, True) |
213 | 825 |
preview = wx.PrintPreview(printout, printout2, data) |
826 |
||
827 |
if preview.Ok(): |
|
220 | 828 |
preview_frame = wx.PreviewFrame(preview, self, "Print preview") |
213 | 829 |
|
830 |
preview_frame.Initialize() |
|
831 |
||
832 |
preview_frame.Show(True) |
|
833 |
event.Skip() |
|
834 |
||
835 |
def OnPrintMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
836 |
selected = self.TabsOpened.GetSelection() |
213 | 837 |
if selected != -1: |
838 |
dialog_data = wx.PrintDialogData(self.PrintData) |
|
839 |
dialog_data.SetToPage(1) |
|
840 |
properties = self.Controler.GetProjectProperties() |
|
841 |
page_size = map(int, properties["pageSize"]) |
|
842 |
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight()) |
|
843 |
printer = wx.Printer(dialog_data) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
844 |
printout = GraphicPrintout(self.TabsOpened.GetPage(selected), page_size, margins) |
213 | 845 |
|
846 |
if not printer.Print(self, printout, True): |
|
847 |
wx.MessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wx.OK) |
|
848 |
printout.Destroy() |
|
849 |
event.Skip() |
|
850 |
||
27 | 851 |
def OnPropertiesMenu(self, event): |
852 |
self.ShowProperties() |
|
853 |
event.Skip() |
|
854 |
||
0 | 855 |
def OnQuitMenu(self, event): |
856 |
self.Close() |
|
857 |
event.Skip() |
|
858 |
||
163 | 859 |
|
860 |
#------------------------------------------------------------------------------- |
|
861 |
# Edit Project Menu Functions |
|
862 |
#------------------------------------------------------------------------------- |
|
863 |
||
864 |
def RefreshEditMenu(self): |
|
217
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
865 |
if self.Controler.HasOpenedProject(): |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
866 |
undo, redo = self.Controler.GetBufferState() |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
867 |
self.EditMenu.Enable(wx.ID_UNDO, undo) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
868 |
self.EditMenu.Enable(wx.ID_REDO, redo) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
869 |
else: |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
870 |
self.EditMenu.Enable(wx.ID_UNDO, False) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
871 |
self.EditMenu.Enable(wx.ID_REDO, False) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
872 |
if self.Controler.HasOpenedProject(): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
873 |
if self.TabsOpened.GetPageCount() > 0: |
217
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
874 |
self.EditMenu.Enable(wx.ID_REFRESH, True) |
185 | 875 |
else: |
876 |
self.EditMenu.Enable(wx.ID_REFRESH, False) |
|
217
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
877 |
self.EditMenu.Enable(wx.ID_ADD, True) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
878 |
self.EditMenu.Enable(wx.ID_DELETE, True) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
879 |
else: |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
880 |
self.EditMenu.Enable(wx.ID_REFRESH, False) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
881 |
self.EditMenu.Enable(wx.ID_ADD, False) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
882 |
self.EditMenu.Enable(wx.ID_DELETE, False) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
883 |
self.EditMenu.Enable(wx.ID_CUT, True) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
884 |
self.EditMenu.Enable(wx.ID_COPY, True) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
885 |
if self.CopyBuffer is not None: |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
886 |
self.EditMenu.Enable(wx.ID_PASTE, True) |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
887 |
else: |
ddb5b2e499e2
Remove useless tests on refreshing edit and file menus
lbessard
parents:
213
diff
changeset
|
888 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
163 | 889 |
|
890 |
def OnRefreshMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
891 |
selected = self.TabsOpened.GetSelection() |
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
892 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
893 |
window = self.TabsOpened.GetPage(selected) |
163 | 894 |
window.RefreshView() |
895 |
self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName()) |
|
896 |
event.Skip() |
|
897 |
||
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
898 |
def OnClearErrorsMenu(self, event): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
899 |
self.ClearErrors() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
900 |
event.Skip() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
901 |
|
163 | 902 |
def OnUndoMenu(self, event): |
903 |
self.Controler.LoadPrevious() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
904 |
idxs = range(self.TabsOpened.GetPageCount()) |
163 | 905 |
idxs.reverse() |
906 |
for idx in idxs: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
907 |
tagname = self.TabsOpened.GetPage(idx).GetTagName() |
163 | 908 |
if self.Controler.GetEditedElement(tagname) is None: |
909 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
910 |
self.TabsOpened.DeletePage(idx) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
911 |
selected = self.TabsOpened.GetSelection() |
163 | 912 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
913 |
window = self.TabsOpened.GetPage(selected) |
163 | 914 |
window.RefreshView() |
915 |
self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName()) |
|
916 |
self.RefreshTitle() |
|
917 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
918 |
self.RefreshTypesTree() |
163 | 919 |
event.Skip() |
920 |
||
921 |
def OnRedoMenu(self, event): |
|
922 |
self.Controler.LoadNext() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
923 |
idxs = range(self.TabsOpened.GetPageCount()) |
163 | 924 |
idxs.reverse() |
925 |
for idx in idxs: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
926 |
tagname = self.TabsOpened.GetPage(idx).GetTagName() |
163 | 927 |
if self.Controler.GetEditedElement(tagname) is None: |
928 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
929 |
self.TabsOpened.DeletePage(idx) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
930 |
selected = self.TabsOpened.GetSelection() |
0 | 931 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
932 |
window = self.TabsOpened.GetPage(selected) |
163 | 933 |
window.RefreshView() |
934 |
self.VariablePanelIndexer.RefreshVariablePanel(window.GetTagName()) |
|
935 |
self.RefreshTitle() |
|
936 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
937 |
self.RefreshTypesTree() |
163 | 938 |
event.Skip() |
939 |
||
940 |
def OnCutMenu(self, event): |
|
223
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
941 |
control = self.FindFocus() |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
942 |
if isinstance(control, Viewer): |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
943 |
control.Cut() |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
944 |
else: |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
945 |
control.ProcessEvent(event) |
163 | 946 |
event.Skip() |
947 |
||
948 |
def OnCopyMenu(self, event): |
|
223
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
949 |
control = self.FindFocus() |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
950 |
if isinstance(control, Viewer): |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
951 |
control.Copy() |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
952 |
else: |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
953 |
control.ProcessEvent(event) |
163 | 954 |
event.Skip() |
955 |
||
956 |
def OnPasteMenu(self, event): |
|
223
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
957 |
control = self.FindFocus() |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
958 |
if isinstance(control, Viewer): |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
959 |
control.Paste() |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
960 |
else: |
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
961 |
control.ProcessEvent(event) |
163 | 962 |
event.Skip() |
963 |
||
964 |
def OnDeleteMenu(self, event): |
|
965 |
window = self.FindFocus() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
966 |
if window == self.TypesTree: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
967 |
selected = self.TypesTree.GetSelection() |
163 | 968 |
if selected.IsOk(): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
969 |
type = self.TypesTree.GetPyData(selected) |
163 | 970 |
tagname = "" |
971 |
if type == ITEM_DATATYPE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
972 |
name = self.TypesTree.GetItemText(selected) |
163 | 973 |
if not self.Controler.DataTypeIsUsed(name): |
974 |
self.Controler.ProjectRemoveDataType(name) |
|
975 |
tagname = self.Controler.ComputeDataTypeName(name) |
|
976 |
else: |
|
977 |
message = wx.MessageDialog(self, "%s is used by one or more POUs. It can't be removed!"%selected, "Error", wx.OK|wx.ICON_ERROR) |
|
978 |
message.ShowModal() |
|
979 |
message.Destroy() |
|
980 |
elif type == ITEM_POU: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
981 |
name = self.TypesTree.GetItemText(selected) |
163 | 982 |
if not self.Controler.DataTypeIsUsed(name): |
983 |
self.Controler.ProjectRemoveDataType(name) |
|
984 |
tagname = self.Controler.ComputeDataTypeName(name) |
|
985 |
else: |
|
986 |
message = wx.MessageDialog(self, "%s is used by one or more POUs. It can't be removed!"%selected, "Error", wx.OK|wx.ICON_ERROR) |
|
987 |
message.ShowModal() |
|
988 |
message.Destroy() |
|
989 |
elif type in [ITEM_TRANSITION, ITEM_ACTION]: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
990 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
991 |
item_type = self.TypesTree.GetPyData(item) |
163 | 992 |
while item_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
993 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
994 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
995 |
pou_name = self.TypesTree.GetItemText(item) |
163 | 996 |
if type == ITEM_TRANSITION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
997 |
transition = self.TypesTree.GetItemText(selected) |
163 | 998 |
self.Controler.ProjectRemovePouTransition(pou_name, transition) |
999 |
tagname = self.Controler.ComputePouTransitionName(pou_name, transition) |
|
1000 |
elif type == ITEM_ACTION: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1001 |
action = self.TypesTree.GetItemText(selected) |
163 | 1002 |
self.Controler.ProjectRemovePouAction(pou_name, action) |
1003 |
tagname = self.Controler.ComputePouActionName(pou_name, action) |
|
1004 |
elif type == ITEM_CONFIGURATION: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1005 |
name = self.TypesTree.GetItemText(selected) |
163 | 1006 |
self.Controler.ProjectRemoveConfiguration(name) |
1007 |
tagname = self.Controler.ComputeConfigurationName(name) |
|
1008 |
elif type == ITEM_RESOURCE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1009 |
resource = self.TypesTree.GetItemText(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1010 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1011 |
item_type = self.TypesTree.GetPyData(item) |
163 | 1012 |
while item_type != ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1013 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1014 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1015 |
config_name = self.TypesTree.GetItemText(item) |
163 | 1016 |
self.Controler.ProjectRemoveConfigurationResource(config_name, resource) |
1017 |
tagname = self.Controler.ComputeConfigurationResourceName(config_name, selected) |
|
1018 |
idx = self.IsOpened(tagname) |
|
1019 |
if idx is not None: |
|
1020 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1021 |
self.TabsOpened.DeletePage(idx) |
163 | 1022 |
self.RefreshTitle() |
1023 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1024 |
self.RefreshTypesTree() |
163 | 1025 |
self.RefreshToolBar() |
1026 |
elif isinstance(window, (Viewer, TextViewer)): |
|
1027 |
event = wx.KeyEvent(wx.EVT_CHAR._getEvtType()) |
|
1028 |
event.m_keyCode = wx.WXK_DELETE |
|
1029 |
window.ProcessEvent(event) |
|
1030 |
event.Skip() |
|
1031 |
||
1032 |
||
1033 |
#------------------------------------------------------------------------------- |
|
1034 |
# Project Editor Panels Management Functions |
|
1035 |
#------------------------------------------------------------------------------- |
|
1036 |
||
0 | 1037 |
def OnPouSelectedChanged(self, event): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1038 |
old_selected = self.TabsOpened.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1039 |
if old_selected >= 0: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1040 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1041 |
selected = event.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1042 |
if selected >= 0: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1043 |
window = self.TabsOpened.GetPage(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1044 |
self.SelectTypesTreeItem(window.GetTagName()) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1045 |
window.RefreshView() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1046 |
self.VariablePanelIndexer.ChangeVariablePanel(window.GetTagName()) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1047 |
self.RefreshFileMenu() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1048 |
self.RefreshEditMenu() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1049 |
self.RefreshToolBar() |
0 | 1050 |
event.Skip() |
1051 |
||
163 | 1052 |
def RefreshEditor(self, variablepanel = True): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1053 |
selected = self.TabsOpened.GetSelection() |
163 | 1054 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1055 |
window = self.TabsOpened.GetPage(selected) |
163 | 1056 |
window.RefreshView() |
1057 |
if variablepanel: |
|
1058 |
self.RefreshVariablePanel(window.GetTagName()) |
|
1059 |
||
1060 |
def RefreshVariablePanel(self, tagname): |
|
1061 |
self.VariablePanelIndexer.RefreshVariablePanel(tagname) |
|
1062 |
||
1063 |
def RefreshEditorNames(self, old_tagname, new_tagname): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1064 |
for i in xrange(self.TabsOpened.GetPageCount()): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1065 |
editor = self.TabsOpened.GetPage(i) |
163 | 1066 |
if editor.GetTagName() == old_tagname: |
1067 |
editor.SetTagName(new_tagname) |
|
1068 |
self.VariablePanelIndexer.UpdateVariablePanelTagName(old_tagname, new_tagname) |
|
1069 |
||
1070 |
def IsOpened(self, tagname): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1071 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1072 |
if self.TabsOpened.GetPage(idx).IsViewing(tagname): |
163 | 1073 |
return idx |
1074 |
return None |
|
1075 |
||
1076 |
def RefreshPageTitles(self): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1077 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1078 |
window = self.TabsOpened.GetPage(idx) |
163 | 1079 |
words = window.GetTagName().split("::") |
203 | 1080 |
if words[0] == "P": |
1081 |
pou_type = self.Controler.GetEditedElementType(window.GetTagName())[1].upper() |
|
1082 |
pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName()) |
|
1083 |
self.SetPageBitmap(idx, GenerateBitmap(pou_type, pou_body_type)) |
|
1084 |
elif words[0] == "T": |
|
1085 |
pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName()) |
|
1086 |
self.SetPageBitmap(idx, GenerateBitmap("TRANSITION", pou_body_type)) |
|
1087 |
elif words[0] == "A": |
|
1088 |
pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName()) |
|
1089 |
self.SetPageBitmap(idx, GenerateBitmap("ACTION", pou_body_type)) |
|
1090 |
elif words[0] == "C": |
|
1091 |
self.SetPageBitmap(idx, GenerateBitmap("CONFIGURATION")) |
|
1092 |
elif words[0] == "R": |
|
1093 |
self.SetPageBitmap(idx, GenerateBitmap("RESOURCE")) |
|
1094 |
elif words[0] == "D": |
|
1095 |
self.SetPageBitmap(idx, GenerateBitmap("DATATYPE")) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1096 |
self.TabsOpened.SetPageText(idx, "-".join(words[1:])) |
163 | 1097 |
|
1098 |
||
1099 |
#------------------------------------------------------------------------------- |
|
1100 |
# Project Tree Management Functions |
|
1101 |
#------------------------------------------------------------------------------- |
|
1102 |
||
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1103 |
def RefreshTypesTree(self): |
163 | 1104 |
infos = self.Controler.GetProjectInfos() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1105 |
root = self.TypesTree.GetRootItem() |
163 | 1106 |
if not root.IsOk(): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1107 |
root = self.TypesTree.AddRoot(infos["name"]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1108 |
self.GenerateTypesTreeBranch(root, infos) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1109 |
self.TypesTree.Expand(self.TypesTree.GetRootItem()) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1110 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1111 |
def GenerateTypesTreeBranch(self, root, infos, topology=False): |
163 | 1112 |
to_delete = [] |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1113 |
self.TypesTree.SetItemText(root, infos["name"]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1114 |
self.TypesTree.SetPyData(root, infos["type"]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1115 |
if infos.get("tagname", None) in self.Errors: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1116 |
self.TypesTree.SetItemBackgroundColour(root, wx.Colour(255, 255, 0)) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1117 |
self.TypesTree.SetItemTextColour(root, wx.RED) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1118 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1119 |
self.TypesTree.SetItemBackgroundColour(root, wx.WHITE) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1120 |
self.TypesTree.SetItemTextColour(root, wx.BLACK) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1121 |
if infos["type"] == ITEM_POU: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1122 |
self.TypesTree.SetItemImage(root, self.TypesTreeImageDict[self.Controler.GetPouBodyType(infos["name"])]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1123 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1124 |
self.TypesTree.SetItemImage(root, self.TypesTreeImageDict[infos["type"]]) |
184
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
1125 |
|
163 | 1126 |
if wx.VERSION >= (2, 6, 0): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1127 |
item, root_cookie = self.TypesTree.GetFirstChild(root) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1128 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1129 |
item, root_cookie = self.TypesTree.GetFirstChild(root, 0) |
163 | 1130 |
for values in infos["values"]: |
1131 |
if not item.IsOk(): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1132 |
item = self.TypesTree.AppendItem(root, "") |
163 | 1133 |
if wx.Platform != '__WXMSW__': |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1134 |
item, root_cookie = self.TypesTree.GetNextChild(root, root_cookie) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1135 |
self.GenerateTypesTreeBranch(item, values) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1136 |
item, root_cookie = self.TypesTree.GetNextChild(root, root_cookie) |
163 | 1137 |
while item.IsOk(): |
1138 |
to_delete.append(item) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1139 |
item, root_cookie = self.TypesTree.GetNextChild(root, root_cookie) |
163 | 1140 |
for item in to_delete: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1141 |
self.TypesTree.Delete(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1142 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1143 |
def SelectTypesTreeItem(self, tagname): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1144 |
if self.TypesTree: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1145 |
root = self.TypesTree.GetRootItem() |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1146 |
words = tagname.split("::") |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1147 |
if words[0] == "D": |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1148 |
return self.RecursiveTypesTreeItemSelection(root, [(words[1], ITEM_DATATYPE)]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1149 |
elif words[0] == "P": |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1150 |
return self.RecursiveTypesTreeItemSelection(root, [(words[1], ITEM_POU)]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1151 |
elif words[0] == "T": |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1152 |
return self.RecursiveTypesTreeItemSelection(root, [(words[1], ITEM_POU), (words[2], ITEM_TRANSITION)]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1153 |
elif words[0] == "A": |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1154 |
return self.RecursiveTypesTreeItemSelection(root, [(words[1], ITEM_POU), (words[2], ITEM_ACTION)]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1155 |
elif words[0] == "C": |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1156 |
return self.RecursiveTypesTreeItemSelection(root, [(words[1], ITEM_CONFIGURATION)]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1157 |
elif words[0] == "R": |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1158 |
return self.RecursiveTypesTreeItemSelection(root, [(words[1], ITEM_CONFIGURATION), (words[2], ITEM_RESOURCE)]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1159 |
return False |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1160 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1161 |
def RecursiveTypesTreeItemSelection(self, root, items): |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1162 |
found = False |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1163 |
if self.TypesTree: |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1164 |
if wx.VERSION >= (2, 6, 0): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1165 |
item, root_cookie = self.TypesTree.GetFirstChild(root) |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1166 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1167 |
item, root_cookie = self.TypesTree.GetFirstChild(root, 0) |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1168 |
while item.IsOk() and not found: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1169 |
if (self.TypesTree.GetItemText(item), self.TypesTree.GetPyData(item)) == items[0]: |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1170 |
if len(items) == 1: |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1171 |
self.SelectedItem = item |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1172 |
self.TypesTree.SelectItem(item) |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1173 |
wx.CallAfter(self.ResetSelectedItem) |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1174 |
return True |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1175 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1176 |
found = self.RecursiveTypesTreeItemSelection(item, items[1:]) |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1177 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1178 |
found = self.RecursiveTypesTreeItemSelection(item, items) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1179 |
item, root_cookie = self.TypesTree.GetNextChild(root, root_cookie) |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1180 |
return found |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1181 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1182 |
def OnTypesTreeBeginDrag(self, event): |
131 | 1183 |
if wx.Platform == '__WXMSW__': |
134 | 1184 |
self.SelectedItem = event.GetItem() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1185 |
if self.SelectedItem is not None and self.TypesTree.GetPyData(self.SelectedItem) == ITEM_POU: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1186 |
block_name = self.TypesTree.GetItemText(self.SelectedItem) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
1187 |
block_type = self.Controler.GetPouType(block_name) |
53 | 1188 |
if block_type != "program": |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
1189 |
data = wx.TextDataObject(str((block_name, block_type, ""))) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1190 |
dragSource = wx.DropSource(self.TypesTree) |
53 | 1191 |
dragSource.SetData(data) |
1192 |
dragSource.DoDragDrop() |
|
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1193 |
self.ResetSelectedItem() |
7 | 1194 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1195 |
def OnTypesTreeItemBeginEdit(self, event): |
163 | 1196 |
selected = event.GetItem() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1197 |
if self.TypesTree.GetPyData(selected) in ITEMS_UNEDITABLE: |
163 | 1198 |
event.Veto() |
1199 |
else: |
|
1200 |
event.Skip() |
|
107 | 1201 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1202 |
def OnTypesTreeItemEndEdit(self, event): |
6 | 1203 |
message = None |
1204 |
abort = False |
|
0 | 1205 |
new_name = event.GetLabel() |
1206 |
if new_name != "": |
|
6 | 1207 |
if not TestIdentifier(new_name): |
1208 |
message = "\"%s\" is not a valid identifier!"%new_name |
|
1209 |
elif new_name.upper() in IEC_KEYWORDS: |
|
1210 |
message = "\"%s\" is a keyword. It can't be used!"%new_name |
|
1211 |
else: |
|
0 | 1212 |
item = event.GetItem() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1213 |
old_name = self.TypesTree.GetItemText(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1214 |
itemtype = self.TypesTree.GetPyData(item) |
0 | 1215 |
if itemtype == ITEM_PROJECT: |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
1216 |
self.Controler.SetProjectProperties(name = new_name) |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1217 |
elif itemtype == ITEM_DATATYPE: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1218 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames() if name != old_name]: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1219 |
message = "\"%s\" data type already exists!"%new_name |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1220 |
abort = True |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1221 |
if not abort: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1222 |
self.Controler.ChangeDataTypeName(old_name, new_name) |
145 | 1223 |
self.RefreshEditorNames(self.Controler.ComputeDataTypeName(old_name), |
1224 |
self.Controler.ComputeDataTypeName(new_name)) |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1225 |
self.RefreshPageTitles() |
0 | 1226 |
elif itemtype == ITEM_POU: |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1227 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
6 | 1228 |
message = "\"%s\" pou already exists!"%new_name |
1229 |
abort = True |
|
70 | 1230 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables()]: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
1231 |
messageDialog = wx.MessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
1232 |
if messageDialog.ShowModal() == wx.ID_NO: |
6 | 1233 |
abort = True |
1234 |
messageDialog.Destroy() |
|
1235 |
if not abort: |
|
1236 |
self.Controler.ChangePouName(old_name, new_name) |
|
145 | 1237 |
self.RefreshEditorNames(self.Controler.ComputePouName(old_name), |
1238 |
self.Controler.ComputePouName(new_name)) |
|
121 | 1239 |
self.RefreshPageTitles() |
0 | 1240 |
elif itemtype == ITEM_TRANSITION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1241 |
parent = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1242 |
parent_type = self.TypesTree.GetPyData(parent) |
107 | 1243 |
while parent_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1244 |
parent = self.TypesTree.GetItemParent(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1245 |
parent_type = self.TypesTree.GetPyData(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1246 |
pou_name = self.TypesTree.GetItemText(parent) |
70 | 1247 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
6 | 1248 |
message = "A pou with \"%s\" as name exists!"%new_name |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1249 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name) if name != old_name]: |
6 | 1250 |
message = "A variable with \"%s\" as name already exists in this pou!"%new_name |
1251 |
else: |
|
1252 |
self.Controler.ChangePouTransitionName(pou_name, old_name, new_name) |
|
145 | 1253 |
self.RefreshEditorNames(self.Controler.ComputePouTransitionName(pou_name, old_name), |
1254 |
self.Controler.ComputePouTransitionName(pou_name, new_name)) |
|
121 | 1255 |
self.RefreshPageTitles() |
0 | 1256 |
elif itemtype == ITEM_ACTION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1257 |
parent = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1258 |
parent_type = self.TypesTree.GetPyData(parent) |
107 | 1259 |
while parent_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1260 |
parent = self.TypesTree.GetItemParent(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1261 |
parent_type = self.TypesTree.GetPyData(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1262 |
pou_name = self.TypesTree.GetItemText(parent) |
70 | 1263 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
6 | 1264 |
message = "A pou with \"%s\" as name exists!"%new_name |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1265 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name) if name != old_name]: |
6 | 1266 |
message = "A variable with \"%s\" as name already exists in this pou!"%new_name |
1267 |
else: |
|
1268 |
self.Controler.ChangePouActionName(pou_name, old_name, new_name) |
|
145 | 1269 |
self.RefreshEditorNames(self.Controler.ComputePouActionName(pou_name, old_name), |
1270 |
self.Controler.ComputePouActionName(pou_name, new_name)) |
|
121 | 1271 |
self.RefreshPageTitles() |
107 | 1272 |
elif itemtype == ITEM_CONFIGURATION: |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1273 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
107 | 1274 |
message = "\"%s\" config already exists!"%new_name |
1275 |
abort = True |
|
1276 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
|
1277 |
messageDialog = wx.MessageDialog(self, "A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION) |
|
1278 |
if messageDialog.ShowModal() == wx.ID_NO: |
|
1279 |
abort = True |
|
1280 |
messageDialog.Destroy() |
|
1281 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables()]: |
|
1282 |
messageDialog = wx.MessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION) |
|
1283 |
if messageDialog.ShowModal() == wx.ID_NO: |
|
1284 |
abort = True |
|
1285 |
messageDialog.Destroy() |
|
1286 |
if not abort: |
|
1287 |
self.Controler.ChangeConfigurationName(old_name, new_name) |
|
145 | 1288 |
self.RefreshEditorNames(self.Controler.ComputeConfigurationName(old_name), |
1289 |
self.Controler.ComputeConfigurationName(new_name)) |
|
121 | 1290 |
self.RefreshPageTitles() |
107 | 1291 |
elif itemtype == ITEM_RESOURCE: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1292 |
parent = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1293 |
parent_type = self.TypesTree.GetPyData(parent) |
107 | 1294 |
while parent_type != ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1295 |
parent = self.TypesTree.GetItemParent(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1296 |
parent_type = self.TypesTree.GetPyData(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1297 |
config_name = self.TypesTree.GetItemText(parent) |
107 | 1298 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
1299 |
message = "\"%s\" config already exists!"%new_name |
|
1300 |
abort = True |
|
1301 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
|
1302 |
messageDialog = wx.MessageDialog(self, "A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION) |
|
1303 |
if messageDialog.ShowModal() == wx.ID_NO: |
|
1304 |
abort = True |
|
1305 |
messageDialog.Destroy() |
|
1306 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables()]: |
|
1307 |
messageDialog = wx.MessageDialog(self, "A variable is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?"%new_name, "Error", wx.YES_NO|wx.ICON_QUESTION) |
|
1308 |
if messageDialog.ShowModal() == wx.ID_NO: |
|
1309 |
abort = True |
|
1310 |
messageDialog.Destroy() |
|
1311 |
if not abort: |
|
1312 |
self.Controler.ChangeConfigurationResourceName(config_name, old_name, new_name) |
|
145 | 1313 |
self.RefreshEditorNames(self.Controler.ComputeConfigurationResourceName(config_name, old_name), |
1314 |
self.Controler.ComputeConfigurationResourceName(config_name, new_name)) |
|
121 | 1315 |
self.RefreshPageTitles() |
6 | 1316 |
if message or abort: |
1317 |
if message: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
1318 |
messageDialog = wx.MessageDialog(self, message, "Error", wx.OK|wx.ICON_ERROR) |
6 | 1319 |
messageDialog.ShowModal() |
1320 |
messageDialog.Destroy() |
|
0 | 1321 |
item = event.GetItem() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1322 |
wx.CallAfter(self.TypesTree.EditLabel, item) |
0 | 1323 |
event.Veto() |
6 | 1324 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1325 |
wx.CallAfter(self.RefreshTypesTree) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1326 |
selected = self.TabsOpened.GetSelection() |
121 | 1327 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1328 |
self.TabsOpened.GetPage(selected).RefreshView() |
6 | 1329 |
event.Skip() |
0 | 1330 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1331 |
def OnTypesTreeItemActivated(self, event): |
0 | 1332 |
selected = event.GetItem() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1333 |
if self.TypesTree.IsExpanded(selected): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1334 |
self.TypesTree.Collapse(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1335 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1336 |
self.TypesTree.Expand(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1337 |
name = self.TypesTree.GetItemText(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1338 |
data = self.TypesTree.GetPyData(selected) |
0 | 1339 |
if name == "Properties": |
27 | 1340 |
self.ShowProperties() |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1341 |
if data == ITEM_DATATYPE: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1342 |
self.EditProjectElement(data, self.Controler.ComputeDataTypeName(name)) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1343 |
elif data == ITEM_POU: |
121 | 1344 |
self.EditProjectElement(data, self.Controler.ComputePouName(name)) |
1345 |
elif data == ITEM_CONFIGURATION: |
|
1346 |
self.EditProjectElement(data, self.Controler.ComputeConfigurationName(name)) |
|
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1347 |
elif data == ITEM_RESOURCE: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1348 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1349 |
item_type = self.TypesTree.GetPyData(item) |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1350 |
while item_type != ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1351 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1352 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1353 |
config_name = self.TypesTree.GetItemText(item) |
121 | 1354 |
self.EditProjectElement(data, self.Controler.ComputeConfigurationResourceName(config_name, name)) |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1355 |
elif data in [ITEM_TRANSITION, ITEM_ACTION]: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1356 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1357 |
item_type = self.TypesTree.GetPyData(item) |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1358 |
while item_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1359 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1360 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1361 |
pou_name = self.TypesTree.GetItemText(item) |
121 | 1362 |
if data == ITEM_TRANSITION: |
1363 |
tagname = self.Controler.ComputePouTransitionName(pou_name, name) |
|
1364 |
elif data == ITEM_ACTION: |
|
1365 |
tagname = self.Controler.ComputePouActionName(pou_name, name) |
|
1366 |
self.EditProjectElement(data, tagname) |
|
129 | 1367 |
event.Skip() |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1368 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1369 |
def TypesTreeItemSelect(self, select_item): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1370 |
name = self.TypesTree.GetItemText(select_item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1371 |
data = self.TypesTree.GetPyData(select_item) |
131 | 1372 |
if data == ITEM_DATATYPE: |
1373 |
self.EditProjectElement(data, self.Controler.ComputeDataTypeName(name), True) |
|
1374 |
elif data == ITEM_POU: |
|
1375 |
self.EditProjectElement(data, self.Controler.ComputePouName(name), True) |
|
1376 |
elif data == ITEM_CONFIGURATION: |
|
1377 |
self.EditProjectElement(data, self.Controler.ComputeConfigurationName(name), True) |
|
1378 |
elif data == ITEM_RESOURCE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1379 |
item = self.TypesTree.GetItemParent(select_item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1380 |
item_type = self.TypesTree.GetPyData(item) |
131 | 1381 |
while item_type != ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1382 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1383 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1384 |
config_name = self.TypesTree.GetItemText(item) |
131 | 1385 |
self.EditProjectElement(data, self.Controler.ComputeConfigurationResourceName(config_name, name), True) |
1386 |
elif data in [ITEM_TRANSITION, ITEM_ACTION]: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1387 |
item = self.TypesTree.GetItemParent(select_item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1388 |
item_type = self.TypesTree.GetPyData(item) |
131 | 1389 |
while item_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1390 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1391 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1392 |
pou_name = self.TypesTree.GetItemText(item) |
131 | 1393 |
if data == ITEM_TRANSITION: |
1394 |
tagname = self.Controler.ComputePouTransitionName(pou_name, name) |
|
1395 |
elif data == ITEM_ACTION: |
|
1396 |
tagname = self.Controler.ComputePouActionName(pou_name, name) |
|
1397 |
self.EditProjectElement(data, tagname, True) |
|
1398 |
||
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1399 |
def OnTypesTreeLeftUp(self, event): |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1400 |
if self.SelectedItem is not None: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1401 |
self.TypesTree.SelectItem(self.SelectedItem) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1402 |
self.TypesTreeItemSelect(self.SelectedItem) |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1403 |
wx.CallAfter(self.ResetSelectedItem) |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1404 |
event.Skip() |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1405 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1406 |
def OnTypesTreeItemSelected(self, event): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1407 |
self.TypesTreeItemSelect(event.GetItem()) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1408 |
event.Skip() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1409 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1410 |
def OnTypesTreeItemChanging(self, event): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1411 |
if self.TypesTree.GetPyData(event.GetItem()) not in ITEMS_UNEDITABLE and self.SelectedItem is None: |
122
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1412 |
self.SelectedItem = event.GetItem() |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1413 |
event.Veto() |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1414 |
else: |
e6faee0c271b
Adding support for Project Tree selected item following current item edited.
lbessard
parents:
121
diff
changeset
|
1415 |
event.Skip() |
121 | 1416 |
|
1417 |
def EditProjectElement(self, elementtype, tagname, onlyopened = False): |
|
1418 |
openedidx = self.IsOpened(tagname) |
|
1419 |
if openedidx is not None: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1420 |
old_selected = self.TabsOpened.GetSelection() |
121 | 1421 |
if old_selected != openedidx: |
1422 |
if old_selected >= 0: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1423 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1424 |
self.TabsOpened.SetSelection(openedidx) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1425 |
self.TabsOpened.GetPage(openedidx).RefreshView() |
121 | 1426 |
self.VariablePanelIndexer.ChangeVariablePanel(tagname) |
1427 |
self.RefreshPageTitles() |
|
1428 |
self.RefreshFileMenu() |
|
1429 |
self.RefreshEditMenu() |
|
1430 |
self.RefreshToolBar() |
|
1431 |
elif not onlyopened: |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1432 |
if elementtype == ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1433 |
new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1434 |
self.TabsOpened.AddPage(new_window, "") |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1435 |
self.VariablePanelIndexer.AddVariablePanel(tagname, "config") |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1436 |
elif elementtype == ITEM_RESOURCE: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1437 |
new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1438 |
self.TabsOpened.AddPage(new_window, "") |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1439 |
self.VariablePanelIndexer.AddVariablePanel(tagname, "resource") |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1440 |
elif elementtype in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1441 |
bodytype = self.Controler.GetEditedElementBodyType(tagname) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1442 |
if bodytype == "FBD": |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1443 |
new_window = Viewer(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1444 |
new_window.RefreshScaling(False) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1445 |
elif bodytype == "LD": |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1446 |
new_window = LD_Viewer(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1447 |
new_window.RefreshScaling(False) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1448 |
elif bodytype == "SFC": |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1449 |
new_window = SFC_Viewer(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1450 |
new_window.RefreshScaling(False) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1451 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1452 |
new_window = TextViewer(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1453 |
new_window.SetTextSyntax(elementtype) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1454 |
if bodytype == "IL": |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1455 |
new_window.SetKeywords(IL_KEYWORDS) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1456 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1457 |
new_window.SetKeywords(ST_KEYWORDS) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1458 |
self.TabsOpened.AddPage(new_window, "") |
121 | 1459 |
words = tagname.split("::") |
1460 |
self.VariablePanelIndexer.AddVariablePanel(tagname, self.Controler.GetPouType(words[1])) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1461 |
elif elementtype == ITEM_DATATYPE: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1462 |
new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1463 |
self.TabsOpened.AddPage(new_window, "") |
121 | 1464 |
self.VariablePanelIndexer.ChangeVariablePanel(tagname) |
1465 |
openedidx = self.IsOpened(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1466 |
old_selected = self.TabsOpened.GetSelection() |
121 | 1467 |
if old_selected != openedidx: |
1468 |
if old_selected >= 0: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1469 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1470 |
for i in xrange(self.TabsOpened.GetPageCount()): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1471 |
window = self.TabsOpened.GetPage(i) |
121 | 1472 |
if window.GetTagName() == tagname: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1473 |
self.TabsOpened.SetSelection(i) |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1474 |
window.RefreshView() |
129 | 1475 |
window.SetFocus() |
121 | 1476 |
self.RefreshPageTitles() |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1477 |
self.RefreshFileMenu() |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1478 |
self.RefreshEditMenu() |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1479 |
self.RefreshToolBar() |
0 | 1480 |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1481 |
def OnTypesTreeRightUp(self, event): |
159 | 1482 |
if wx.Platform == '__WXMSW__': |
163 | 1483 |
item = event.GetItem() |
1484 |
else: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1485 |
item = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1486 |
name = self.TypesTree.GetItemText(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1487 |
type = self.TypesTree.GetPyData(item) |
163 | 1488 |
if type == ITEM_POU: |
1489 |
menu = wx.Menu(title='') |
|
0 | 1490 |
if self.Controler.GetPouBodyType(name) == "SFC": |
163 | 1491 |
new_id = wx.NewId() |
1492 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Transition") |
|
1493 |
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), id=new_id) |
|
1494 |
new_id = wx.NewId() |
|
1495 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Action") |
|
1496 |
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), id=new_id) |
|
1497 |
menu.AppendSeparator() |
|
1498 |
new_id = wx.NewId() |
|
1499 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete") |
|
1500 |
self.Bind(wx.EVT_MENU, self.OnRemovePouMenu, id=new_id) |
|
1501 |
self.PopupMenu(menu) |
|
1502 |
elif type == ITEM_CONFIGURATION: |
|
1503 |
menu = wx.Menu(title='') |
|
1504 |
new_id = wx.NewId() |
|
1505 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Resource") |
|
1506 |
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), id=new_id) |
|
1507 |
new_id = wx.NewId() |
|
1508 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete") |
|
1509 |
self.Bind(wx.EVT_MENU, self.OnRemoveConfigurationMenu, id=new_id) |
|
1510 |
self.PopupMenu(menu) |
|
1511 |
elif type in [ITEM_DATATYPE, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE]: |
|
1512 |
menu = wx.Menu(title='') |
|
1513 |
new_id = wx.NewId() |
|
1514 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete") |
|
1515 |
if type == ITEM_DATATYPE: |
|
1516 |
self.Bind(wx.EVT_MENU, self.OnRemoveDataTypeMenu, id=new_id) |
|
1517 |
elif type == ITEM_TRANSITION: |
|
1518 |
self.Bind(wx.EVT_MENU, self.OnRemoveTransitionMenu, id=new_id) |
|
1519 |
elif type == ITEM_ACTION: |
|
1520 |
self.Bind(wx.EVT_MENU, self.OnRemoveActionMenu, id=new_id) |
|
1521 |
elif type == ITEM_RESOURCE: |
|
1522 |
self.Bind(wx.EVT_MENU, self.OnRemoveResourceMenu, id=new_id) |
|
1523 |
self.PopupMenu(menu) |
|
184
d3e6484ebe85
changed the way icons are loaded for both toolbars and treectrl. Now, non editable items have different pyData.
etisserant
parents:
183
diff
changeset
|
1524 |
elif type in ITEMS_UNEDITABLE: |
163 | 1525 |
if name == "Data Types": |
1526 |
menu = wx.Menu(title='') |
|
1527 |
new_id = wx.NewId() |
|
1528 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add DataType") |
|
1529 |
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, id=new_id) |
|
1530 |
self.PopupMenu(menu) |
|
1531 |
elif name in ["Functions", "Function Blocks", "Programs"]: |
|
1532 |
menu = wx.Menu(title='') |
|
1533 |
new_id = wx.NewId() |
|
1534 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Pou") |
|
1535 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions" : "function", "Function Blocks" : "functionBlock", "Programs" : "program"}[name]), id=new_id) |
|
1536 |
self.PopupMenu(menu) |
|
1537 |
elif name == "Configurations": |
|
1538 |
menu = wx.Menu(title='') |
|
1539 |
new_id = wx.NewId() |
|
1540 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Configuration") |
|
1541 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, id=new_id) |
|
1542 |
self.PopupMenu(menu) |
|
1543 |
elif name == "Transitions": |
|
1544 |
menu = wx.Menu(title='') |
|
1545 |
new_id = wx.NewId() |
|
1546 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Transition") |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1547 |
parent = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1548 |
parent_type = self.TypesTree.GetPyData(parent) |
163 | 1549 |
while parent_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1550 |
parent = self.TypesTree.GetItemParent(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1551 |
parent_type = self.TypesTree.GetPyData(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1552 |
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(self.TypesTree.GetItemText(parent)), id=new_id) |
163 | 1553 |
self.PopupMenu(menu) |
1554 |
elif name == "Actions": |
|
1555 |
menu = wx.Menu(title='') |
|
1556 |
new_id = wx.NewId() |
|
1557 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Action") |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1558 |
parent = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1559 |
parent_type = self.TypesTree.GetPyData(parent) |
163 | 1560 |
while parent_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1561 |
parent = self.TypesTree.GetItemParent(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1562 |
parent_type = self.TypesTree.GetPyData(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1563 |
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(self.TypesTree.GetItemText(parent)), id=new_id) |
163 | 1564 |
self.PopupMenu(menu) |
1565 |
elif name == "Resources": |
|
1566 |
menu = wx.Menu(title='') |
|
1567 |
new_id = wx.NewId() |
|
1568 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Add Resource") |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1569 |
parent = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1570 |
parent_type = self.TypesTree.GetPyData(parent) |
163 | 1571 |
while parent_type != ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1572 |
parent = self.TypesTree.GetItemParent(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1573 |
parent_type = self.TypesTree.GetPyData(parent) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1574 |
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(self.TypesTree.GetItemText(parent)), id=new_id) |
163 | 1575 |
self.PopupMenu(menu) |
1576 |
event.Skip() |
|
1577 |
||
1578 |
||
1579 |
#------------------------------------------------------------------------------- |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1580 |
# Topology Tree Management Functions |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1581 |
#------------------------------------------------------------------------------- |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1582 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1583 |
def RefreshInstancesTree(self): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1584 |
infos = self.Controler.GetProjectTopology() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1585 |
root = self.InstancesTree.GetRootItem() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1586 |
if not root.IsOk(): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1587 |
root = self.InstancesTree.AddRoot(infos["name"]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1588 |
self.GenerateInstancesTreeBranch(root, infos) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1589 |
self.InstancesTree.Expand(self.InstancesTree.GetRootItem()) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1590 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1591 |
def GenerateInstancesTreeBranch(self, root, infos): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1592 |
to_delete = [] |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1593 |
if infos.get("elmt_type", None) is not None: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1594 |
self.InstancesTree.SetItemText(root, "%s(%s)"%(infos["name"], infos["elmt_type"])) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1595 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1596 |
self.InstancesTree.SetItemText(root, infos["name"]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1597 |
self.InstancesTree.SetPyData(root, infos["type"]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1598 |
self.InstancesTree.SetItemImage(root, self.InstancesTreeImageDict[infos["type"]]) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1599 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1600 |
if wx.VERSION >= (2, 6, 0): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1601 |
item, root_cookie = self.InstancesTree.GetFirstChild(root) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1602 |
else: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1603 |
item, root_cookie = self.InstancesTree.GetFirstChild(root, 0) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1604 |
for values in infos["values"]: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1605 |
if not item.IsOk(): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1606 |
item = self.InstancesTree.AppendItem(root, "") |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1607 |
if wx.Platform != '__WXMSW__': |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1608 |
item, root_cookie = self.InstancesTree.GetNextChild(root, root_cookie) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1609 |
self.GenerateInstancesTreeBranch(item, values) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1610 |
item, root_cookie = self.InstancesTree.GetNextChild(root, root_cookie) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1611 |
while item.IsOk(): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1612 |
to_delete.append(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1613 |
item, root_cookie = self.InstancesTree.GetNextChild(root, root_cookie) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1614 |
for item in to_delete: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1615 |
self.InstancesTree.Delete(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1616 |
|
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1617 |
#------------------------------------------------------------------------------- |
163 | 1618 |
# ToolBar Management Functions |
1619 |
#------------------------------------------------------------------------------- |
|
1620 |
||
6 | 1621 |
def ResetToolBar(self): |
1622 |
for item in self.CurrentToolBar: |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1623 |
if wx.VERSION >= (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1624 |
self.Unbind(wx.EVT_MENU, id=item) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1625 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
1626 |
self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED) |
120 | 1627 |
|
1628 |
if wx.VERSION < (2, 8, 0): |
|
1629 |
ToolBar = self.ToolBar |
|
1630 |
else: |
|
1631 |
ToolBar = self.Panes["ToolBar"] |
|
121 | 1632 |
if ToolBar: |
1633 |
ToolBar.DeleteTool(item) |
|
1634 |
ToolBar.Realize() |
|
1635 |
if wx.VERSION >= (2, 8, 0): |
|
1636 |
self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize()) |
|
1637 |
self.AUIManager.Update() |
|
6 | 1638 |
|
0 | 1639 |
def RefreshToolBar(self): |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1640 |
selected = self.TabsOpened.GetSelection() |
121 | 1641 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1642 |
language = self.Controler.GetEditedElementBodyType(self.TabsOpened.GetPage(selected).GetTagName()) |
121 | 1643 |
else: |
1644 |
language = None |
|
1645 |
if language is not None and language != self.CurrentLanguage: |
|
27 | 1646 |
self.ResetToolBar() |
1647 |
self.CurrentLanguage = language |
|
1648 |
self.CurrentToolBar = [] |
|
120 | 1649 |
if wx.VERSION < (2, 8, 0): |
1650 |
ToolBar = self.ToolBar |
|
1651 |
else: |
|
1652 |
ToolBar = self.Panes["ToolBar"] |
|
121 | 1653 |
if ToolBar: |
1654 |
for radio, modes, id, method, picture, help in ToolBarItems[language]: |
|
1655 |
if modes & self.DrawingMode: |
|
1656 |
if radio or self.DrawingMode == FREEDRAWING_MODE: |
|
1657 |
ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help) |
|
1658 |
else: |
|
1659 |
ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help) |
|
1660 |
self.Bind(wx.EVT_TOOL, getattr(self, method), id=id) |
|
1661 |
self.CurrentToolBar.append(id) |
|
1662 |
ToolBar.Realize() |
|
1663 |
if wx.VERSION >= (2, 8, 0): |
|
1664 |
self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize()) |
|
1665 |
self.AUIManager.Update() |
|
95 | 1666 |
elif not language: |
1667 |
self.ResetToolBar() |
|
1668 |
self.CurrentLanguage = language |
|
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
1669 |
self.ResetCurrentMode() |
0 | 1670 |
|
163 | 1671 |
|
1672 |
#------------------------------------------------------------------------------- |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
1673 |
# ToolBar Items Functions |
163 | 1674 |
#------------------------------------------------------------------------------- |
1675 |
||
1676 |
def ResetCurrentMode(self): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1677 |
selected = self.TabsOpened.GetSelection() |
0 | 1678 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1679 |
window = self.TabsOpened.GetPage(selected) |
163 | 1680 |
window.SetMode(MODE_SELECTION) |
1681 |
if wx.VERSION < (2, 8, 0): |
|
1682 |
ToolBar = self.ToolBar |
|
1683 |
else: |
|
1684 |
ToolBar = self.Panes["ToolBar"] |
|
1685 |
if ToolBar: |
|
1686 |
ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True) |
|
1687 |
||
1688 |
def ResetToolToggle(self, id): |
|
1689 |
if wx.VERSION < (2, 8, 0): |
|
1690 |
tool = self.ToolBar.FindById(id) |
|
1691 |
else: |
|
1692 |
tool = self.Panes["ToolBar"].FindById(id) |
|
1693 |
tool.SetToggle(False) |
|
1694 |
||
1695 |
def OnSelectionTool(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1696 |
selected = self.TabsOpened.GetSelection() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
1697 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1698 |
self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION) |
163 | 1699 |
event.Skip() |
1700 |
||
1701 |
def OnCommentTool(self, event): |
|
1702 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOMMENT) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1703 |
selected = self.TabsOpened.GetSelection() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
1704 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1705 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
163 | 1706 |
event.Skip() |
1707 |
||
1708 |
def OnVariableTool(self, event): |
|
1709 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARVARIABLE) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1710 |
selected = self.TabsOpened.GetSelection() |
0 | 1711 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1712 |
self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE) |
163 | 1713 |
event.Skip() |
1714 |
||
1715 |
def OnBlockTool(self, event): |
|
1716 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARBLOCK) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1717 |
selected = self.TabsOpened.GetSelection() |
0 | 1718 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1719 |
self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK) |
163 | 1720 |
event.Skip() |
1721 |
||
1722 |
def OnConnectionTool(self, event): |
|
1723 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONNECTION) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1724 |
selected = self.TabsOpened.GetSelection() |
0 | 1725 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1726 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION) |
163 | 1727 |
event.Skip() |
1728 |
||
1729 |
def OnPowerRailTool(self, event): |
|
1730 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARPOWERRAIL) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1731 |
selected = self.TabsOpened.GetSelection() |
163 | 1732 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1733 |
self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL) |
163 | 1734 |
event.Skip() |
1735 |
||
1736 |
def OnRungTool(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1737 |
selected = self.TabsOpened.GetSelection() |
163 | 1738 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1739 |
self.TabsOpened.GetPage(selected).AddLadderRung() |
163 | 1740 |
event.Skip() |
1741 |
||
1742 |
def OnCoilTool(self, event): |
|
1743 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCOIL) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1744 |
selected = self.TabsOpened.GetSelection() |
163 | 1745 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1746 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COIL) |
163 | 1747 |
event.Skip() |
1748 |
||
1749 |
def OnContactTool(self, event): |
|
1750 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
1751 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARCONTACT) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1752 |
selected = self.TabsOpened.GetSelection() |
163 | 1753 |
if selected != -1: |
1754 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1755 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT) |
163 | 1756 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1757 |
self.TabsOpened.GetPage(selected).AddLadderContact() |
163 | 1758 |
event.Skip() |
1759 |
||
1760 |
def OnBranchTool(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1761 |
selected = self.TabsOpened.GetSelection() |
163 | 1762 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1763 |
self.TabsOpened.GetPage(selected).AddLadderBranch() |
163 | 1764 |
event.Skip() |
1765 |
||
1766 |
def OnInitialStepTool(self, event): |
|
1767 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARINITIALSTEP) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1768 |
selected = self.TabsOpened.GetSelection() |
163 | 1769 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1770 |
self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP) |
163 | 1771 |
event.Skip() |
1772 |
||
1773 |
def OnStepTool(self, event): |
|
1774 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
1775 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARSTEP) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1776 |
selected = self.TabsOpened.GetSelection() |
163 | 1777 |
if selected != -1: |
1778 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1779 |
self.TabsOpened.GetPage(selected).SetMode(MODE_STEP) |
163 | 1780 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1781 |
self.TabsOpened.GetPage(selected).AddStep() |
163 | 1782 |
event.Skip() |
1783 |
||
1784 |
def OnActionBlockTool(self, event): |
|
1785 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
1786 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARACTIONBLOCK) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1787 |
selected = self.TabsOpened.GetSelection() |
163 | 1788 |
if selected != -1: |
1789 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1790 |
self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION) |
163 | 1791 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1792 |
self.TabsOpened.GetPage(selected).AddStepAction() |
163 | 1793 |
event.Skip() |
1794 |
||
1795 |
def OnTransitionTool(self, event): |
|
1796 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARTRANSITION) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1797 |
selected = self.TabsOpened.GetSelection() |
163 | 1798 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1799 |
self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION) |
163 | 1800 |
event.Skip() |
1801 |
||
1802 |
def OnDivergenceTool(self, event): |
|
1803 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
1804 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARDIVERGENCE) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1805 |
selected = self.TabsOpened.GetSelection() |
163 | 1806 |
if selected != -1: |
1807 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1808 |
self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE) |
163 | 1809 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1810 |
self.TabsOpened.GetPage(selected).AddDivergence() |
163 | 1811 |
event.Skip() |
1812 |
||
1813 |
def OnJumpTool(self, event): |
|
1814 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
1815 |
self.ResetToolToggle(ID_PLCOPENEDITORTOOLBARJUMP) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1816 |
selected = self.TabsOpened.GetSelection() |
163 | 1817 |
if selected != -1: |
1818 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1819 |
self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP) |
163 | 1820 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1821 |
self.TabsOpened.GetPage(selected).AddJump() |
163 | 1822 |
event.Skip() |
1823 |
||
1824 |
||
1825 |
#------------------------------------------------------------------------------- |
|
1826 |
# Add Project Elements Functions |
|
1827 |
#------------------------------------------------------------------------------- |
|
1828 |
||
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1829 |
def OnAddDataTypeMenu(self, event): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1830 |
dialog = DataTypeDialog(self, "Add a new data type", "Please enter data type name", "", wx.OK|wx.CANCEL) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1831 |
dialog.SetDataTypeNames(self.Controler.GetProjectDataTypeNames()) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1832 |
if dialog.ShowModal() == wx.ID_OK: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1833 |
self.Controler.ProjectAddDataType(dialog.GetValue()) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1834 |
self.RefreshTitle() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1835 |
self.RefreshEditMenu() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1836 |
self.RefreshTypesTree() |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1837 |
dialog.Destroy() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1838 |
event.Skip() |
163 | 1839 |
|
1840 |
def GenerateAddPouFunction(self, pou_type): |
|
1841 |
def OnAddPouMenu(event): |
|
1842 |
dialog = PouDialog(self, pou_type) |
|
1843 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1844 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables()) |
|
1845 |
if dialog.ShowModal() == wx.ID_OK: |
|
1846 |
values = dialog.GetValues() |
|
1847 |
self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"]) |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1848 |
self.RefreshTitle() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
1849 |
self.RefreshEditMenu() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1850 |
self.RefreshTypesTree() |
163 | 1851 |
dialog.Destroy() |
1852 |
event.Skip() |
|
1853 |
return OnAddPouMenu |
|
1854 |
||
1855 |
def GenerateAddTransitionFunction(self, pou_name): |
|
1856 |
def OnAddTransitionMenu(event): |
|
1857 |
dialog = PouTransitionDialog(self) |
|
1858 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1859 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name)) |
|
1860 |
if dialog.ShowModal() == wx.ID_OK: |
|
1861 |
values = dialog.GetValues() |
|
1862 |
self.Controler.ProjectAddPouTransition(pou_name, values["transitionName"], values["language"]) |
|
80 | 1863 |
self.RefreshTitle() |
1864 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1865 |
self.RefreshTypesTree() |
163 | 1866 |
dialog.Destroy() |
1867 |
event.Skip() |
|
1868 |
return OnAddTransitionMenu |
|
1869 |
||
1870 |
def GenerateAddActionFunction(self, pou_name): |
|
1871 |
def OnAddActionMenu(event): |
|
1872 |
dialog = PouActionDialog(self) |
|
1873 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1874 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables(pou_name)) |
|
1875 |
if dialog.ShowModal() == wx.ID_OK: |
|
1876 |
values = dialog.GetValues() |
|
1877 |
self.Controler.ProjectAddPouAction(pou_name, values["actionName"], values["language"]) |
|
1878 |
self.RefreshTitle() |
|
1879 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1880 |
self.RefreshTypesTree() |
163 | 1881 |
dialog.Destroy() |
1882 |
event.Skip() |
|
1883 |
return OnAddActionMenu |
|
0 | 1884 |
|
1885 |
def OnAddConfigurationMenu(self, event): |
|
80 | 1886 |
dialog = ConfigurationNameDialog(self, "Please enter configuration name", "Add new configuration") |
1887 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1888 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables()) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
1889 |
if dialog.ShowModal() == wx.ID_OK: |
0 | 1890 |
value = dialog.GetValue() |
1891 |
self.Controler.ProjectAddConfiguration(value) |
|
80 | 1892 |
self.RefreshTitle() |
1893 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1894 |
self.RefreshTypesTree() |
0 | 1895 |
dialog.Destroy() |
1896 |
event.Skip() |
|
1897 |
||
163 | 1898 |
def GenerateAddResourceFunction(self, config_name): |
177 | 1899 |
def OnAddResourceMenu(event): |
80 | 1900 |
dialog = ResourceNameDialog(self, "Please enter resource name", "Add new resource") |
1901 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1902 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariables()) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
1903 |
if dialog.ShowModal() == wx.ID_OK: |
0 | 1904 |
value = dialog.GetValue() |
1905 |
self.Controler.ProjectAddConfigurationResource(config_name, value) |
|
163 | 1906 |
self.RefreshTitle() |
1907 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1908 |
self.RefreshTypesTree() |
163 | 1909 |
dialog.Destroy() |
1910 |
event.Skip() |
|
1911 |
return OnAddResourceMenu |
|
1912 |
||
1913 |
||
1914 |
#------------------------------------------------------------------------------- |
|
1915 |
# Remove Project Elements Functions |
|
1916 |
#------------------------------------------------------------------------------- |
|
1917 |
||
1918 |
def OnRemoveDataTypeMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1919 |
selected = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1920 |
if self.TypesTree.GetPyData(selected) == ITEM_DATATYPE: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1921 |
name = self.TypesTree.GetItemText(selected) |
163 | 1922 |
if not self.Controler.DataTypeIsUsed(name): |
1923 |
self.Controler.ProjectRemoveDataType(name) |
|
1924 |
tagname = self.Controler.ComputeDataTypeName(name) |
|
121 | 1925 |
idx = self.IsOpened(tagname) |
1926 |
if idx is not None: |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1927 |
self.TabsOpened.DeletePage(idx) |
80 | 1928 |
self.RefreshTitle() |
1929 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1930 |
self.RefreshTypesTree() |
163 | 1931 |
self.RefreshToolBar() |
1932 |
else: |
|
1933 |
message = wx.MessageDialog(self, "%s is used by one or more POUs. It can't be removed!"%selected, "Error", wx.OK|wx.ICON_ERROR) |
|
1934 |
message.ShowModal() |
|
1935 |
message.Destroy() |
|
1936 |
event.Skip() |
|
1937 |
||
1938 |
def OnRemovePouMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1939 |
selected = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1940 |
if self.TypesTree.GetPyData(selected) == ITEM_POU: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1941 |
name = self.TypesTree.GetItemText(selected) |
163 | 1942 |
if not self.Controler.PouIsUsed(name): |
1943 |
self.Controler.ProjectRemovePou(name) |
|
1944 |
tagname = self.Controler.ComputePouName(name) |
|
1945 |
idx = self.IsOpened(tagname) |
|
1946 |
if idx is not None: |
|
1947 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1948 |
self.TabsOpened.DeletePage(idx) |
80 | 1949 |
self.RefreshTitle() |
1950 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1951 |
self.RefreshTypesTree() |
163 | 1952 |
self.RefreshToolBar() |
1953 |
else: |
|
1954 |
message = wx.MessageDialog(self, "%s is used by one or more POUs. It can't be removed!"%selected, "Error", wx.OK|wx.ICON_ERROR) |
|
1955 |
message.ShowModal() |
|
1956 |
message.Destroy() |
|
1957 |
event.Skip() |
|
1958 |
||
1959 |
def OnRemoveConfigurationMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1960 |
selected = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1961 |
if self.TypesTree.GetPyData(selected) == ITEM_CONFIGURATION: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1962 |
name = self.TypesTree.GetItemText(selected) |
163 | 1963 |
self.Controler.ProjectRemoveConfiguration(name) |
1964 |
tagname = self.Controler.ComputeConfigurationName(name) |
|
1965 |
idx = self.IsOpened(tagname) |
|
1966 |
if idx is not None: |
|
1967 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1968 |
self.TabsOpened.DeletePage(idx) |
163 | 1969 |
self.RefreshTitle() |
1970 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1971 |
self.RefreshTypesTree() |
163 | 1972 |
event.Skip() |
1973 |
||
1974 |
def OnRemoveTransitionMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1975 |
selected = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1976 |
if self.TypesTree.GetPyData(selected) == ITEM_TRANSITION: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1977 |
transition = self.TypesTree.GetItemText(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1978 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1979 |
item_type = self.TypesTree.GetPyData(item) |
163 | 1980 |
while item_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1981 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1982 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1983 |
pou_name = self.TypesTree.GetItemText(item) |
163 | 1984 |
self.Controler.ProjectRemovePouTransition(pou_name, transition) |
1985 |
tagname = self.Controler.ComputePouTransitionName(pou_name, transition) |
|
1986 |
idx = self.IsOpened(tagname) |
|
1987 |
if idx is not None: |
|
1988 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1989 |
self.TabsOpened.DeletePage(idx) |
163 | 1990 |
self.RefreshTitle() |
1991 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1992 |
self.RefreshTypesTree() |
163 | 1993 |
event.Skip() |
1994 |
||
1995 |
def OnRemoveActionMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1996 |
selected = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1997 |
if self.TypesTree.GetPyData(selected) == ITEM_ACTION: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1998 |
action = self.TypesTree.GetItemText(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1999 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2000 |
item_type = self.TypesTree.GetPyData(item) |
163 | 2001 |
while item_type != ITEM_POU: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2002 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2003 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2004 |
pou_name = self.TypesTree.GetItemText(item) |
163 | 2005 |
self.Controler.ProjectRemovePouAction(pou_name, action) |
2006 |
tagname = self.Controler.ComputePouActionName(pou_name, action) |
|
2007 |
idx = self.IsOpened(tagname) |
|
2008 |
if idx is not None: |
|
2009 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2010 |
self.TabsOpened.DeletePage(idx) |
163 | 2011 |
self.RefreshTitle() |
2012 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2013 |
self.RefreshTypesTree() |
163 | 2014 |
event.Skip() |
2015 |
||
2016 |
def OnRemoveResourceMenu(self, event): |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2017 |
selected = self.TypesTree.GetSelection() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2018 |
if self.TypesTree.GetPyData(selected) == ITEM_RESOURCE: |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2019 |
resource = self.TypesTree.GetItemText(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2020 |
item = self.TypesTree.GetItemParent(selected) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2021 |
item_type = self.TypesTree.GetPyData(item) |
163 | 2022 |
while item_type != ITEM_CONFIGURATION: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2023 |
item = self.TypesTree.GetItemParent(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2024 |
item_type = self.TypesTree.GetPyData(item) |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2025 |
config_name = self.TypesTree.GetItemText(item) |
163 | 2026 |
self.Controler.ProjectRemoveConfigurationResource(config_name, resource) |
2027 |
tagname = self.Controler.ComputeConfigurationResourceName(config_name, selected) |
|
2028 |
idx = self.IsOpened(tagname) |
|
2029 |
if idx is not None: |
|
2030 |
self.VariablePanelIndexer.RemoveVariablePanel(tagname) |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2031 |
self.TabsOpened.DeletePage(idx) |
163 | 2032 |
self.RefreshTitle() |
2033 |
self.RefreshEditMenu() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2034 |
self.RefreshTypesTree() |
0 | 2035 |
event.Skip() |
190 | 2036 |
|
2037 |
def OnPLCOpenEditorMenu(self, event): |
|
2038 |
wx.MessageBox("No documentation available.\nComing soon.") |
|
223
ea857c3a0427
Bug forbidding copy, cut, paste and F2 on grid cells fixed
lbessard
parents:
221
diff
changeset
|
2039 |
#event.Skip() |
190 | 2040 |
|
0 | 2041 |
def OnPLCOpenMenu(self, event): |
190 | 2042 |
open_pdf(os.path.join(CWD, "plcopen", "TC6_XML_V101.pdf")) |
2043 |
event.Skip() |
|
2044 |
||
2045 |
def OnAboutMenu(self, event): |
|
2046 |
OpenHtmlFrame(self,"About PLCOpenEditor", os.path.join(CWD, "doc","about.html"), wx.Size(350, 350)) |
|
2047 |
event.Skip() |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2048 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2049 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2050 |
#------------------------------------------------------------------------------- |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2051 |
# Errors showing functions |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2052 |
#------------------------------------------------------------------------------- |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2053 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2054 |
def ShowError(self, infos, start, end): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2055 |
self.EditProjectElement(self.Controler.GetElementType(infos[0]), infos[0]) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2056 |
self.SelectTypesTreeItem(infos[0]) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2057 |
if infos[1] == "name": |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2058 |
self.Errors.append(infos[0]) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2059 |
self.RefreshTypesTree() |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2060 |
self.TypesTree.Unselect() |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2061 |
elif infos[1] == "variable": |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2062 |
self.VariablePanelIndexer.AddVariableError(infos) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2063 |
else: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2064 |
selected = self.TabsOpened.GetSelection() |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2065 |
if selected != -1: |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2066 |
viewer = self.TabsOpened.GetPage(selected) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2067 |
viewer.AddShownError(infos[1:], start, end) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2068 |
viewer.RefreshView() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2069 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2070 |
def ClearErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2071 |
self.Errors = [] |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2072 |
self.RefreshTypesTree() |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2073 |
self.VariablePanelIndexer.ClearErrors() |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2074 |
for i in xrange(self.TabsOpened.GetPageCount()): |
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
2075 |
viewer = self.TabsOpened.GetPage(i) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
2076 |
viewer.ClearErrors() |
190 | 2077 |
|
0 | 2078 |
current_num = 0 |
2079 |
def GetNewNum(): |
|
2080 |
global current_num |
|
2081 |
current_num += 1 |
|
2082 |
return current_num |
|
2083 |
||
2084 |
#------------------------------------------------------------------------------- |
|
2085 |
# Create Project Dialog |
|
2086 |
#------------------------------------------------------------------------------- |
|
2087 |
||
145 | 2088 |
[ID_SCALINGPANEL, ID_SCALINGPANELXSCALE, |
2089 |
ID_SCALINGPANELYSCALE, ID_SCALINGPANELSTATICTEXT1, |
|
2090 |
ID_SCALINGPANELSTATICTEXT2, |
|
2091 |
] = [wx.NewId() for _init_ctrls in range(5)] |
|
2092 |
||
2093 |
class ScalingPanel(wx.Panel): |
|
2094 |
||
2095 |
def _init_coll_ScalingPanelSizer_Items(self, parent): |
|
2096 |
parent.AddWindow(self.staticText1, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT) |
|
2097 |
parent.AddWindow(self.XScale, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT) |
|
2098 |
parent.AddWindow(self.staticText2, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT) |
|
2099 |
parent.AddWindow(self.YScale, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT) |
|
2100 |
||
2101 |
def _init_coll_ScalingPanelSizer_Growables(self, parent): |
|
2102 |
parent.AddGrowableCol(1) |
|
2103 |
||
2104 |
def _init_sizers(self): |
|
2105 |
self.ScalingPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=5) |
|
2106 |
||
2107 |
self._init_coll_ScalingPanelSizer_Items(self.ScalingPanelSizer) |
|
2108 |
self._init_coll_ScalingPanelSizer_Growables(self.ScalingPanelSizer) |
|
2109 |
||
2110 |
self.SetSizer(self.ScalingPanelSizer) |
|
2111 |
||
2112 |
def _init_ctrls(self, prnt): |
|
2113 |
wx.Panel.__init__(self, id=ID_SCALINGPANEL, |
|
2114 |
name='ScalingPanel', parent=prnt, pos=wx.Point(0, 0), |
|
163 | 2115 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
145 | 2116 |
|
2117 |
self.staticText1 = wx.StaticText(id=ID_SCALINGPANELSTATICTEXT1, |
|
2118 |
label='X Scale:', name='staticText1', parent=self, |
|
2119 |
pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
|
2120 |
||
2121 |
self.XScale = wx.SpinCtrl(id=ID_SCALINGPANELXSCALE, |
|
2122 |
name='XScale', parent=self, pos=wx.Point(0, 0), |
|
2123 |
size=wx.Size(0, 24), style=0, min=0, max=2**16) |
|
2124 |
||
2125 |
self.staticText2 = wx.StaticText(id=ID_SCALINGPANELSTATICTEXT2, |
|
2126 |
label='Y Scale:', name='staticText2', parent=self, |
|
2127 |
pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
|
2128 |
||
2129 |
self.YScale = wx.SpinCtrl(id=ID_SCALINGPANELYSCALE, |
|
2130 |
name='YScale', parent=self, pos=wx.Point(0, 0), |
|
2131 |
size=wx.Size(0, 24), style=0, min=0, max=2**16) |
|
2132 |
||
2133 |
self._init_sizers() |
|
2134 |
||
2135 |
def __init__(self, parent): |
|
2136 |
self._init_ctrls(parent) |
|
2137 |
||
2138 |
def SetScaling(self, x, y): |
|
2139 |
self.XScale.SetValue(x) |
|
2140 |
self.YScale.SetValue(y) |
|
2141 |
||
2142 |
def GetScaling(self): |
|
2143 |
return self.XScale.GetValue(), self.YScale.GetValue() |
|
2144 |
||
2145 |
[ID_PROJECTDIALOG, ID_PROJECTDIALOGMAINNOTEBOOK, |
|
2146 |
ID_PROJECTDIALOGPROJECTPANEL, ID_PROJECTDIALOGAUTHORPANEL, |
|
2147 |
ID_PROJECTDIALOGGRAPHICSPANEL, ID_PROJECTDIALOGMISCELLANEOUSPANEL, |
|
2148 |
ID_PROJECTDIALOGPROJECTNAME, ID_PROJECTDIALOGPROJECTVERSION, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2149 |
ID_PROJECTDIALOGPRODUCTNAME, ID_PROJECTDIALOGPRODUCTVERSION, |
145 | 2150 |
ID_PROJECTDIALOGPRODUCTRELEASE, ID_PROJECTDIALOGCOMPANYNAME, |
2151 |
ID_PROJECTDIALOGCOMPANYURL, ID_PROJECTDIALOGAUTHORNAME, |
|
2152 |
ID_PROJECTDIALOGORGANIZATION, ID_PROJECTDIALOGLANGUAGE, |
|
2153 |
ID_PROJECTDIALOGCONTENTDESCRIPTION, ID_PROJECTDIALOGSCALINGNOTEBOOK, |
|
2154 |
ID_PROJECTDIALOGPAGEWIDTH, ID_PROJECTDIALOGPAGEHEIGHT, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2155 |
ID_PROJECTDIALOGSTATICTEXT1, ID_PROJECTDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2156 |
ID_PROJECTDIALOGSTATICTEXT3, ID_PROJECTDIALOGSTATICTEXT4, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2157 |
ID_PROJECTDIALOGSTATICTEXT5, ID_PROJECTDIALOGSTATICTEXT6, |
145 | 2158 |
ID_PROJECTDIALOGSTATICTEXT7, ID_PROJECTDIALOGSTATICTEXT8, |
2159 |
ID_PROJECTDIALOGSTATICTEXT9, ID_PROJECTDIALOGSTATICTEXT10, |
|
2160 |
ID_PROJECTDIALOGSTATICTEXT11, ID_PROJECTDIALOGSTATICTEXT12, |
|
2161 |
ID_PROJECTDIALOGSTATICTEXT13, ID_PROJECTDIALOGSTATICTEXT14, |
|
2162 |
ID_PROJECTDIALOGSTATICTEXT15, |
|
2163 |
] = [wx.NewId() for _init_ctrls in range(35)] |
|
2164 |
||
0 | 2165 |
class ProjectDialog(wx.Dialog): |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2166 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2167 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2168 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2169 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2170 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2171 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2172 |
|
0 | 2173 |
def _init_coll_flexGridSizer1_Items(self, parent): |
145 | 2174 |
parent.AddSizer(self.MainNotebook, 0, border=0, flag=wx.GROW) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2175 |
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:
58
diff
changeset
|
2176 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2177 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2178 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2179 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2180 |
|
145 | 2181 |
def _init_coll_ProjectPanelSizer_Items(self, parent): |
2182 |
parent.AddWindow(self.staticText1, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT) |
|
2183 |
parent.AddWindow(self.ProjectName, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT) |
|
2184 |
parent.AddWindow(self.staticText2, 0, border=10, flag=wx.GROW|wx.LEFT) |
|
2185 |
parent.AddWindow(self.ProjectVersion, 0, border=10, flag=wx.GROW|wx.RIGHT) |
|
2186 |
parent.AddWindow(self.staticText3, 0, border=10, flag=wx.GROW|wx.LEFT) |
|
2187 |
parent.AddWindow(self.ProductName, 0, border=10, flag=wx.GROW|wx.RIGHT) |
|
2188 |
parent.AddWindow(self.staticText4, 0, border=10, flag=wx.GROW|wx.LEFT) |
|
2189 |
parent.AddWindow(self.ProductVersion, 0, border=10, flag=wx.GROW|wx.RIGHT) |
|
2190 |
parent.AddWindow(self.staticText5, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT) |
|
2191 |
parent.AddWindow(self.ProductRelease, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT) |
|
2192 |
||
2193 |
def _init_coll_ProjectPanelSizer_Growables(self, parent): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2194 |
parent.AddGrowableCol(1) |
145 | 2195 |
|
2196 |
def _init_coll_AuthorPanelSizer_Items(self, parent): |
|
2197 |
parent.AddWindow(self.staticText6, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT) |
|
2198 |
parent.AddWindow(self.CompanyName, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT) |
|
2199 |
parent.AddWindow(self.staticText7, 0, border=10, flag=wx.GROW|wx.LEFT) |
|
2200 |
parent.AddWindow(self.CompanyURL, 0, border=10, flag=wx.GROW|wx.RIGHT) |
|
2201 |
parent.AddWindow(self.staticText8, 0, border=10, flag=wx.GROW|wx.LEFT) |
|
2202 |
parent.AddWindow(self.AuthorName, 0, border=10, flag=wx.GROW|wx.RIGHT) |
|
2203 |
parent.AddWindow(self.staticText9, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT) |
|
2204 |
parent.AddWindow(self.Organization, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT) |
|
2205 |
||
2206 |
def _init_coll_AuthorPanelSizer_Growables(self, parent): |
|
2207 |
parent.AddGrowableCol(1) |
|
2208 |
||
2209 |
def _init_coll_GraphicsPanelSizer_Items(self, parent): |
|
2210 |
parent.AddWindow(self.staticText12, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
2211 |
parent.AddSizer(self.GraphicsPageSizeSizer, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT) |
|
2212 |
parent.AddWindow(self.staticText15, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT) |
|
2213 |
parent.AddWindow(self.ScalingNotebook, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
2214 |
||
2215 |
def _init_coll_GraphicsPanelSizer_Growables(self, parent): |
|
2216 |
parent.AddGrowableCol(0) |
|
2217 |
parent.AddGrowableRow(3) |
|
2218 |
||
2219 |
def _init_coll_GraphicsPageSizeSizer_Items(self, parent): |
|
2220 |
parent.AddWindow(self.staticText13, 0, border=12, flag=wx.GROW|wx.LEFT) |
|
2221 |
parent.AddWindow(self.PageWidth, 0, border=0, flag=wx.GROW) |
|
2222 |
parent.AddWindow(self.staticText14, 0, border=12, flag=wx.GROW|wx.LEFT) |
|
2223 |
parent.AddWindow(self.PageHeight, 0, border=0, flag=wx.GROW) |
|
2224 |
||
2225 |
def _init_coll_GraphicsPageSizeSizer_Growables(self, parent): |
|
2226 |
parent.AddGrowableCol(1) |
|
2227 |
||
2228 |
def _init_coll_MiscellaneousPanelSizer_Items(self, parent): |
|
2229 |
parent.AddWindow(self.staticText10, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT) |
|
2230 |
parent.AddWindow(self.Language, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT) |
|
2231 |
parent.AddWindow(self.staticText11, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT) |
|
2232 |
parent.AddWindow(self.ContentDescription, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT) |
|
2233 |
||
2234 |
def _init_coll_MiscellaneousPanelSizer_Growables(self, parent): |
|
2235 |
parent.AddGrowableCol(1) |
|
2236 |
parent.AddGrowableRow(1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2237 |
|
0 | 2238 |
def _init_sizers(self): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2239 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
145 | 2240 |
self.ProjectPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=5, vgap=15) |
2241 |
self.AuthorPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=15) |
|
2242 |
self.GraphicsPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=5) |
|
2243 |
self.GraphicsPageSizeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=5) |
|
2244 |
self.MiscellaneousPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=15) |
|
0 | 2245 |
|
2246 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2247 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
145 | 2248 |
self._init_coll_ProjectPanelSizer_Items(self.ProjectPanelSizer) |
2249 |
self._init_coll_ProjectPanelSizer_Growables(self.ProjectPanelSizer) |
|
2250 |
self._init_coll_AuthorPanelSizer_Items(self.AuthorPanelSizer) |
|
2251 |
self._init_coll_AuthorPanelSizer_Growables(self.AuthorPanelSizer) |
|
2252 |
self._init_coll_GraphicsPanelSizer_Items(self.GraphicsPanelSizer) |
|
2253 |
self._init_coll_GraphicsPanelSizer_Growables(self.GraphicsPanelSizer) |
|
2254 |
self._init_coll_GraphicsPageSizeSizer_Items(self.GraphicsPageSizeSizer) |
|
2255 |
self._init_coll_GraphicsPageSizeSizer_Growables(self.GraphicsPageSizeSizer) |
|
2256 |
self._init_coll_MiscellaneousPanelSizer_Items(self.MiscellaneousPanelSizer) |
|
2257 |
self._init_coll_MiscellaneousPanelSizer_Growables(self.MiscellaneousPanelSizer) |
|
0 | 2258 |
|
2259 |
self.SetSizer(self.flexGridSizer1) |
|
145 | 2260 |
self.ProjectPanel.SetSizer(self.ProjectPanelSizer) |
2261 |
self.AuthorPanel.SetSizer(self.AuthorPanelSizer) |
|
2262 |
self.GraphicsPanel.SetSizer(self.GraphicsPanelSizer) |
|
2263 |
self.MiscellaneousPanel.SetSizer(self.MiscellaneousPanelSizer) |
|
0 | 2264 |
|
2265 |
def _init_ctrls(self, prnt): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2266 |
wx.Dialog.__init__(self, id=ID_PROJECTDIALOG, |
0 | 2267 |
name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223), |
145 | 2268 |
size=wx.Size(500, 350), style=wx.DEFAULT_DIALOG_STYLE, |
0 | 2269 |
title='Create a new project') |
145 | 2270 |
self.SetClientSize(wx.Size(500, 350)) |
2271 |
||
2272 |
self.MainNotebook = wx.Notebook(id=ID_PROJECTDIALOGMAINNOTEBOOK, |
|
2273 |
name='MainNotebook', parent=self, pos=wx.Point(0, |
|
2274 |
0), size=wx.Size(0, 0), style=0) |
|
2275 |
||
2276 |
# Project Panel elements |
|
2277 |
||
2278 |
self.ProjectPanel = wx.Panel(id=ID_PROJECTDIALOGPROJECTPANEL, |
|
2279 |
name='ProjectPanel', parent=self.MainNotebook, pos=wx.Point(0, 0), |
|
2280 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
0 | 2281 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2282 |
self.staticText1 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT1, |
145 | 2283 |
label='Project Name (required):', name='staticText1', parent=self.ProjectPanel, |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2284 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2285 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2286 |
self.ProjectName = wx.TextCtrl(id=ID_PROJECTDIALOGPROJECTNAME, |
145 | 2287 |
name='ProjectName', parent=self.ProjectPanel, pos=wx.Point(0, 0), |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2288 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2289 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2290 |
self.staticText2 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT2, |
145 | 2291 |
label='Project Version (optional):', name='staticText2', parent=self.ProjectPanel, |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2292 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2293 |
|
145 | 2294 |
self.ProjectVersion = wx.TextCtrl(id=ID_PROJECTDIALOGPROJECTVERSION, |
2295 |
name='ProjectVersion', parent=self.ProjectPanel, pos=wx.Point(0, 0), |
|
2296 |
size=wx.Size(0, 24), style=0) |
|
2297 |
||
2298 |
self.staticText3 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT3, |
|
2299 |
label='Product Name (required):', name='staticText3', parent=self.ProjectPanel, |
|
2300 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
|
2301 |
||
2302 |
self.ProductName = wx.TextCtrl(id=ID_PROJECTDIALOGPRODUCTNAME, |
|
2303 |
name='ProductName', parent=self.ProjectPanel, pos=wx.Point(0, 0), |
|
2304 |
size=wx.Size(0, 24), style=0) |
|
2305 |
||
2306 |
self.staticText4 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT4, |
|
2307 |
label='Product Version (required):', name='staticText4', parent=self.ProjectPanel, |
|
2308 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
|
2309 |
||
2310 |
self.ProductVersion = wx.TextCtrl(id=ID_PROJECTDIALOGPRODUCTVERSION, |
|
2311 |
name='ProductVersion', parent=self.ProjectPanel, pos=wx.Point(0, 0), |
|
2312 |
size=wx.Size(0, 24), style=0) |
|
2313 |
||
2314 |
self.staticText5 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT5, |
|
2315 |
label='Product Release (optional):', name='staticText5', parent=self.ProjectPanel, |
|
2316 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
|
2317 |
||
2318 |
self.ProductRelease = wx.TextCtrl(id=ID_PROJECTDIALOGPRODUCTRELEASE, |
|
2319 |
name='ProductRelease', parent=self.ProjectPanel, pos=wx.Point(0, 0), |
|
2320 |
size=wx.Size(0, 24), style=0) |
|
2321 |
||
2322 |
self.MainNotebook.AddPage(self.ProjectPanel, "Project") |
|
2323 |
||
2324 |
# Author Panel elements |
|
2325 |
||
2326 |
self.AuthorPanel = wx.Panel(id=ID_PROJECTDIALOGAUTHORPANEL, |
|
2327 |
name='AuthorPanel', parent=self.MainNotebook, pos=wx.Point(0, 0), |
|
2328 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
2329 |
||
2330 |
self.staticText6 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT6, |
|
2331 |
label='Company Name (required):', name='staticText6', parent=self.AuthorPanel, |
|
2332 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
|
2333 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2334 |
self.CompanyName = wx.TextCtrl(id=ID_PROJECTDIALOGCOMPANYNAME, |
145 | 2335 |
name='CompanyName', parent=self.AuthorPanel, pos=wx.Point(0, 0), |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2336 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2337 |
|
145 | 2338 |
self.staticText7 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT7, |
2339 |
label='Company URL (optional):', name='staticText7', parent=self.AuthorPanel, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2340 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2341 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2342 |
self.CompanyURL = wx.TextCtrl(id=ID_PROJECTDIALOGCOMPANYURL, |
145 | 2343 |
name='CompanyURL', parent=self.AuthorPanel, pos=wx.Point(0, 0), |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2344 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2345 |
|
145 | 2346 |
self.staticText8 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT8, |
2347 |
label='Author Name (optional):', name='staticText8', parent=self.AuthorPanel, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2348 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2349 |
|
145 | 2350 |
self.AuthorName = wx.TextCtrl(id=ID_PROJECTDIALOGAUTHORNAME, |
2351 |
name='AuthorName', parent=self.AuthorPanel, pos=wx.Point(0, 0), |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2352 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2353 |
|
145 | 2354 |
self.staticText9 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT9, |
2355 |
label='Organization (optional):', name='staticText9', parent=self.AuthorPanel, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2356 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2357 |
|
145 | 2358 |
self.Organization = wx.TextCtrl(id=ID_PROJECTDIALOGORGANIZATION, |
2359 |
name='Organization', parent=self.AuthorPanel, pos=wx.Point(0, 0), |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2360 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2361 |
|
145 | 2362 |
self.MainNotebook.AddPage(self.AuthorPanel, "Author") |
2363 |
||
2364 |
# Graphics Panel elements |
|
2365 |
||
2366 |
self.GraphicsPanel = wx.Panel(id=ID_PROJECTDIALOGGRAPHICSPANEL, |
|
2367 |
name='GraphicsPanel', parent=self.MainNotebook, pos=wx.Point(0, 0), |
|
2368 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
2369 |
||
2370 |
self.staticText12 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT12, |
|
2371 |
label='Page Size (optional):', name='staticText12', parent=self.GraphicsPanel, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2372 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2373 |
|
145 | 2374 |
self.staticText13 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT13, |
2375 |
label='Width:', name='staticText13', parent=self.GraphicsPanel, |
|
2376 |
pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
|
2377 |
||
2378 |
self.PageWidth = wx.SpinCtrl(id=ID_PROJECTDIALOGPAGEWIDTH, |
|
2379 |
name='PageWidth', parent=self.GraphicsPanel, pos=wx.Point(0, 0), |
|
2380 |
size=wx.Size(0, 24), style=0, min=0, max=2**16) |
|
2381 |
||
2382 |
self.staticText14 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT14, |
|
2383 |
label='Height:', name='staticText14', parent=self.GraphicsPanel, |
|
2384 |
pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0) |
|
2385 |
||
2386 |
self.PageHeight = wx.SpinCtrl(id=ID_PROJECTDIALOGPAGEHEIGHT, |
|
2387 |
name='PageHeight', parent=self.GraphicsPanel, pos=wx.Point(0, 0), |
|
2388 |
size=wx.Size(0, 24), style=0, min=0, max=2**16) |
|
2389 |
||
2390 |
self.staticText15 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT15, |
|
2391 |
label='Scaling:', name='staticText15', parent=self.GraphicsPanel, |
|
2392 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
|
2393 |
||
2394 |
self.ScalingNotebook = wx.Notebook(id=ID_PROJECTDIALOGSCALINGNOTEBOOK, |
|
2395 |
name='ScalingNotebook', parent=self.GraphicsPanel, pos=wx.Point(0, |
|
2396 |
0), size=wx.Size(0, 0), style=0) |
|
2397 |
||
2398 |
self.Scalings = {} |
|
2399 |
for language in ["FBD", "LD", "SFC"]: |
|
2400 |
window = ScalingPanel(self.ScalingNotebook) |
|
2401 |
self.Scalings[language] = window |
|
2402 |
self.ScalingNotebook.AddPage(window, language) |
|
2403 |
||
2404 |
self.MainNotebook.AddPage(self.GraphicsPanel, "Graphics") |
|
2405 |
||
2406 |
# Miscellaneous Panel elements |
|
2407 |
||
2408 |
self.MiscellaneousPanel = wx.Panel(id=ID_PROJECTDIALOGMISCELLANEOUSPANEL, |
|
2409 |
name='MiscellaneousPanel', parent=self.MainNotebook, pos=wx.Point(0, 0), |
|
2410 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
2411 |
||
2412 |
self.staticText10 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT10, |
|
2413 |
label='Language (optional):', name='staticText10', parent=self.MiscellaneousPanel, |
|
2414 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
|
2415 |
||
2416 |
self.Language = wx.Choice(id=ID_PROJECTDIALOGLANGUAGE, |
|
2417 |
name='Language', parent=self.MiscellaneousPanel, pos=wx.Point(0, 0), |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2418 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2419 |
|
145 | 2420 |
self.staticText11 = wx.StaticText(id=ID_PROJECTDIALOGSTATICTEXT11, |
2421 |
label='Content Description (optional):', name='staticText11', parent=self.MiscellaneousPanel, |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2422 |
pos=wx.Point(0, 0), size=wx.Size(200, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2423 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2424 |
self.ContentDescription = wx.TextCtrl(id=ID_PROJECTDIALOGCONTENTDESCRIPTION, |
145 | 2425 |
name='ContentDescription', parent=self.MiscellaneousPanel, pos=wx.Point(0, 0), |
2426 |
size=wx.Size(0, 24), style=wx.TE_MULTILINE) |
|
2427 |
||
2428 |
self.MainNotebook.AddPage(self.MiscellaneousPanel, "Miscellaneous") |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2429 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2430 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2431 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2432 |
|
0 | 2433 |
self._init_sizers() |
2434 |
||
2435 |
def __init__(self, parent): |
|
2436 |
self._init_ctrls(parent) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2437 |
|
145 | 2438 |
languages = ["", "en-US", "fr-FR"] |
2439 |
||
2440 |
for language in languages: |
|
2441 |
self.Language.Append(language) |
|
2442 |
||
0 | 2443 |
def OnOK(self, event): |
2444 |
error = [] |
|
2445 |
if self.ProjectName.GetValue() == "": |
|
2446 |
error.append("Project Name") |
|
2447 |
if self.CompanyName.GetValue() == "": |
|
2448 |
error.append("Company Name") |
|
2449 |
if self.ProductName.GetValue() == "": |
|
2450 |
error.append("Product Name") |
|
2451 |
if self.ProductVersion.GetValue() == "": |
|
2452 |
error.append("Product Version") |
|
2453 |
if len(error) > 0: |
|
2454 |
text = "" |
|
2455 |
for i, item in enumerate(error): |
|
2456 |
if i == 0: |
|
2457 |
text += item |
|
2458 |
elif i == len(error) - 1: |
|
2459 |
text += " and %s"%item |
|
2460 |
else: |
|
145 | 2461 |
text += ", %s"%item |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2462 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2463 |
message.ShowModal() |
2464 |
message.Destroy() |
|
2465 |
else: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2466 |
self.EndModal(wx.ID_OK) |
0 | 2467 |
|
2468 |
def SetValues(self, values): |
|
2469 |
for item, value in values.items(): |
|
2470 |
if item == "projectName": |
|
2471 |
self.ProjectName.SetValue(value) |
|
145 | 2472 |
elif item == "projectVersion": |
2473 |
self.ProjectVersion.SetValue(value) |
|
0 | 2474 |
elif item == "productName": |
2475 |
self.ProductName.SetValue(value) |
|
2476 |
elif item == "productVersion": |
|
2477 |
self.ProductVersion.SetValue(value) |
|
2478 |
elif item == "productRelease": |
|
2479 |
self.ProductRelease.SetValue(value) |
|
145 | 2480 |
elif item == "companyName": |
2481 |
self.CompanyName.SetValue(value) |
|
2482 |
elif item == "companyURL": |
|
2483 |
self.CompanyURL.SetValue(value) |
|
2484 |
elif item == "authorName": |
|
2485 |
self.AuthorName.SetValue(value) |
|
2486 |
elif item == "organization": |
|
2487 |
self.Organization.SetValue(value) |
|
2488 |
elif item == "language": |
|
2489 |
self.Language.SetStringSelection(value) |
|
0 | 2490 |
elif item == "contentDescription": |
2491 |
self.ContentDescription.SetValue(value) |
|
145 | 2492 |
elif item == "pageSize": |
2493 |
self.PageWidth.SetValue(value[0]) |
|
2494 |
self.PageHeight.SetValue(value[1]) |
|
2495 |
elif item == "scaling": |
|
2496 |
for language, (x, y) in value.items(): |
|
2497 |
if language in self.Scalings: |
|
2498 |
self.Scalings[language].SetScaling(x, y) |
|
2499 |
||
0 | 2500 |
def GetValues(self): |
2501 |
values = {} |
|
2502 |
values["projectName"] = self.ProjectName.GetValue() |
|
145 | 2503 |
if self.ProjectVersion.GetValue() != "": |
2504 |
values["projectVersion"] = self.ProjectVersion.GetValue() |
|
0 | 2505 |
values["productName"] = self.ProductName.GetValue() |
2506 |
values["productVersion"] = self.ProductVersion.GetValue() |
|
145 | 2507 |
if self.ProductRelease.GetValue() != "": |
0 | 2508 |
values["productRelease"] = self.ProductRelease.GetValue() |
145 | 2509 |
values["companyName"] = self.CompanyName.GetValue() |
2510 |
if self.CompanyURL.GetValue() != "": |
|
2511 |
values["companyURL"] = self.CompanyURL.GetValue() |
|
2512 |
if self.AuthorName.GetValue() != "": |
|
2513 |
values["authorName"] = self.AuthorName.GetValue() |
|
2514 |
if self.Organization.GetValue() != "": |
|
2515 |
values["organization"] = self.Organization.GetValue() |
|
2516 |
if self.Language.GetStringSelection() != "": |
|
2517 |
values["language"] = self.Language.GetStringSelection() |
|
2518 |
if self.ProductRelease.GetValue() != "": |
|
0 | 2519 |
values["contentDescription"] = self.ContentDescription.GetValue() |
145 | 2520 |
values["pageSize"] = (self.PageWidth.GetValue(), self.PageHeight.GetValue()) |
2521 |
values["scaling"] = {} |
|
2522 |
for language in ["FBD", "LD", "SFC"]: |
|
2523 |
values["scaling"][language] = self.Scalings[language].GetScaling() |
|
0 | 2524 |
return values |
2525 |
||
2526 |
#------------------------------------------------------------------------------- |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2527 |
# Edit Step Name Dialog |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2528 |
#------------------------------------------------------------------------------- |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2529 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2530 |
class DataTypeDialog(wx.TextEntryDialog): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2531 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2532 |
if wx.VERSION < (2, 6, 0): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2533 |
def Bind(self, event, function, id = None): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2534 |
if id is not None: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2535 |
event(self, id, function) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2536 |
else: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2537 |
event(self, function) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2538 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2539 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2540 |
def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2541 |
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2542 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2543 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2544 |
self.DataTypeNames = [] |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2545 |
if wx.VERSION >= (2, 8, 0): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2546 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2547 |
elif wx.VERSION >= (2, 6, 0): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2548 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2549 |
else: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2550 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2551 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2552 |
def OnOK(self, event): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2553 |
datatype_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2554 |
if datatype_name == "": |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2555 |
message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2556 |
message.ShowModal() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2557 |
message.Destroy() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2558 |
elif not TestIdentifier(datatype_name): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2559 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%datatype_name, "Error", wx.OK|wx.ICON_ERROR) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2560 |
message.ShowModal() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2561 |
message.Destroy() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2562 |
elif datatype_name.upper() in IEC_KEYWORDS: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2563 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%datatype_name, "Error", wx.OK|wx.ICON_ERROR) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2564 |
message.ShowModal() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2565 |
message.Destroy() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2566 |
elif datatype_name.upper() in self.DataTypeNames: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2567 |
message = wx.MessageDialog(self, "\"%s\" data type already exists!"%datatype_name, "Error", wx.OK|wx.ICON_ERROR) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2568 |
message.ShowModal() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2569 |
message.Destroy() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2570 |
else: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2571 |
self.EndModal(wx.ID_OK) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2572 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2573 |
def SetDataTypeNames(self, datatype_names): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2574 |
self.DataTypeNames = [datatype_name.upper() for datatype_name in datatype_names] |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2575 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2576 |
def GetValue(self): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2577 |
return self.GetSizer().GetItem(1).GetWindow().GetValue() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2578 |
|
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
2579 |
#------------------------------------------------------------------------------- |
0 | 2580 |
# Create Pou Dialog |
2581 |
#------------------------------------------------------------------------------- |
|
2582 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2583 |
[ID_POUDIALOG, ID_POUDIALOGPOUNAME, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2584 |
ID_POUDIALOGPOUTYPE, ID_POUDIALOGLANGUAGE, ID_POUDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2585 |
ID_POUDIALOGSTATICTEXT2, ID_POUDIALOGSTATICTEXT3, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2586 |
] = [wx.NewId() for _init_ctrls in range(7)] |
0 | 2587 |
|
2588 |
class PouDialog(wx.Dialog): |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2589 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2590 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2591 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2592 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2593 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2594 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2595 |
|
0 | 2596 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2597 |
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:
58
diff
changeset
|
2598 |
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:
58
diff
changeset
|
2599 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2600 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2601 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2602 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2603 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2604 |
def _init_coll_MainSizer_Items(self, parent): |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2605 |
parent.AddWindow(self.staticText1, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2606 |
parent.AddWindow(self.PouName, 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:
114
diff
changeset
|
2607 |
parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2608 |
parent.AddWindow(self.PouType, 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:
114
diff
changeset
|
2609 |
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:
58
diff
changeset
|
2610 |
parent.AddWindow(self.Language, 0, border=0, flag=wx.GROW) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2611 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2612 |
def _init_coll_MainSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2613 |
parent.AddGrowableCol(1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2614 |
|
0 | 2615 |
def _init_sizers(self): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2616 |
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:
58
diff
changeset
|
2617 |
self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=3, vgap=15) |
0 | 2618 |
|
2619 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2620 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2621 |
self._init_coll_MainSizer_Items(self.MainSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2622 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
0 | 2623 |
|
2624 |
self.SetSizer(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2625 |
|
0 | 2626 |
def _init_ctrls(self, prnt): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2627 |
wx.Dialog.__init__(self, id=ID_POUDIALOG, |
16 | 2628 |
name='PouDialog', parent=prnt, pos=wx.Point(376, 223), |
0 | 2629 |
size=wx.Size(300, 200), style=wx.DEFAULT_DIALOG_STYLE, |
16 | 2630 |
title='Create a new POU') |
0 | 2631 |
self.SetClientSize(wx.Size(300, 200)) |
2632 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2633 |
self.staticText1 = wx.StaticText(id=ID_POUDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2634 |
label='POU Name:', name='staticText1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2635 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2636 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2637 |
self.PouName = wx.TextCtrl(id=ID_POUDIALOGPOUNAME, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2638 |
name='POUName', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2639 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2640 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2641 |
self.staticText2 = wx.StaticText(id=ID_POUDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2642 |
label='POU Type:', name='staticText2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2643 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2644 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2645 |
self.PouType = wx.Choice(id=ID_POUDIALOGPOUTYPE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2646 |
name='POUType', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2647 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2648 |
self.Bind(wx.EVT_CHOICE, self.OnTypeChanged, id=ID_POUDIALOGPOUTYPE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2649 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2650 |
self.staticText3 = wx.StaticText(id=ID_POUDIALOGSTATICTEXT3, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2651 |
label='Language:', name='staticText3', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2652 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2653 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2654 |
self.Language = wx.Choice(id=ID_POUDIALOGLANGUAGE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2655 |
name='Language', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2656 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2657 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2658 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2659 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2660 |
|
0 | 2661 |
self._init_sizers() |
2662 |
||
163 | 2663 |
def __init__(self, parent, pou_type = None): |
0 | 2664 |
self._init_ctrls(parent) |
2665 |
||
163 | 2666 |
for option in ["function", "functionBlock", "program"]: |
0 | 2667 |
self.PouType.Append(option) |
163 | 2668 |
if pou_type is not None: |
2669 |
self.PouType.SetStringSelection(pou_type) |
|
0 | 2670 |
self.RefreshLanguage() |
2671 |
||
6 | 2672 |
self.PouNames = [] |
70 | 2673 |
self.PouElementNames = [] |
6 | 2674 |
|
0 | 2675 |
def OnOK(self, event): |
2676 |
error = [] |
|
2677 |
pou_name = self.PouName.GetValue() |
|
2678 |
if pou_name == "": |
|
2679 |
error.append("POU Name") |
|
2680 |
if self.PouType.GetStringSelection() == "": |
|
2681 |
error.append("POU Type") |
|
2682 |
if self.Language.GetStringSelection() == "": |
|
2683 |
error.append("Language") |
|
2684 |
if len(error) > 0: |
|
2685 |
text = "" |
|
2686 |
for i, item in enumerate(error): |
|
2687 |
if i == 0: |
|
2688 |
text += item |
|
2689 |
elif i == len(error) - 1: |
|
2690 |
text += " and %s"%item |
|
2691 |
else: |
|
2692 |
text += ", %s"%item |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2693 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2694 |
message.ShowModal() |
2695 |
message.Destroy() |
|
2696 |
elif not TestIdentifier(pou_name): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2697 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%pou_name, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2698 |
message.ShowModal() |
2699 |
message.Destroy() |
|
2700 |
elif pou_name.upper() in IEC_KEYWORDS: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2701 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%pou_name, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2702 |
message.ShowModal() |
2703 |
message.Destroy() |
|
2704 |
elif pou_name.upper() in self.PouNames: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2705 |
message = wx.MessageDialog(self, "\"%s\" pou already exists!"%pou_name, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2706 |
message.ShowModal() |
2707 |
message.Destroy() |
|
70 | 2708 |
elif pou_name.upper() in self.PouElementNames: |
2709 |
message = wx.MessageDialog(self, "A pou has an element with \"%s\" for name. It can generate a conflict. Do you wish to continue?"%pou_name, "Warning", wx.YES_NO|wx.ICON_EXCLAMATION) |
|
2710 |
result = message.ShowModal() |
|
2711 |
message.Destroy() |
|
2712 |
if result == wx.ID_YES: |
|
2713 |
self.EndModal(wx.ID_OK) |
|
0 | 2714 |
else: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2715 |
self.EndModal(wx.ID_OK) |
0 | 2716 |
|
2717 |
def RefreshLanguage(self): |
|
2718 |
selection = self.Language.GetStringSelection() |
|
2719 |
self.Language.Clear() |
|
2720 |
for option in ["IL","ST","LD","FBD","SFC"]: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2721 |
if option != "SFC" or self.PouType.GetStringSelection() != "function": |
0 | 2722 |
self.Language.Append(option) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2723 |
if self.Language.FindString(selection) != wx.NOT_FOUND: |
0 | 2724 |
self.Language.SetStringSelection(selection) |
2725 |
||
2726 |
def OnTypeChanged(self, event): |
|
2727 |
self.RefreshLanguage() |
|
2728 |
event.Skip() |
|
2729 |
||
2730 |
def SetPouNames(self, pou_names): |
|
2731 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
2732 |
||
70 | 2733 |
def SetPouElementNames(self, element_names): |
2734 |
self.PouElementNames = [element_name.upper() for element_name in element_names] |
|
2735 |
||
0 | 2736 |
def SetValues(self, values): |
2737 |
for item, value in values.items(): |
|
2738 |
if item == "pouName": |
|
2739 |
self.PouName.SetValue(value) |
|
2740 |
elif item == "pouType": |
|
2741 |
self.PouType.SetStringSelection(value) |
|
2742 |
elif item == "language": |
|
2743 |
self.Language.SetStringSelection(value) |
|
2744 |
||
2745 |
def GetValues(self): |
|
2746 |
values = {} |
|
2747 |
values["pouName"] = self.PouName.GetValue() |
|
2748 |
values["pouType"] = self.PouType.GetStringSelection() |
|
2749 |
values["language"] = self.Language.GetStringSelection() |
|
2750 |
return values |
|
2751 |
||
2752 |
||
2753 |
#------------------------------------------------------------------------------- |
|
2754 |
# Create Pou Transition Dialog |
|
2755 |
#------------------------------------------------------------------------------- |
|
2756 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2757 |
[ID_POUTRANSITIONDIALOG, ID_POUTRANSITIONDIALOGTRANSITIONNAME, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2758 |
ID_POUTRANSITIONDIALOGLANGUAGE, ID_POUTRANSITIONDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2759 |
ID_POUTRANSITIONDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2760 |
] = [wx.NewId() for _init_ctrls in range(5)] |
0 | 2761 |
|
2762 |
class PouTransitionDialog(wx.Dialog): |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2763 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2764 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2765 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2766 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2767 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2768 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2769 |
|
0 | 2770 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2771 |
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:
58
diff
changeset
|
2772 |
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:
58
diff
changeset
|
2773 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2774 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2775 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2776 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2777 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2778 |
def _init_coll_MainSizer_Items(self, parent): |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2779 |
parent.AddWindow(self.staticText1, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2780 |
parent.AddWindow(self.TransitionName, 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:
114
diff
changeset
|
2781 |
parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2782 |
parent.AddWindow(self.Language, 0, border=0, flag=wx.GROW) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2783 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2784 |
def _init_coll_MainSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2785 |
parent.AddGrowableCol(1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2786 |
|
0 | 2787 |
def _init_sizers(self): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2788 |
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:
58
diff
changeset
|
2789 |
self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=15) |
0 | 2790 |
|
2791 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2792 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2793 |
self._init_coll_MainSizer_Items(self.MainSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2794 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
0 | 2795 |
|
2796 |
self.SetSizer(self.flexGridSizer1) |
|
2797 |
||
2798 |
def _init_ctrls(self, prnt): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2799 |
wx.Dialog.__init__(self, id=ID_POUTRANSITIONDIALOG, |
45 | 2800 |
name='PouTransitionDialog', parent=prnt, pos=wx.Point(376, 223), |
0 | 2801 |
size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE, |
45 | 2802 |
title='Create a new transition') |
2803 |
self.SetClientSize(wx.Size(350, 160)) |
|
0 | 2804 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2805 |
self.staticText1 = wx.StaticText(id=ID_POUTRANSITIONDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2806 |
label='Transition Name:', name='staticText1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2807 |
pos=wx.Point(0, 0), size=wx.Size(120, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2808 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2809 |
self.TransitionName = wx.TextCtrl(id=ID_POUTRANSITIONDIALOGTRANSITIONNAME, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2810 |
name='TransitionName', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2811 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2812 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2813 |
self.staticText2 = wx.StaticText(id=ID_POUTRANSITIONDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2814 |
label='Language:', name='staticText2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2815 |
pos=wx.Point(0, 0), size=wx.Size(120, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2816 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2817 |
self.Language = wx.Choice(id=ID_POUTRANSITIONDIALOGLANGUAGE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2818 |
name='Language', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2819 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2820 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2821 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2822 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2823 |
|
0 | 2824 |
self._init_sizers() |
2825 |
||
2826 |
def __init__(self, parent): |
|
2827 |
self._init_ctrls(parent) |
|
45 | 2828 |
|
0 | 2829 |
for option in ["IL","ST","LD","FBD"]: |
2830 |
self.Language.Append(option) |
|
70 | 2831 |
|
2832 |
self.PouNames = [] |
|
2833 |
self.PouElementNames = [] |
|
0 | 2834 |
|
2835 |
def OnOK(self, event): |
|
2836 |
error = [] |
|
70 | 2837 |
transition_name = self.TransitionName.GetValue() |
0 | 2838 |
if self.TransitionName.GetValue() == "": |
2839 |
error.append("Transition Name") |
|
2840 |
if self.Language.GetStringSelection() == "": |
|
2841 |
error.append("Language") |
|
2842 |
if len(error) > 0: |
|
2843 |
text = "" |
|
2844 |
for i, item in enumerate(error): |
|
2845 |
if i == 0: |
|
2846 |
text += item |
|
2847 |
elif i == len(error) - 1: |
|
2848 |
text += " and %s"%item |
|
2849 |
else: |
|
2850 |
text += ", %s"%item |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2851 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2852 |
message.ShowModal() |
2853 |
message.Destroy() |
|
70 | 2854 |
elif not TestIdentifier(transition_name): |
2855 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%transition_name, "Error", wx.OK|wx.ICON_ERROR) |
|
2856 |
message.ShowModal() |
|
2857 |
message.Destroy() |
|
2858 |
elif transition_name.upper() in IEC_KEYWORDS: |
|
2859 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%transition_name, "Error", wx.OK|wx.ICON_ERROR) |
|
2860 |
message.ShowModal() |
|
2861 |
message.Destroy() |
|
2862 |
elif transition_name.upper() in self.PouNames: |
|
2863 |
message = wx.MessageDialog(self, "A pou with \"%s\" for name exists!"%transition_name, "Error", wx.OK|wx.ICON_ERROR) |
|
2864 |
message.ShowModal() |
|
2865 |
message.Destroy() |
|
2866 |
elif transition_name.upper() in self.PouElementNames: |
|
2867 |
message = wx.MessageDialog(self, "\"%s\" element for this pou already exists!"%transition_name, "Error", wx.OK|wx.ICON_ERROR) |
|
2868 |
message.ShowModal() |
|
2869 |
message.Destroy() |
|
0 | 2870 |
else: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2871 |
self.EndModal(wx.ID_OK) |
70 | 2872 |
|
2873 |
def SetPouNames(self, pou_names): |
|
2874 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
2875 |
||
2876 |
def SetPouElementNames(self, pou_names): |
|
2877 |
self.PouElementNames = [pou_name.upper() for pou_name in pou_names] |
|
2878 |
||
0 | 2879 |
def SetValues(self, values): |
2880 |
for item, value in values.items(): |
|
45 | 2881 |
if item == "transitionName": |
0 | 2882 |
self.TransitionName.SetValue(value) |
2883 |
elif item == "language": |
|
2884 |
self.Language.SetStringSelection(value) |
|
2885 |
||
2886 |
def GetValues(self): |
|
2887 |
values = {} |
|
2888 |
values["transitionName"] = self.TransitionName.GetValue() |
|
2889 |
values["language"] = self.Language.GetStringSelection() |
|
2890 |
return values |
|
2891 |
||
2892 |
#------------------------------------------------------------------------------- |
|
2893 |
# Create Pou Action Dialog |
|
2894 |
#------------------------------------------------------------------------------- |
|
2895 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2896 |
[ID_POUACTIONDIALOG, ID_POUACTIONDIALOGACTIONNAME, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2897 |
ID_POUACTIONDIALOGLANGUAGE, ID_POUACTIONDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2898 |
ID_POUACTIONDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2899 |
] = [wx.NewId() for _init_ctrls in range(5)] |
0 | 2900 |
|
2901 |
class PouActionDialog(wx.Dialog): |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2902 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2903 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2904 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2905 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2906 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2907 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
2908 |
|
0 | 2909 |
def _init_coll_flexGridSizer1_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2910 |
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:
58
diff
changeset
|
2911 |
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:
58
diff
changeset
|
2912 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2913 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2914 |
parent.AddGrowableCol(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2915 |
parent.AddGrowableRow(0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2916 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2917 |
def _init_coll_MainSizer_Items(self, parent): |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2918 |
parent.AddWindow(self.staticText1, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2919 |
parent.AddWindow(self.ActionName, 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:
114
diff
changeset
|
2920 |
parent.AddWindow(self.staticText2, 0, border=4, flag=wx.GROW|wx.TOP) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2921 |
parent.AddWindow(self.Language, 0, border=0, flag=wx.GROW) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2922 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2923 |
def _init_coll_MainSizer_Growables(self, parent): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2924 |
parent.AddGrowableCol(1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2925 |
|
0 | 2926 |
def _init_sizers(self): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2927 |
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:
58
diff
changeset
|
2928 |
self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=15) |
0 | 2929 |
|
2930 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2931 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2932 |
self._init_coll_MainSizer_Items(self.MainSizer) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2933 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
0 | 2934 |
|
2935 |
self.SetSizer(self.flexGridSizer1) |
|
2936 |
||
2937 |
def _init_ctrls(self, prnt): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2938 |
wx.Dialog.__init__(self, id=ID_POUACTIONDIALOG, |
45 | 2939 |
name='PouActionDialog', parent=prnt, pos=wx.Point(376, 223), |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2940 |
size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
45 | 2941 |
title='Create a new action') |
2942 |
self.SetClientSize(wx.Size(320, 160)) |
|
0 | 2943 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2944 |
self.staticText1 = wx.StaticText(id=ID_POUACTIONDIALOGSTATICTEXT1, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2945 |
label='Action Name:', name='staticText1', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2946 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2947 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2948 |
self.ActionName = wx.TextCtrl(id=ID_POUACTIONDIALOGACTIONNAME, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2949 |
name='ActionName', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2950 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2951 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2952 |
self.staticText2 = wx.StaticText(id=ID_POUACTIONDIALOGSTATICTEXT2, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2953 |
label='Language:', name='staticText2', parent=self, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2954 |
pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2955 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2956 |
self.Language = wx.Choice(id=ID_POUACTIONDIALOGLANGUAGE, |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2957 |
name='Language', parent=self, pos=wx.Point(0, 0), |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2958 |
size=wx.Size(0, 24), style=0) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2959 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2960 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2961 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2962 |
|
0 | 2963 |
self._init_sizers() |
2964 |
||
2965 |
def __init__(self, parent): |
|
2966 |
self._init_ctrls(parent) |
|
45 | 2967 |
|
0 | 2968 |
for option in ["IL","ST","LD","FBD"]: |
2969 |
self.Language.Append(option) |
|
2970 |
||
70 | 2971 |
self.PouNames = [] |
2972 |
self.PouElementNames = [] |
|
2973 |
||
0 | 2974 |
def OnOK(self, event): |
2975 |
error = [] |
|
70 | 2976 |
action_name = self.ActionName.GetValue() |
2977 |
if action_name == "": |
|
0 | 2978 |
error.append("Action Name") |
2979 |
if self.Language.GetStringSelection() == "": |
|
2980 |
error.append("Language") |
|
2981 |
if len(error) > 0: |
|
2982 |
text = "" |
|
2983 |
for i, item in enumerate(error): |
|
2984 |
if i == 0: |
|
2985 |
text += item |
|
2986 |
elif i == len(error) - 1: |
|
2987 |
text += " and %s"%item |
|
2988 |
else: |
|
2989 |
text += ", %s"%item |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
2990 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
0 | 2991 |
message.ShowModal() |
2992 |
message.Destroy() |
|
70 | 2993 |
elif not TestIdentifier(action_name): |
2994 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%action_name, "Error", wx.OK|wx.ICON_ERROR) |
|
2995 |
message.ShowModal() |
|
2996 |
message.Destroy() |
|
2997 |
elif action_name.upper() in IEC_KEYWORDS: |
|
2998 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%action_name, "Error", wx.OK|wx.ICON_ERROR) |
|
2999 |
message.ShowModal() |
|
3000 |
message.Destroy() |
|
3001 |
elif action_name.upper() in self.PouNames: |
|
3002 |
message = wx.MessageDialog(self, "A pou with \"%s\" for name exists!"%action_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3003 |
message.ShowModal() |
|
3004 |
message.Destroy() |
|
3005 |
elif action_name.upper() in self.PouElementNames: |
|
3006 |
message = wx.MessageDialog(self, "\"%s\" element for this pou already exists!"%action_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3007 |
message.ShowModal() |
|
3008 |
message.Destroy() |
|
0 | 3009 |
else: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3010 |
self.EndModal(wx.ID_OK) |
70 | 3011 |
|
3012 |
def SetPouNames(self, pou_names): |
|
3013 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
3014 |
||
3015 |
def SetPouElementNames(self, element_names): |
|
3016 |
self.PouElementNames = [element_name.upper() for element_name in element_names] |
|
3017 |
||
0 | 3018 |
def SetValues(self, values): |
3019 |
for item, value in values.items(): |
|
45 | 3020 |
if item == "actionName": |
0 | 3021 |
self.ActionName.SetValue(value) |
3022 |
elif item == "language": |
|
3023 |
self.Language.SetStringSelection(value) |
|
3024 |
||
3025 |
def GetValues(self): |
|
3026 |
values = {} |
|
3027 |
values["actionName"] = self.ActionName.GetValue() |
|
3028 |
values["language"] = self.Language.GetStringSelection() |
|
3029 |
return values |
|
3030 |
||
3031 |
#------------------------------------------------------------------------------- |
|
80 | 3032 |
# Configuration Name Dialog |
3033 |
#------------------------------------------------------------------------------- |
|
3034 |
||
3035 |
class ConfigurationNameDialog(wx.TextEntryDialog): |
|
3036 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3037 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3038 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3039 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3040 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3041 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3042 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3043 |
|
80 | 3044 |
def __init__(self, parent, message, caption = "Please enter configuration name", defaultValue = "", |
3045 |
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): |
|
3046 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
|
3047 |
||
3048 |
self.PouNames = [] |
|
3049 |
self.PouElementNames = [] |
|
3050 |
||
144 | 3051 |
if wx.VERSION >= (2, 8, 0): |
3052 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) |
|
3053 |
elif wx.VERSION >= (2, 6, 0): |
|
3054 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) |
|
3055 |
else: |
|
3056 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
3057 |
||
80 | 3058 |
def OnOK(self, event): |
3059 |
config_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
3060 |
if config_name == "": |
|
3061 |
message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR) |
|
3062 |
message.ShowModal() |
|
3063 |
message.Destroy() |
|
3064 |
elif not TestIdentifier(config_name): |
|
3065 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%config_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3066 |
message.ShowModal() |
|
3067 |
message.Destroy() |
|
3068 |
elif config_name.upper() in IEC_KEYWORDS: |
|
3069 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%config_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3070 |
message.ShowModal() |
|
3071 |
message.Destroy() |
|
3072 |
elif config_name.upper() in self.PouNames: |
|
3073 |
message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%config_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3074 |
message.ShowModal() |
|
3075 |
message.Destroy() |
|
3076 |
elif config_name.upper() in self.PouElementNames: |
|
3077 |
message = wx.MessageDialog(self, "A pou has an element with \"%s\" for name. It can generate a conflict. Do you wish to continue?"%config_name, "Warning", wx.YES_NO|wx.ICON_EXCLAMATION) |
|
3078 |
result = message.ShowModal() |
|
3079 |
message.Destroy() |
|
3080 |
if result == wx.ID_YES: |
|
3081 |
self.EndModal(wx.ID_OK) |
|
3082 |
else: |
|
3083 |
self.EndModal(wx.ID_OK) |
|
3084 |
||
3085 |
def SetPouNames(self, pou_names): |
|
3086 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
3087 |
||
3088 |
def SetPouElementNames(self, pou_names): |
|
3089 |
self.PouElementNames = [pou_name.upper() for pou_name in pou_names] |
|
3090 |
||
3091 |
def GetValue(self): |
|
3092 |
return self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
3093 |
||
3094 |
#------------------------------------------------------------------------------- |
|
3095 |
# Resource Name Dialog |
|
3096 |
#------------------------------------------------------------------------------- |
|
3097 |
||
3098 |
class ResourceNameDialog(wx.TextEntryDialog): |
|
3099 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3100 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3101 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3102 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3103 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3104 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3105 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3106 |
|
80 | 3107 |
def __init__(self, parent, message, caption = "Please enter resource name", defaultValue = "", |
3108 |
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): |
|
3109 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
|
3110 |
||
3111 |
self.PouNames = [] |
|
3112 |
self.PouElementNames = [] |
|
3113 |
||
144 | 3114 |
if wx.VERSION >= (2, 8, 0): |
3115 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) |
|
3116 |
elif wx.VERSION >= (2, 6, 0): |
|
3117 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) |
|
3118 |
else: |
|
3119 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
|
3120 |
||
80 | 3121 |
def OnOK(self, event): |
3122 |
resource_name = self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
3123 |
if resource_name == "": |
|
3124 |
message = wx.MessageDialog(self, "You must type a name!", "Error", wx.OK|wx.ICON_ERROR) |
|
3125 |
message.ShowModal() |
|
3126 |
message.Destroy() |
|
3127 |
elif not TestIdentifier(resource_name): |
|
3128 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%resource_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3129 |
message.ShowModal() |
|
3130 |
message.Destroy() |
|
3131 |
elif resource_name.upper() in IEC_KEYWORDS: |
|
3132 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%resource_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3133 |
message.ShowModal() |
|
3134 |
message.Destroy() |
|
3135 |
elif resource_name.upper() in self.PouNames: |
|
3136 |
message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%resource_name, "Error", wx.OK|wx.ICON_ERROR) |
|
3137 |
message.ShowModal() |
|
3138 |
message.Destroy() |
|
3139 |
elif resource_name.upper() in self.PouElementNames: |
|
3140 |
message = wx.MessageDialog(self, "A pou has an element with \"%s\" for name. It can generate a conflict. Do you wish to continue?"%resource_name, "Warning", wx.YES_NO|wx.ICON_EXCLAMATION) |
|
3141 |
result = message.ShowModal() |
|
3142 |
message.Destroy() |
|
3143 |
if result == wx.ID_YES: |
|
3144 |
self.EndModal(wx.ID_OK) |
|
3145 |
else: |
|
3146 |
self.EndModal(wx.ID_OK) |
|
3147 |
||
3148 |
def SetPouNames(self, pou_names): |
|
3149 |
self.PouNames = [pou_name.upper() for pou_name in pou_names] |
|
3150 |
||
3151 |
def SetPouElementNames(self, pou_names): |
|
3152 |
self.PouElementNames = [pou_name.upper() for pou_name in pou_names] |
|
3153 |
||
3154 |
def GetValue(self): |
|
3155 |
return self.GetSizer().GetItem(1).GetWindow().GetValue() |
|
3156 |
||
3157 |
#------------------------------------------------------------------------------- |
|
121 | 3158 |
# Variables Editor Panel |
3159 |
#------------------------------------------------------------------------------- |
|
3160 |
||
3161 |
class VariablePanelIndexer(wx.Panel): |
|
3162 |
||
3163 |
def _init_sizers(self): |
|
3164 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
3165 |
||
3166 |
self.SetSizer(self.MainSizer) |
|
3167 |
||
3168 |
def _init_ctrls(self, prnt): |
|
3169 |
wx.Panel.__init__(self, id=wx.NewId(), |
|
3170 |
name='VariablePanelIndexer', parent=prnt, pos=wx.Point(0, 0), |
|
3171 |
size=wx.Size(0, 300), style=wx.TAB_TRAVERSAL) |
|
3172 |
||
3173 |
self._init_sizers() |
|
3174 |
||
145 | 3175 |
def __init__(self, parent, window, controler): |
121 | 3176 |
self._init_ctrls(parent) |
3177 |
||
145 | 3178 |
self.ParentWindow = window |
121 | 3179 |
self.Controler = controler |
3180 |
||
3181 |
self.VariablePanelList = {} |
|
3182 |
self.CurrentPanel = None |
|
3183 |
||
3184 |
def AddVariablePanel(self, tagname, element_type): |
|
3185 |
new_panel = VariablePanel(self, self.ParentWindow, self.Controler, element_type) |
|
3186 |
new_panel.SetTagName(tagname) |
|
3187 |
new_panel.Hide() |
|
3188 |
new_panel.RefreshView() |
|
3189 |
self.MainSizer.AddWindow(new_panel, 1, border=0, flag=wx.GROW) |
|
3190 |
self.VariablePanelList[tagname] = new_panel |
|
3191 |
||
3192 |
def RemoveVariablePanel(self, tagname): |
|
3193 |
if tagname in self.VariablePanelList: |
|
3194 |
panel = self.VariablePanelList.pop(tagname) |
|
3195 |
panel.Hide() |
|
3196 |
self.MainSizer.Remove(panel) |
|
3197 |
if self.CurrentPanel == tagname: |
|
3198 |
self.CurrentPanel = None |
|
3199 |
||
3200 |
def RemoveAllPanels(self): |
|
3201 |
if self.CurrentPanel is not None and self.CurrentPanel in self.VariablePanelList: |
|
3202 |
self.VariablePanelList[self.CurrentPanel].Hide() |
|
3203 |
self.VariablePanelList = {} |
|
3204 |
self.MainSizer.Clear() |
|
3205 |
self.CurrentPanel = None |
|
3206 |
||
3207 |
def UpdateVariablePanelTagName(self, old_tagname, new_tagname): |
|
145 | 3208 |
if old_tagname in self.VariablePanelList: |
121 | 3209 |
self.VariablePanelList[new_tagname] = self.VariablePanelList.pop(old_tagname) |
3210 |
if self.CurrentPanel == old_tagname: |
|
3211 |
self.CurrentPanel = new_tagname |
|
3212 |
||
3213 |
def ChangeVariablePanel(self, tagname): |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3214 |
if tagname in self.VariablePanelList: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3215 |
if tagname != self.CurrentPanel: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3216 |
if self.CurrentPanel is not None: |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3217 |
self.VariablePanelList[self.CurrentPanel].Hide() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3218 |
self.CurrentPanel = tagname |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3219 |
self.VariablePanelList[self.CurrentPanel].RefreshView() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3220 |
self.VariablePanelList[self.CurrentPanel].Show() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3221 |
self.MainSizer.Layout() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3222 |
else: |
121 | 3223 |
if self.CurrentPanel is not None: |
3224 |
self.VariablePanelList[self.CurrentPanel].Hide() |
|
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3225 |
self.CurrentPanel = None |
121 | 3226 |
self.MainSizer.Layout() |
3227 |
||
3228 |
def RefreshVariablePanel(self, tagname): |
|
3229 |
if tagname in self.VariablePanelList: |
|
3230 |
self.VariablePanelList[self.CurrentPanel].RefreshView() |
|
3231 |
||
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3232 |
def AddVariableError(self, infos): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3233 |
self.ChangeVariablePanel(infos[0]) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3234 |
if self.CurrentPanel is not None: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3235 |
self.VariablePanelList[self.CurrentPanel].AddVariableError(infos[2:]) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3236 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3237 |
def ClearErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3238 |
for panel in self.VariablePanelList.values(): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3239 |
panel.ClearErrors() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3240 |
|
121 | 3241 |
#------------------------------------------------------------------------------- |
3242 |
# Variables Editor Panel |
|
0 | 3243 |
#------------------------------------------------------------------------------- |
3244 |
||
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3245 |
class VariableTable(wx.grid.PyGridTableBase): |
0 | 3246 |
|
3247 |
""" |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3248 |
A custom wx.grid.Grid Table using user supplied data |
0 | 3249 |
""" |
3250 |
def __init__(self, parent, data, colnames): |
|
3251 |
# The base class must be initialized *first* |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3252 |
wx.grid.PyGridTableBase.__init__(self) |
0 | 3253 |
self.data = data |
58 | 3254 |
self.old_value = None |
0 | 3255 |
self.colnames = colnames |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3256 |
self.Errors = {} |
0 | 3257 |
self.Parent = parent |
3258 |
# XXX |
|
3259 |
# we need to store the row length and collength to |
|
3260 |
# see if the table has changed size |
|
3261 |
self._rows = self.GetNumberRows() |
|
3262 |
self._cols = self.GetNumberCols() |
|
3263 |
||
3264 |
def GetNumberCols(self): |
|
3265 |
return len(self.colnames) |
|
3266 |
||
3267 |
def GetNumberRows(self): |
|
3268 |
return len(self.data) |
|
3269 |
||
3270 |
def GetColLabelValue(self, col): |
|
3271 |
if col < len(self.colnames): |
|
3272 |
return self.colnames[col] |
|
3273 |
||
3274 |
def GetRowLabelValues(self, row): |
|
3275 |
return row |
|
3276 |
||
3277 |
def GetValue(self, row, col): |
|
3278 |
if row < self.GetNumberRows(): |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3279 |
if col == 0: |
80 | 3280 |
return self.data[row]["Number"] |
0 | 3281 |
name = str(self.data[row].get(self.GetColLabelValue(col), "")) |
3282 |
return name |
|
3283 |
||
3284 |
def SetValue(self, row, col, value): |
|
3285 |
if col < len(self.colnames): |
|
58 | 3286 |
colname = self.GetColLabelValue(col) |
3287 |
if colname == "Name": |
|
3288 |
self.old_value = self.data[row][colname] |
|
3289 |
self.data[row][colname] = value |
|
3290 |
||
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3291 |
def GetValueByName(self, row, colname): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3292 |
if row < self.GetNumberRows(): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3293 |
return self.data[row].get(colname) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3294 |
|
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3295 |
def SetValueByName(self, row, colname, value): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3296 |
if row < self.GetNumberRows(): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3297 |
self.data[row][colname] = value |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3298 |
|
58 | 3299 |
def GetOldValue(self): |
3300 |
return self.old_value |
|
3301 |
||
0 | 3302 |
def ResetView(self, grid): |
3303 |
""" |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3304 |
(wx.grid.Grid) -> Reset the grid view. Call this to |
0 | 3305 |
update the grid if rows and columns have been added or deleted |
3306 |
""" |
|
3307 |
grid.BeginBatch() |
|
3308 |
for current, new, delmsg, addmsg in [ |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3309 |
(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:
58
diff
changeset
|
3310 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
0 | 3311 |
]: |
3312 |
if new < current: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3313 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
0 | 3314 |
grid.ProcessTableMessage(msg) |
3315 |
elif new > current: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3316 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
0 | 3317 |
grid.ProcessTableMessage(msg) |
3318 |
self.UpdateValues(grid) |
|
3319 |
grid.EndBatch() |
|
3320 |
||
3321 |
self._rows = self.GetNumberRows() |
|
3322 |
self._cols = self.GetNumberCols() |
|
3323 |
# update the column rendering scheme |
|
3324 |
self._updateColAttrs(grid) |
|
3325 |
||
3326 |
# update the scrollbars and the displayed part of the grid |
|
3327 |
grid.AdjustScrollbars() |
|
3328 |
grid.ForceRefresh() |
|
3329 |
||
3330 |
def UpdateValues(self, grid): |
|
3331 |
"""Update all displayed values""" |
|
3332 |
# 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:
58
diff
changeset
|
3333 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
0 | 3334 |
grid.ProcessTableMessage(msg) |
3335 |
||
3336 |
def _updateColAttrs(self, grid): |
|
3337 |
""" |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3338 |
wx.grid.Grid -> update the column attributes to add the |
0 | 3339 |
appropriate renderer given the column name. |
3340 |
||
3341 |
Otherwise default to the default renderer. |
|
3342 |
""" |
|
3343 |
||
3344 |
typelist = None |
|
3345 |
accesslist = None |
|
3346 |
for row in range(self.GetNumberRows()): |
|
3347 |
for col in range(self.GetNumberCols()): |
|
3348 |
editor = None |
|
3349 |
renderer = None |
|
3350 |
colname = self.GetColLabelValue(col) |
|
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3351 |
if col != 0 and self.GetValueByName(row, "Edit"): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3352 |
grid.SetReadOnly(row, col, False) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3353 |
if colname == "Name": |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3354 |
if self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3355 |
grid.SetReadOnly(row, col, True) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3356 |
else: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3357 |
editor = wx.grid.GridCellTextEditor() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3358 |
renderer = wx.grid.GridCellStringRenderer() |
107 | 3359 |
elif colname == "Initial Value": |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3360 |
editor = wx.grid.GridCellTextEditor() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3361 |
renderer = wx.grid.GridCellStringRenderer() |
107 | 3362 |
elif colname == "Location": |
3363 |
if self.GetValueByName(row, "Class") in ["Local", "Global"]: |
|
3364 |
editor = wx.grid.GridCellTextEditor() |
|
3365 |
renderer = wx.grid.GridCellStringRenderer() |
|
3366 |
else: |
|
3367 |
grid.SetReadOnly(row, col, True) |
|
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3368 |
elif colname == "Class": |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3369 |
if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and self.GetValueByName(row, "Class") in ["Input", "Output", "InOut"]: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3370 |
grid.SetReadOnly(row, col, True) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3371 |
else: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3372 |
editor = wx.grid.GridCellChoiceEditor() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3373 |
excluded = [] |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3374 |
if self.Parent.PouIsUsed: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3375 |
excluded.extend(["Input","Output","InOut"]) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3376 |
editor.SetParameters(",".join([choice for choice in self.Parent.ClassList if choice not in excluded])) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3377 |
elif colname in ["Retain", "Constant"]: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3378 |
editor = wx.grid.GridCellChoiceEditor() |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3379 |
editor.SetParameters(self.Parent.OptionList) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3380 |
elif colname == "Type": |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3381 |
editor = wx.grid.GridCellTextEditor() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3382 |
else: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3383 |
grid.SetReadOnly(row, col, True) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3384 |
|
0 | 3385 |
grid.SetCellEditor(row, col, editor) |
3386 |
grid.SetCellRenderer(row, col, renderer) |
|
3387 |
||
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3388 |
if row in self.Errors and self.Errors[row][0] == colname.lower(): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3389 |
grid.SetCellBackgroundColour(row, col, wx.Colour(255, 255, 0)) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3390 |
grid.SetCellTextColour(row, col, wx.RED) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3391 |
grid.MakeCellVisible(row, col) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3392 |
else: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3393 |
grid.SetCellTextColour(row, col, wx.BLACK) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3394 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
0 | 3395 |
|
3396 |
def SetData(self, data): |
|
3397 |
self.data = data |
|
3398 |
||
3399 |
def GetData(self): |
|
3400 |
return self.data |
|
3401 |
||
3402 |
def GetCurrentIndex(self): |
|
3403 |
return self.CurrentIndex |
|
3404 |
||
3405 |
def SetCurrentIndex(self, index): |
|
3406 |
self.CurrentIndex = index |
|
3407 |
||
3408 |
def AppendRow(self, row_content): |
|
3409 |
self.data.append(row_content) |
|
3410 |
||
3411 |
def RemoveRow(self, row_index): |
|
3412 |
self.data.pop(row_index) |
|
12 | 3413 |
|
3414 |
def GetRow(self, row_index): |
|
3415 |
return self.data[row_index] |
|
0 | 3416 |
|
3417 |
def Empty(self): |
|
3418 |
self.data = [] |
|
3419 |
self.editors = [] |
|
3420 |
||
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3421 |
def AddError(self, infos): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3422 |
self.Errors[infos[0]] = infos[1:] |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3423 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3424 |
def ClearErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3425 |
self.Errors = {} |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3426 |
|
53 | 3427 |
class VariableDropTarget(wx.TextDropTarget): |
3428 |
||
3429 |
def __init__(self, parent): |
|
3430 |
wx.TextDropTarget.__init__(self) |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3431 |
self.ParentWindow = parent |
53 | 3432 |
|
3433 |
def OnDropText(self, x, y, data): |
|
182 | 3434 |
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3435 |
col = self.ParentWindow.VariablesGrid.XToCol(x) |
97 | 3436 |
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize()) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3437 |
if col != wx.NOT_FOUND and row != wx.NOT_FOUND: |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3438 |
if self.ParentWindow.Table.GetColLabelValue(col) != "Location": |
53 | 3439 |
return |
107 | 3440 |
message = None |
3441 |
if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
|
3442 |
message = "Can't affect a location to a function block instance" |
|
3443 |
elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]: |
|
3444 |
message = "Can affect a location only to local or global variables" |
|
3445 |
else: |
|
3446 |
try: |
|
3447 |
values = eval(data) |
|
3448 |
except: |
|
218 | 3449 |
message = "Invalid value \"%s\" for location"%data |
107 | 3450 |
values = None |
218 | 3451 |
if not isinstance(values, TupleType): |
3452 |
message = "Invalid value \"%s\" for location"%data |
|
3453 |
values = None |
|
3454 |
if values is not None and values[1] == "location": |
|
107 | 3455 |
location = values[0] |
3456 |
variable_type = self.ParentWindow.Table.GetValueByName(row, "Type") |
|
219
ca1f1d3734f9
Bug on located variable defined with devived type when dropping location fixed
lbessard
parents:
218
diff
changeset
|
3457 |
base_type = self.ParentWindow.Controler.GetBaseType(variable_type) |
107 | 3458 |
message = None |
210 | 3459 |
if location.startswith("%"): |
219
ca1f1d3734f9
Bug on located variable defined with devived type when dropping location fixed
lbessard
parents:
218
diff
changeset
|
3460 |
if base_type != values[2]: |
210 | 3461 |
message = "Incompatible data types between \"%s\" and \"%s\""%(values[2], variable_type) |
3462 |
else: |
|
107 | 3463 |
self.ParentWindow.Table.SetValue(row, col, location) |
3464 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
|
3465 |
self.ParentWindow.SaveValues() |
|
210 | 3466 |
else: |
219
ca1f1d3734f9
Bug on located variable defined with devived type when dropping location fixed
lbessard
parents:
218
diff
changeset
|
3467 |
if location[0].isdigit() and base_type != "BOOL": |
210 | 3468 |
message = "Incompatible size of data between \"%s\" and \"BOOL\""%location |
3469 |
elif location[0] not in LOCATIONDATATYPES: |
|
3470 |
message = "Unrecognized data size \"%s\""%location[0] |
|
219
ca1f1d3734f9
Bug on located variable defined with devived type when dropping location fixed
lbessard
parents:
218
diff
changeset
|
3471 |
elif base_type not in LOCATIONDATATYPES[location[0]]: |
210 | 3472 |
message = "Incompatible size of data between \"%s\" and \"%s\""%(location, variable_type) |
3473 |
else: |
|
3474 |
dialog = wx.SingleChoiceDialog(self.ParentWindow, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wx.OK|wx.CANCEL) |
|
3475 |
if dialog.ShowModal() == wx.ID_OK: |
|
3476 |
selected = dialog.GetSelection() |
|
3477 |
if selected == 0: |
|
3478 |
location = "%I" + location |
|
3479 |
elif selected == 1: |
|
3480 |
location = "%Q" + location |
|
3481 |
else: |
|
3482 |
location = "%M" + location |
|
3483 |
self.ParentWindow.Table.SetValue(row, col, location) |
|
3484 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
|
3485 |
self.ParentWindow.SaveValues() |
|
3486 |
dialog.Destroy() |
|
218 | 3487 |
wx.CallAfter(self.ShowMessage, message) |
3488 |
||
3489 |
def ShowMessage(self, message): |
|
3490 |
if message is not None: |
|
3491 |
message = wx.MessageDialog(self.ParentWindow, message, "Error", wx.OK|wx.ICON_ERROR) |
|
3492 |
message.ShowModal() |
|
3493 |
message.Destroy() |
|
53 | 3494 |
|
121 | 3495 |
[ID_VARIABLEEDITORPANEL, ID_VARIABLEEDITORPANELVARIABLESGRID, |
3496 |
ID_VARIABLEEDITORPANELRETURNTYPE, ID_VARIABLEEDITORPANELCLASSFILTER, |
|
3497 |
ID_VARIABLEEDITORPANELADDBUTTON, ID_VARIABLEEDITORPANELDELETEBUTTON, |
|
3498 |
ID_VARIABLEEDITORPANELUPBUTTON, ID_VARIABLEEDITORPANELDOWNBUTTON, |
|
3499 |
ID_VARIABLEEDITORPANELSTATICTEXT1, ID_VARIABLEEDITORPANELSTATICTEXT2, |
|
3500 |
ID_VARIABLEEDITORPANELSTATICTEXT3, |
|
3501 |
] = [wx.NewId() for _init_ctrls in range(11)] |
|
3502 |
||
3503 |
class VariablePanel(wx.Panel): |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3504 |
|
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3505 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3506 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3507 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3508 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3509 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3510 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3511 |
|
121 | 3512 |
def _init_coll_MainSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3513 |
parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3514 |
parent.AddSizer(self.ControlPanelSizer, 0, border=0, flag=wx.GROW) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3515 |
|
121 | 3516 |
def _init_coll_MainSizer_Growables(self, parent): |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3517 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3518 |
parent.AddGrowableRow(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3519 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3520 |
def _init_coll_ControlPanelSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3521 |
parent.AddSizer(self.ChoicePanelSizer, 0, border=0, flag=wx.GROW) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3522 |
parent.AddSizer(self.ButtonPanelSizer, 0, border=0, flag=wx.ALIGN_CENTER) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3523 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3524 |
def _init_coll_ControlPanelSizer_Growables(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3525 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3526 |
parent.AddGrowableRow(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3527 |
parent.AddGrowableRow(1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3528 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3529 |
def _init_coll_ChoicePanelSizer_Items(self, parent): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3530 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.ALIGN_BOTTOM) |
52 | 3531 |
parent.AddWindow(self.ReturnType, 0, border=0, flag=0) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3532 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_BOTTOM) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3533 |
parent.AddWindow(self.ClassFilter, 0, border=0, flag=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3534 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3535 |
def _init_coll_ButtonPanelSizer_Items(self, parent): |
52 | 3536 |
parent.AddWindow(self.UpButton, 0, border=0, flag=0) |
51 | 3537 |
parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
52 | 3538 |
parent.AddWindow(self.DownButton, 0, border=0, flag=0) |
51 | 3539 |
parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) |
52 | 3540 |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3541 |
def _init_coll_ButtonPanelSizer_Growables(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3542 |
parent.AddGrowableCol(0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3543 |
parent.AddGrowableCol(1) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3544 |
parent.AddGrowableCol(2) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3545 |
parent.AddGrowableCol(3) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3546 |
parent.AddGrowableRow(0) |
0 | 3547 |
|
3548 |
def _init_sizers(self): |
|
121 | 3549 |
self.MainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=0) |
52 | 3550 |
self.ControlPanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
3551 |
self.ChoicePanelSizer = wx.GridSizer(cols=1, hgap=5, rows=4, vgap=5) |
|
3552 |
self.ButtonPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3553 |
|
121 | 3554 |
self._init_coll_MainSizer_Items(self.MainSizer) |
3555 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3556 |
self._init_coll_ControlPanelSizer_Items(self.ControlPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3557 |
self._init_coll_ControlPanelSizer_Growables(self.ControlPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3558 |
self._init_coll_ChoicePanelSizer_Items(self.ChoicePanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3559 |
self._init_coll_ButtonPanelSizer_Items(self.ButtonPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3560 |
self._init_coll_ButtonPanelSizer_Growables(self.ButtonPanelSizer) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3561 |
|
121 | 3562 |
self.SetSizer(self.MainSizer) |
3563 |
||
3564 |
def _init_ctrls(self, prnt): |
|
3565 |
wx.Panel.__init__(self, id=ID_VARIABLEEDITORPANEL, |
|
3566 |
name='VariableEditorPanel', parent=prnt, pos=wx.Point(0, 0), |
|
80 | 3567 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3568 |
|
121 | 3569 |
self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, |
3570 |
label='Return Type:', name='staticText1', parent=self, |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3571 |
pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3572 |
|
121 | 3573 |
self.ReturnType = wx.Choice(id=ID_VARIABLEEDITORPANELRETURNTYPE, |
3574 |
name='ReturnType', parent=self, pos=wx.Point(0, 0), |
|
52 | 3575 |
size=wx.Size(145, 24), style=0) |
121 | 3576 |
self.Bind(wx.EVT_CHOICE, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE) |
3577 |
||
3578 |
self.staticText2 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT2, |
|
3579 |
label='Class Filter:', name='staticText2', parent=self, |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3580 |
pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3581 |
|
121 | 3582 |
self.ClassFilter = wx.Choice(id=ID_VARIABLEEDITORPANELCLASSFILTER, |
3583 |
name='ClassFilter', parent=self, pos=wx.Point(0, 0), |
|
52 | 3584 |
size=wx.Size(145, 24), style=0) |
121 | 3585 |
self.Bind(wx.EVT_CHOICE, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER) |
3586 |
||
3587 |
self.VariablesGrid = wx.grid.Grid(id=ID_VARIABLEEDITORPANELVARIABLESGRID, |
|
3588 |
name='VariablesGrid', parent=self, pos=wx.Point(0, 0), |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3589 |
size=wx.Size(0, 150), style=wx.VSCROLL) |
0 | 3590 |
self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
3591 |
'Sans')) |
|
3592 |
self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
|
3593 |
False, 'Sans')) |
|
107 | 3594 |
self.VariablesGrid.SetSelectionBackground(wx.WHITE) |
3595 |
self.VariablesGrid.SetSelectionForeground(wx.BLACK) |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3596 |
if wx.VERSION >= (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3597 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3598 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridSelectCell) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3599 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3600 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3601 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3602 |
wx.grid.EVT_GRID_CELL_CHANGE(self.VariablesGrid, self.OnVariablesGridCellChange) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3603 |
wx.grid.EVT_GRID_SELECT_CELL(self.VariablesGrid, self.OnVariablesGridSelectCell) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3604 |
wx.grid.EVT_GRID_CELL_LEFT_CLICK(self.VariablesGrid, self.OnVariablesGridCellLeftClick) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3605 |
wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown) |
53 | 3606 |
self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) |
3607 |
||
121 | 3608 |
self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label='Add', |
3609 |
name='AddButton', parent=self, pos=wx.Point(345, 340), |
|
0 | 3610 |
size=wx.Size(72, 32), style=0) |
121 | 3611 |
self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_VARIABLEEDITORPANELADDBUTTON) |
3612 |
||
3613 |
self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label='Delete', |
|
3614 |
name='DeleteButton', parent=self, pos=wx.Point(425, 340), |
|
0 | 3615 |
size=wx.Size(72, 32), style=0) |
121 | 3616 |
self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_VARIABLEEDITORPANELDELETEBUTTON) |
3617 |
||
3618 |
self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^', |
|
3619 |
name='UpButton', parent=self, pos=wx.Point(505, 340), |
|
0 | 3620 |
size=wx.Size(32, 32), style=0) |
121 | 3621 |
self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_VARIABLEEDITORPANELUPBUTTON) |
3622 |
||
3623 |
self.DownButton = wx.Button(id=ID_VARIABLEEDITORPANELDOWNBUTTON, label='v', |
|
3624 |
name='DownButton', parent=self, pos=wx.Point(545, 340), |
|
0 | 3625 |
size=wx.Size(32, 32), style=0) |
121 | 3626 |
self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_VARIABLEEDITORPANELDOWNBUTTON) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3627 |
|
0 | 3628 |
self._init_sizers() |
3629 |
||
121 | 3630 |
def __init__(self, parent, window, controler, element_type): |
3631 |
self._init_ctrls(parent) |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3632 |
self.ParentWindow = window |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3633 |
self.Controler = controler |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3634 |
self.ElementType = element_type |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3635 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3636 |
self.Filter = "All" |
0 | 3637 |
self.FilterChoices = [] |
3638 |
self.FilterChoiceTransfer = {"All" : "All", "Interface" : "Interface", |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3639 |
" Input" : "Input", " Output" : "Output", " InOut" : "InOut", |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3640 |
" External" : "External", "Variables" : "Variables", " Local" : "Local", |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3641 |
" Temp" : "Temp", "Global" : "Global", "Access" : "Access"} |
0 | 3642 |
|
121 | 3643 |
if element_type in ["config", "resource"]: |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3644 |
self.DefaultTypes = {"All" : "Global"} |
80 | 3645 |
self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True} |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3646 |
else: |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3647 |
self.DefaultTypes = {"All" : "Local", "Interface" : "Input", "Variables" : "Local"} |
80 | 3648 |
self.DefaultValue = {"Name" : "", "Class" : "", "Type" : "INT", "Location" : "", "Initial Value" : "", "Retain" : "No", "Constant" : "No", "Edit" : True} |
121 | 3649 |
if element_type in ["config", "resource"] or element_type in ["program", "transition", "action"]: |
70 | 3650 |
self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Location", "Initial Value", "Retain", "Constant"]) |
121 | 3651 |
if element_type not in ["config", "resource"]: |
0 | 3652 |
self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp","Global","Access"] |
3653 |
else: |
|
3654 |
self.FilterChoices = ["All","Global","Access"] |
|
70 | 3655 |
self.ColSizes = [40, 80, 70, 80, 80, 80, 60, 70] |
3656 |
self.ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_CENTER] |
|
3657 |
else: |
|
3658 |
self.Table = VariableTable(self, [], ["#", "Name", "Class", "Type", "Initial Value", "Retain", "Constant"]) |
|
0 | 3659 |
self.FilterChoices = ["All","Interface"," Input"," Output"," InOut"," External","Variables"," Local"," Temp"] |
70 | 3660 |
self.ColSizes = [40, 120, 70, 80, 120, 60, 70] |
3661 |
self.ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_CENTER] |
|
0 | 3662 |
for choice in self.FilterChoices: |
3663 |
self.ClassFilter.Append(choice) |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3664 |
reverse_transfer = {} |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3665 |
for filter, choice in self.FilterChoiceTransfer.items(): |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3666 |
reverse_transfer[choice] = filter |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3667 |
self.ClassFilter.SetStringSelection(reverse_transfer[self.Filter]) |
0 | 3668 |
self.RefreshTypeList() |
3669 |
||
3670 |
self.OptionList = "Yes,No" |
|
3671 |
||
121 | 3672 |
if element_type == "function": |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3673 |
for base_type in self.Controler.GetBaseTypes(): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3674 |
self.ReturnType.Append(base_type) |
0 | 3675 |
self.ReturnType.Enable(True) |
3676 |
else: |
|
3677 |
self.ReturnType.Enable(False) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3678 |
self.staticText1.Hide() |
0 | 3679 |
self.ReturnType.Hide() |
3680 |
||
3681 |
self.VariablesGrid.SetTable(self.Table) |
|
3682 |
self.VariablesGrid.SetRowLabelSize(0) |
|
107 | 3683 |
for col in range(self.Table.GetNumberCols()): |
3684 |
attr = wx.grid.GridCellAttr() |
|
3685 |
attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE) |
|
3686 |
self.VariablesGrid.SetColAttr(col, attr) |
|
3687 |
self.VariablesGrid.SetColSize(col, self.ColSizes[col]) |
|
3688 |
||
121 | 3689 |
def SetTagName(self, tagname): |
3690 |
self.TagName = tagname |
|
3691 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3692 |
def RefreshView(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3693 |
self.PouNames = self.Controler.GetProjectPouNames() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3694 |
|
121 | 3695 |
words = self.TagName.split("::") |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3696 |
if self.ElementType == "config": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3697 |
self.PouIsUsed = False |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3698 |
returnType = None |
121 | 3699 |
self.Values = self.Controler.GetConfigurationGlobalVars(words[1]) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3700 |
elif self.ElementType == "resource": |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3701 |
self.PouIsUsed = False |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3702 |
returnType = None |
121 | 3703 |
self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2]) |
3704 |
else: |
|
3705 |
self.PouIsUsed = self.Controler.PouIsUsed(words[1]) |
|
3706 |
returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName) |
|
3707 |
self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName) |
|
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3708 |
|
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3709 |
if returnType and self.ReturnType.IsEnabled(): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3710 |
self.ReturnType.SetStringSelection(returnType) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3711 |
|
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3712 |
self.RefreshValues() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3713 |
self.RefreshButtons() |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
65
diff
changeset
|
3714 |
|
80 | 3715 |
def OnReturnTypeChanged(self, event): |
121 | 3716 |
words = self.TagName.split("::") |
3717 |
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection()) |
|
80 | 3718 |
self.Controler.BufferProject() |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3719 |
self.ParentWindow.RefreshTitle() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3720 |
self.ParentWindow.RefreshEditMenu() |
80 | 3721 |
event.Skip() |
3722 |
||
0 | 3723 |
def OnClassFilter(self, event): |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3724 |
self.Filter = self.FilterChoiceTransfer[self.ClassFilter.GetStringSelection()] |
0 | 3725 |
self.RefreshTypeList() |
3726 |
self.RefreshValues() |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3727 |
self.RefreshButtons() |
0 | 3728 |
event.Skip() |
3729 |
||
3730 |
def RefreshTypeList(self): |
|
3731 |
if self.Filter == "All": |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3732 |
self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All","Interface","Variables"]] |
0 | 3733 |
elif self.Filter == "Interface": |
3734 |
self.ClassList = ["Input","Output","InOut","External"] |
|
3735 |
elif self.Filter == "Variables": |
|
3736 |
self.ClassList = ["Local","Temp"] |
|
3737 |
else: |
|
3738 |
self.ClassList = [self.Filter] |
|
3739 |
||
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3740 |
def RefreshButtons(self): |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
3741 |
if getattr(self, "Table", None): |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3742 |
table_length = len(self.Table.data) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3743 |
row_class = None |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3744 |
if table_length and self.PouIsUsed: |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3745 |
row = self.VariablesGrid.GetGridCursorRow() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3746 |
row_class = self.Table.GetValueByName(row, "Class") |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3747 |
self.AddButton.Enable(not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3748 |
self.DeleteButton.Enable(table_length > 0 and row_class not in ["Input", "Output", "InOut"]) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3749 |
self.UpButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
55
diff
changeset
|
3750 |
self.DownButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3751 |
|
0 | 3752 |
def OnAddButton(self, event): |
11 | 3753 |
new_row = self.DefaultValue.copy() |
3754 |
if self.Filter in self.DefaultTypes: |
|
3755 |
new_row["Class"] = self.DefaultTypes[self.Filter] |
|
3756 |
else: |
|
3757 |
new_row["Class"] = self.Filter |
|
12 | 3758 |
self.Values.append(new_row) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3759 |
self.SaveValues() |
12 | 3760 |
self.RefreshValues() |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3761 |
self.RefreshButtons() |
0 | 3762 |
event.Skip() |
3763 |
||
3764 |
def OnDeleteButton(self, event): |
|
12 | 3765 |
row = self.Table.GetRow(self.VariablesGrid.GetGridCursorRow()) |
3766 |
self.Values.remove(row) |
|
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3767 |
self.SaveValues() |
12 | 3768 |
self.RefreshValues() |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3769 |
self.RefreshButtons() |
0 | 3770 |
event.Skip() |
3771 |
||
3772 |
def OnUpButton(self, event): |
|
12 | 3773 |
self.MoveValue(self.VariablesGrid.GetGridCursorRow(), -1) |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3774 |
self.RefreshButtons() |
0 | 3775 |
event.Skip() |
3776 |
||
3777 |
def OnDownButton(self, event): |
|
12 | 3778 |
self.MoveValue(self.VariablesGrid.GetGridCursorRow(), 1) |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3779 |
self.RefreshButtons() |
0 | 3780 |
event.Skip() |
3781 |
||
6 | 3782 |
def OnVariablesGridCellChange(self, event): |
3783 |
row, col = event.GetRow(), event.GetCol() |
|
3784 |
colname = self.Table.GetColLabelValue(col) |
|
3785 |
value = self.Table.GetValue(row, col) |
|
3786 |
if colname == "Name": |
|
3787 |
if not TestIdentifier(value): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3788 |
message = wx.MessageDialog(self, "\"%s\" is not a valid identifier!"%value, "Error", wx.OK|wx.ICON_ERROR) |
6 | 3789 |
message.ShowModal() |
3790 |
message.Destroy() |
|
3791 |
event.Veto() |
|
3792 |
elif value.upper() in IEC_KEYWORDS: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3793 |
message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%value, "Error", wx.OK|wx.ICON_ERROR) |
6 | 3794 |
message.ShowModal() |
3795 |
message.Destroy() |
|
3796 |
event.Veto() |
|
3797 |
elif value.upper() in self.PouNames: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3798 |
message = wx.MessageDialog(self, "A pou with \"%s\" as name exists!"%value, "Error", wx.OK|wx.ICON_ERROR) |
6 | 3799 |
message.ShowModal() |
3800 |
message.Destroy() |
|
3801 |
event.Veto() |
|
3802 |
elif value.upper() in [var["Name"].upper() for var in self.Values if var != self.Table.data[row]]: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3803 |
message = wx.MessageDialog(self, "A variable with \"%s\" as name exists in this pou!"%value, "Error", wx.OK|wx.ICON_ERROR) |
6 | 3804 |
message.ShowModal() |
3805 |
message.Destroy() |
|
3806 |
event.Veto() |
|
3807 |
else: |
|
58 | 3808 |
self.SaveValues(False) |
3809 |
old_value = self.Table.GetOldValue() |
|
3810 |
if old_value != "": |
|
121 | 3811 |
self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value) |
58 | 3812 |
self.Controler.BufferProject() |
121 | 3813 |
self.ParentWindow.RefreshEditor(variablepanel = False) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3814 |
self.ParentWindow.RefreshTitle() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3815 |
self.ParentWindow.RefreshEditMenu() |
6 | 3816 |
event.Skip() |
3817 |
else: |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3818 |
self.SaveValues() |
107 | 3819 |
if colname == "Class": |
3820 |
self.Table.ResetView(self.VariablesGrid) |
|
6 | 3821 |
event.Skip() |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3822 |
|
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3823 |
def OnVariablesGridEditorShown(self, event): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3824 |
row, col = event.GetRow(), event.GetCol() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3825 |
if self.Table.GetColLabelValue(col) == "Type": |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3826 |
type_menu = wx.Menu(title='') |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3827 |
base_menu = wx.Menu(title='') |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3828 |
for base_type in self.Controler.GetBaseTypes(): |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3829 |
new_id = wx.NewId() |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3830 |
AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3831 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3832 |
type_menu.AppendMenu(wx.NewId(), "Base Types", base_menu) |
125
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3833 |
datatype_menu = wx.Menu(title='') |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3834 |
for datatype in self.Controler.GetDataTypes(basetypes = False): |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3835 |
new_id = wx.NewId() |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3836 |
AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3837 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
394d9f168258
Adding support for execution order in PLCGenerator
lbessard
parents:
122
diff
changeset
|
3838 |
type_menu.AppendMenu(wx.NewId(), "User Data Types", datatype_menu) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3839 |
functionblock_menu = wx.Menu(title='') |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3840 |
for functionblock_type in self.Controler.GetFunctionBlockTypes(): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3841 |
new_id = wx.NewId() |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3842 |
AppendMenu(functionblock_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3843 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
108
diff
changeset
|
3844 |
type_menu.AppendMenu(wx.NewId(), "Function Block Types", functionblock_menu) |
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3845 |
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3846 |
self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize()) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3847 |
event.Veto() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3848 |
else: |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3849 |
event.Skip() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3850 |
|
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3851 |
def GetVariableTypeFunction(self, base_type): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3852 |
def VariableTypeFunction(event): |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3853 |
row = self.VariablesGrid.GetGridCursorRow() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3854 |
self.Table.SetValueByName(row, "Type", base_type) |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3855 |
self.Table.ResetView(self.VariablesGrid) |
98 | 3856 |
self.SaveValues(False) |
121 | 3857 |
self.ParentWindow.RefreshEditor(variablepanel = False) |
98 | 3858 |
self.Controler.BufferProject() |
3859 |
self.ParentWindow.RefreshTitle() |
|
3860 |
self.ParentWindow.RefreshEditMenu() |
|
68
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3861 |
event.Skip() |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3862 |
return VariableTypeFunction |
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3863 |
|
66308e07402c
Adding support for allowing declarations of function block into POU interface
lbessard
parents:
67
diff
changeset
|
3864 |
def OnVariablesGridCellLeftClick(self, event): |
211
ac7ba3dc027b
Bug fixed with Drag and Drop of FunctionBlocks from Variable Panel
lbessard
parents:
210
diff
changeset
|
3865 |
row = event.GetRow() |
ac7ba3dc027b
Bug fixed with Drag and Drop of FunctionBlocks from Variable Panel
lbessard
parents:
210
diff
changeset
|
3866 |
if event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit"): |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3867 |
row = event.GetRow() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3868 |
var_name = self.Table.GetValueByName(row, "Name") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3869 |
var_class = self.Table.GetValueByName(row, "Class") |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3870 |
var_type = self.Table.GetValueByName(row, "Type") |
121 | 3871 |
data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName))) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3872 |
dragSource = wx.DropSource(self.VariablesGrid) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3873 |
dragSource.SetData(data) |
135 | 3874 |
dragSource.DoDragDrop() |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3875 |
event.Skip() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3876 |
|
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3877 |
def OnVariablesGridSelectCell(self, event): |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
3878 |
wx.CallAfter(self.RefreshButtons) |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3879 |
event.Skip() |
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3880 |
|
12 | 3881 |
def MoveValue(self, value_index, move): |
3882 |
new_index = max(0, min(value_index + move, len(self.Values) - 1)) |
|
3883 |
if new_index != value_index: |
|
3884 |
self.Values.insert(new_index, self.Values.pop(value_index)) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
3885 |
self.RefreshValues() |
12 | 3886 |
self.VariablesGrid.SetGridCursor(new_index, self.VariablesGrid.GetGridCursorCol()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
3887 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
3888 |
self.RefreshValues() |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3889 |
self.SaveValues() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3890 |
|
0 | 3891 |
def RefreshValues(self): |
37
256eedd275d0
Adding support for disable interface variable change if a POU is used
lbessard
parents:
28
diff
changeset
|
3892 |
if len(self.Table.data) > 0: |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3893 |
self.VariablesGrid.SetGridCursor(0, 1) |
0 | 3894 |
data = [] |
80 | 3895 |
for num, variable in enumerate(self.Values): |
0 | 3896 |
if variable["Class"] in self.ClassList: |
80 | 3897 |
variable["Number"] = num + 1 |
0 | 3898 |
data.append(variable) |
3899 |
self.Table.SetData(data) |
|
3900 |
self.Table.ResetView(self.VariablesGrid) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3901 |
|
58 | 3902 |
def SaveValues(self, buffer = True): |
121 | 3903 |
words = self.TagName.split("::") |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3904 |
if self.ElementType == "config": |
121 | 3905 |
self.Controler.SetConfigurationGlobalVars(words[1], self.Values) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3906 |
elif self.ElementType == "resource": |
121 | 3907 |
self.Controler.SetConfigurationResourceGlobalVars(words[1], words[2], self.Values) |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3908 |
else: |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3909 |
if self.ReturnType.IsEnabled(): |
121 | 3910 |
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection()) |
3911 |
self.Controler.SetPouInterfaceVars(words[1], self.Values) |
|
58 | 3912 |
if buffer: |
3913 |
self.Controler.BufferProject() |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3914 |
self.ParentWindow.RefreshTitle() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
82
diff
changeset
|
3915 |
self.ParentWindow.RefreshEditMenu() |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
46
diff
changeset
|
3916 |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3917 |
def AddVariableError(self, infos): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3918 |
if isinstance(infos[0], TupleType): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3919 |
for i in xrange(*infos[0]): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3920 |
self.Table.AddError((i,) + infos[1:]) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3921 |
else: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3922 |
self.Table.AddError(infos) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3923 |
self.Table.ResetView(self.VariablesGrid) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3924 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3925 |
def ClearErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3926 |
self.Table.ClearErrors() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3927 |
self.Table.ResetView(self.VariablesGrid) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
223
diff
changeset
|
3928 |
|
213 | 3929 |
UPPER_DIV = lambda x, y: (x / y) + {True : 0, False : 1}[(x % y) == 0] |
3930 |
||
3931 |
class GraphicPrintout(wx.Printout): |
|
3932 |
def __init__(self, viewer, page_size, margins, preview = False): |
|
3933 |
wx.Printout.__init__(self) |
|
3934 |
self.Viewer = viewer |
|
3935 |
self.PageSize = page_size |
|
221 | 3936 |
if self.PageSize[0] == 0 or self.PageSize[1] == 0: |
3937 |
self.PageSize = (1050, 1485) |
|
213 | 3938 |
self.Preview = preview |
3939 |
self.Margins = margins |
|
221 | 3940 |
self.FontSize = 5 |
3941 |
self.TextMargin = 3 |
|
213 | 3942 |
|
3943 |
maxx, maxy = viewer.GetMaxSize() |
|
221 | 3944 |
self.PageGrid = (UPPER_DIV(maxx, self.PageSize[0]), |
3945 |
UPPER_DIV(maxy, self.PageSize[1])) |
|
213 | 3946 |
|
3947 |
def GetPageNumber(self): |
|
3948 |
return self.PageGrid[0] * self.PageGrid[1] |
|
3949 |
||
3950 |
def HasPage(self, page): |
|
3951 |
return page <= self.GetPageNumber() |
|
3952 |
||
3953 |
def GetPageInfo(self): |
|
3954 |
page_number = self.GetPageNumber() |
|
3955 |
return (1, page_number, 1, page_number) |
|
3956 |
||
3957 |
def OnBeginDocument(self, startPage, endPage): |
|
3958 |
dc = self.GetDC() |
|
3959 |
if not self.Preview and isinstance(dc, wx.PostScriptDC): |
|
3960 |
dc.SetResolution(720) |
|
3961 |
super(GraphicPrintout, self).OnBeginDocument(startPage, endPage) |
|
3962 |
||
3963 |
def OnPrintPage(self, page): |
|
3964 |
dc = self.GetDC() |
|
221 | 3965 |
dc.SetUserScale(1.0, 1.0) |
3966 |
dc.SetDeviceOrigin(0, 0) |
|
213 | 3967 |
dc.printing = not self.Preview |
3968 |
||
3969 |
# Get the size of the DC in pixels |
|
3970 |
ppiPrinterX, ppiPrinterY = self.GetPPIPrinter() |
|
3971 |
ppiScreenX, ppiScreenY = self.GetPPIScreen() |
|
3972 |
pw, ph = self.GetPageSizePixels() |
|
3973 |
dw, dh = dc.GetSizeTuple() |
|
3974 |
Xscale = (float(dw) * float(ppiPrinterX)) / (float(pw) * 25.4) |
|
3975 |
Yscale = (float(dh) * float(ppiPrinterY)) / (float(ph) * 25.4) |
|
3976 |
||
221 | 3977 |
fontsize = self.FontSize * Yscale |
3978 |
text_margin = self.TextMargin * Yscale |
|
3979 |
||
213 | 3980 |
margin_left = self.Margins[0].x * Xscale |
3981 |
margin_top = self.Margins[0].y * Yscale |
|
3982 |
area_width = dw - self.Margins[1].x * Xscale - margin_left |
|
3983 |
area_height = dh - self.Margins[1].y * Yscale - margin_top |
|
3984 |
||
3985 |
dc.SetPen(wx.BLACK_PEN) |
|
3986 |
dc.SetBrush(wx.TRANSPARENT_BRUSH) |
|
3987 |
dc.DrawRectangle(margin_left, margin_top, area_width, area_height) |
|
3988 |
||
221 | 3989 |
dc.SetFont(wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) |
213 | 3990 |
dc.SetTextForeground(wx.BLACK) |
3991 |
block_name = " - ".join(self.Viewer.GetTagName().split("::")[1:]) |
|
3992 |
text_width, text_height = dc.GetTextExtent(block_name) |
|
3993 |
dc.DrawText(block_name, margin_left, margin_top - text_height - self.TextMargin) |
|
3994 |
dc.DrawText("Page: %d" % page, margin_left, margin_top + area_height + self.TextMargin) |
|
3995 |
||
3996 |
# Calculate the position on the DC for centering the graphic |
|
3997 |
posX = area_width * ((page - 1) % self.PageGrid[0]) |
|
3998 |
posY = area_height * ((page - 1) / self.PageGrid[0]) |
|
3999 |
||
4000 |
scaleX = float(area_width) / float(self.PageSize[0]) |
|
4001 |
scaleY = float(area_height) / float(self.PageSize[1]) |
|
4002 |
scale = min(scaleX, scaleY) |
|
4003 |
||
4004 |
# Set the scale and origin |
|
4005 |
dc.SetDeviceOrigin(-posX + margin_left, -posY + margin_top) |
|
221 | 4006 |
dc.SetClippingRegion(posX, posY, self.PageSize[0] * scale, self.PageSize[1] * scale) |
213 | 4007 |
dc.SetUserScale(scale, scale) |
4008 |
||
4009 |
#------------------------------------------- |
|
4010 |
||
4011 |
self.Viewer.DoDrawing(dc, True) |
|
4012 |
||
4013 |
return True |
|
4014 |
||
0 | 4015 |
#------------------------------------------------------------------------------- |
4016 |
# Exception Handler |
|
4017 |
#------------------------------------------------------------------------------- |
|
4018 |
||
4019 |
Max_Traceback_List_Size = 20 |
|
4020 |
||
4021 |
def Display_Exception_Dialog(e_type,e_value,e_tb): |
|
4022 |
trcbck_lst = [] |
|
4023 |
for i,line in enumerate(traceback.extract_tb(e_tb)): |
|
4024 |
trcbck = " " + str(i+1) + ". " |
|
4025 |
if line[0].find(os.getcwd()) == -1: |
|
4026 |
trcbck += "file : " + str(line[0]) + ", " |
|
4027 |
else: |
|
4028 |
trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
|
4029 |
trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
|
4030 |
trcbck_lst.append(trcbck) |
|
4031 |
||
4032 |
# Allow clicking.... |
|
4033 |
cap = wx.Window_GetCapture() |
|
4034 |
if cap: |
|
4035 |
cap.ReleaseMouse() |
|
4036 |
||
4037 |
dlg = wx.SingleChoiceDialog(None, |
|
4038 |
""" |
|
4039 |
An error happens. |
|
4040 |
||
4041 |
Click on OK for saving an error report. |
|
4042 |
||
4043 |
Please contact LOLITech at: |
|
4044 |
+33 (0)3 29 52 95 67 |
|
4045 |
bugs_PLCOpenEditor@lolitech.fr |
|
4046 |
||
4047 |
||
4048 |
Error: |
|
4049 |
""" + |
|
4050 |
str(e_type) + " : " + str(e_value), |
|
4051 |
"Error", |
|
4052 |
trcbck_lst) |
|
4053 |
try: |
|
4054 |
res = (dlg.ShowModal() == wx.ID_OK) |
|
4055 |
finally: |
|
4056 |
dlg.Destroy() |
|
4057 |
||
4058 |
return res |
|
4059 |
||
4060 |
def Display_Error_Dialog(e_value): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
4061 |
message = wx.MessageDialog(None, str(e_value), "Error", wx.OK|wx.ICON_ERROR) |
0 | 4062 |
message.ShowModal() |
4063 |
message.Destroy() |
|
4064 |
||
4065 |
def get_last_traceback(tb): |
|
4066 |
while tb.tb_next: |
|
4067 |
tb = tb.tb_next |
|
4068 |
return tb |
|
4069 |
||
4070 |
||
4071 |
def format_namespace(d, indent=' '): |
|
4072 |
return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
|
4073 |
||
4074 |
||
4075 |
ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
|
4076 |
||
65
cb6bed0720f0
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
64
diff
changeset
|
4077 |
def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
0 | 4078 |
|
4079 |
def handle_exception(e_type, e_value, e_traceback): |
|
4080 |
traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
|
4081 |
last_tb = get_last_traceback(e_traceback) |
|
4082 |
ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
|
4083 |
if str(e_value).startswith("!!!"): |
|
4084 |
Display_Error_Dialog(e_value) |
|
4085 |
elif ex not in ignored_exceptions: |
|
4086 |
result = Display_Exception_Dialog(e_type,e_value,e_traceback) |
|
4087 |
if result: |
|
4088 |
ignored_exceptions.append(ex) |
|
4089 |
info = { |
|
4090 |
'app-title' : wx.GetApp().GetAppName(), # app_title |
|
4091 |
'app-version' : app_version, |
|
4092 |
'wx-version' : wx.VERSION_STRING, |
|
4093 |
'wx-platform' : wx.Platform, |
|
4094 |
'python-version' : platform.python_version(), #sys.version.split()[0], |
|
4095 |
'platform' : platform.platform(), |
|
4096 |
'e-type' : e_type, |
|
4097 |
'e-value' : e_value, |
|
4098 |
'date' : time.ctime(), |
|
4099 |
'cwd' : os.getcwd(), |
|
4100 |
} |
|
4101 |
if e_traceback: |
|
4102 |
info['traceback'] = ''.join(traceback.format_tb(e_traceback)) + '%s: %s' % (e_type, e_value) |
|
4103 |
last_tb = get_last_traceback(e_traceback) |
|
4104 |
exception_locals = last_tb.tb_frame.f_locals # the locals at the level of the stack trace where the exception actually occurred |
|
4105 |
info['locals'] = format_namespace(exception_locals) |
|
4106 |
if 'self' in exception_locals: |
|
4107 |
info['self'] = format_namespace(exception_locals['self'].__dict__) |
|
4108 |
||
4109 |
output = open(path+os.sep+"bug_report_"+info['date'].replace(':','-').replace(' ','_')+".txt",'w') |
|
4110 |
lst = info.keys() |
|
4111 |
lst.sort() |
|
4112 |
for a in lst: |
|
4113 |
output.write(a+":\n"+str(info[a])+"\n\n") |
|
4114 |
||
4115 |
#sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
|
4116 |
sys.excepthook = handle_exception |
|
4117 |
||
4118 |
if __name__ == '__main__': |
|
92
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4119 |
def usage(): |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4120 |
print "\nUsage of PLCOpenEditor.py :" |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4121 |
print "\n %s [Filepath]\n"%sys.argv[0] |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4122 |
|
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4123 |
try: |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4124 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4125 |
except getopt.GetoptError: |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4126 |
# print help information and exit: |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4127 |
usage() |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4128 |
sys.exit(2) |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4129 |
|
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4130 |
for o, a in opts: |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4131 |
if o in ("-h", "--help"): |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4132 |
usage() |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4133 |
sys.exit() |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4134 |
|
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4135 |
fileOpen = None |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4136 |
if len(args) > 1: |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4137 |
usage() |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4138 |
sys.exit() |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4139 |
elif len(args) == 1: |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4140 |
fileOpen = args[0] |
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4141 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
4142 |
app = wx.PySimpleApp() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
58
diff
changeset
|
4143 |
wx.InitAllImageHandlers() |
0 | 4144 |
|
4145 |
# Install a exception handle for bug reports |
|
65
cb6bed0720f0
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
64
diff
changeset
|
4146 |
AddExceptHook(os.getcwd(),__version__) |
0 | 4147 |
|
92
76d5001393df
Adding support for refreshing PLCOpenEditor block list
lbessard
parents:
90
diff
changeset
|
4148 |
frame = PLCOpenEditor(None, fileOpen=fileOpen) |
0 | 4149 |
|
4150 |
frame.Show() |
|
4151 |
app.MainLoop() |
|
4152 |