author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Sun, 17 Jul 2022 17:49:34 +0200 | |
changeset 3547 | 8a9a7d180b93 |
parent 3388 | 6cde1a3ded58 |
child 3583 | 27e7679ddb99 |
permissions | -rw-r--r-- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1 |
#!/usr/bin/env python |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
3 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
6 |
# |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
8 |
# |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
10 |
# |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
15 |
# |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
19 |
# GNU General Public License for more details. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
20 |
# |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
24 |
|
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
25 |
|
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
26 |
from __future__ import absolute_import |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
27 |
from __future__ import division |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
28 |
import re |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
29 |
from builtins import str as text |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
30 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
31 |
import wx |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
32 |
import wx.grid |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
33 |
import wx.lib.buttons |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
34 |
from six import string_types |
2432
dbc065a2f7a5
python3 support: pylint, W1613 # (xrange-builtin) xrange built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2301
diff
changeset
|
35 |
from six.moves import xrange |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
36 |
|
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
37 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
38 |
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType |
1953
5736d25bb393
PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents:
1951
diff
changeset
|
39 |
from plcopen.VariableInfoCollector import _VariableInfos |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
40 |
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
41 |
from dialogs.ArrayTypeDialog import ArrayTypeDialog |
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
42 |
from controls.CustomGrid import CustomGrid |
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
43 |
from controls.CustomTable import CustomTable |
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
44 |
from controls.LocationCellEditor import LocationCellEditor |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
45 |
from util.BitmapLibrary import GetBitmap |
1834
cd42b426028b
fix ungrouped imports from package X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1833
diff
changeset
|
46 |
from util.TranslationCatalogs import NoTranslate |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
47 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
48 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
49 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
50 |
# Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
51 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
52 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
53 |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
54 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
55 |
TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
56 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
57 |
] = range(10) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
58 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
59 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
60 |
def GetVariableTableColnames(location): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1760
diff
changeset
|
61 |
_ = NoTranslate |
1772
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
62 |
cols = ["#", |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
63 |
_("Name"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
64 |
_("Class"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
65 |
_("Type"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
66 |
_("Location"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
67 |
_("Initial Value"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
68 |
_("Option"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
69 |
_("Documentation")] |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
70 |
if not location: |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
71 |
del cols[4] # remove 'Location' column |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
72 |
return cols |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
73 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
74 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
75 |
def GetOptions(constant=True, retain=True, non_retain=True): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1760
diff
changeset
|
76 |
_ = NoTranslate |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
77 |
options = [""] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
78 |
if constant: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
79 |
options.append(_("Constant")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
80 |
if retain: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
81 |
options.append(_("Retain")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
82 |
if non_retain: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
83 |
options.append(_("Non-Retain")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
84 |
return options |
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
85 |
|
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
86 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
87 |
def GetFilterChoiceTransfer(): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1760
diff
changeset
|
88 |
_ = NoTranslate |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
89 |
return {_("All"): _("All"), _("Interface"): _("Interface"), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
90 |
_(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
91 |
_(" External"): _("External"), _("Variables"): _("Variables"), _(" Local"): _("Local"), |
1760
ed2e2afb9573
clean-up: fix PEP8 E262 inline comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1758
diff
changeset
|
92 |
_(" Temp"): _("Temp"), _("Global"): _("Global")} # , _("Access") : _("Access")} |
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
93 |
|
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
94 |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
95 |
CheckOptionForClass = { |
1774
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
96 |
"Local": lambda x: x, |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
97 |
"Temp": lambda x: "", |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
98 |
"Input": lambda x: {"Retain": "Retain", "Non-Retain": "Non-Retain"}.get(x, ""), |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
99 |
"InOut": lambda x: "", |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
100 |
"Output": lambda x: {"Retain": "Retain", "Non-Retain": "Non-Retain"}.get(x, ""), |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
101 |
"Global": lambda x: {"Constant": "Constant", "Retain": "Retain"}.get(x, ""), |
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
102 |
"External": lambda x: {"Constant": "Constant"}.get(x, "") |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
103 |
} |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
104 |
|
2439
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
105 |
LOCATION_MODEL = re.compile(r"((?:%[IQM](?:\*|(?:[XBWLD]?[0-9]+(?:\.[0-9]+)*)))?)$") |
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
106 |
LOCATION_MODEL_SET = re.compile(r"((?:%[IQM](?:[XBWLD]?[0-9]+(?:\.[0-9]+)*))?)$") |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
107 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
108 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
109 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
110 |
# Variables Panel Table |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
111 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
112 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
113 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
114 |
class VariableTable(CustomTable): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
115 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
116 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
117 |
A custom wx.grid.Grid Table using user supplied data |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
118 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
119 |
def __init__(self, parent, data, colnames): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
120 |
# The base class must be initialized *first* |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
121 |
CustomTable.__init__(self, parent, data, colnames) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
122 |
self.old_value = None |
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
123 |
self.OPTIONS_DICT = dict([(_(option), option) |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
124 |
for option in GetOptions()]) |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
125 |
self.VARIABLE_CLASSES_DICT = dict([(_(_class), _class) |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
126 |
for _class in GetFilterChoiceTransfer().itervalues()]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
127 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
128 |
def GetValueByName(self, row, colname): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
129 |
if row < self.GetNumberRows(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
130 |
return getattr(self.data[row], colname) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
131 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
132 |
def SetValueByName(self, row, colname, value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
133 |
if row < self.GetNumberRows(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
134 |
setattr(self.data[row], colname, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
135 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
136 |
def GetValue(self, row, col): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
137 |
if row < self.GetNumberRows(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
138 |
if col == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
139 |
return self.data[row].Number |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
140 |
colname = self.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
141 |
if colname == "Initial Value": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
142 |
colname = "InitialValue" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
143 |
value = getattr(self.data[row], colname, "") |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
144 |
if colname == "Type" and isinstance(value, tuple): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
145 |
if value[0] == "array": |
1833
2269739dd098
fix unnecessary lambda and enable corresponding pylint check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
146 |
return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1]) |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
147 |
if not isinstance(value, string_types): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
148 |
value = str(value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
149 |
if colname in ["Class", "Option"]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
150 |
return _(value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
151 |
return value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
152 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
153 |
def SetValue(self, row, col, value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
154 |
if col < len(self.colnames): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
155 |
colname = self.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
156 |
if colname == "Name": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
157 |
self.old_value = getattr(self.data[row], colname) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
158 |
elif colname == "Class": |
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
159 |
value = self.VARIABLE_CLASSES_DICT[value] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
160 |
self.SetValueByName(row, "Option", CheckOptionForClass[value](self.GetValueByName(row, "Option"))) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
161 |
if value == "External": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
162 |
self.SetValueByName(row, "InitialValue", "") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
163 |
elif colname == "Option": |
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
164 |
value = self.OPTIONS_DICT[value] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
165 |
elif colname == "Initial Value": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
166 |
colname = "InitialValue" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
167 |
setattr(self.data[row], colname, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
168 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
169 |
def GetOldValue(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
170 |
return self.old_value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
171 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
172 |
def _GetRowEdit(self, row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
173 |
row_edit = self.GetValueByName(row, "Edit") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
174 |
var_type = self.Parent.GetTagName() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
175 |
bodytype = self.Parent.Controler.GetEditedElementBodyType(var_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
176 |
if bodytype in ["ST", "IL"]: |
1752
d14ff9d7eb76
clean-up: fix PEP8 E703 statement ends with a semicolon
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
177 |
row_edit = True |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
178 |
return row_edit |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
179 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
180 |
def _updateColAttrs(self, grid): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
181 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
182 |
wx.grid.Grid -> update the column attributes to add the |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
183 |
appropriate renderer given the column name. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
184 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
185 |
Otherwise default to the default renderer. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
186 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
187 |
for row in range(self.GetNumberRows()): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
188 |
var_class = self.GetValueByName(row, "Class") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
189 |
var_type = self.GetValueByName(row, "Type") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
190 |
row_highlights = self.Highlights.get(row, {}) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
191 |
for col in range(self.GetNumberCols()): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
192 |
editor = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
193 |
renderer = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
194 |
colname = self.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
195 |
if self.Parent.Debug: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
196 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
197 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
198 |
if colname == "Option": |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
199 |
options = GetOptions(constant=var_class in ["Local", "External", "Global"], |
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
200 |
retain=self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"], |
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
201 |
non_retain=self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
202 |
if len(options) > 1: |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
203 |
editor = wx.grid.GridCellChoiceEditor(map(_, options)) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
204 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
205 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
206 |
elif col != 0 and self._GetRowEdit(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
207 |
grid.SetReadOnly(row, col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
208 |
if colname == "Name": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
209 |
editor = wx.grid.GridCellTextEditor() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
210 |
renderer = wx.grid.GridCellStringRenderer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
211 |
elif colname == "Initial Value": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
212 |
if var_class not in ["External", "InOut"]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
213 |
if self.Parent.Controler.IsEnumeratedType(var_type): |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
214 |
editor = wx.grid.GridCellChoiceEditor([""] + self.Parent.Controler.GetEnumeratedDataValues(var_type)) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
215 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
216 |
editor = wx.grid.GridCellTextEditor() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
217 |
renderer = wx.grid.GridCellStringRenderer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
218 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
219 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
220 |
elif colname == "Location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
221 |
if var_class in ["Local", "Global"] and self.Parent.Controler.IsLocatableType(var_type): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
222 |
editor = LocationCellEditor(self, self.Parent.Controler) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
223 |
renderer = wx.grid.GridCellStringRenderer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
224 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
225 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
226 |
elif colname == "Class": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
227 |
if len(self.Parent.ClassList) == 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
228 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
229 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
230 |
excluded = [] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
231 |
if self.Parent.IsFunctionBlockType(var_type): |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
232 |
excluded.extend(["Local", "Temp"]) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
233 |
editor = wx.grid.GridCellChoiceEditor([_(choice) for choice in self.Parent.ClassList if choice not in excluded]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
234 |
elif colname != "Documentation": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
235 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
236 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
237 |
grid.SetCellEditor(row, col, editor) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
238 |
grid.SetCellRenderer(row, col, renderer) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
239 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
240 |
if colname == "Location" and LOCATION_MODEL.match(self.GetValueByName(row, colname)) is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
241 |
highlight_colours = ERROR_HIGHLIGHT |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
242 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
243 |
highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
244 |
grid.SetCellBackgroundColour(row, col, highlight_colours[0]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
245 |
grid.SetCellTextColour(row, col, highlight_colours[1]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
246 |
self.ResizeRow(grid, row) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
247 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
248 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
249 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
250 |
# Variable Panel Drop Target |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
251 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
252 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
253 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
254 |
class VariableDropTarget(wx.TextDropTarget): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
255 |
''' |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
256 |
This allows dragging a variable location from somewhere to the Location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
257 |
column of a variable row. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
258 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
259 |
The drag source should be a TextDataObject containing a Python tuple like: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
260 |
('%ID0.0.0', 'location', 'REAL') |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
261 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
262 |
c_ext/CFileEditor.py has an example of this (you can drag a C extension |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
263 |
variable to the Location column of the variable panel). |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
264 |
''' |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
265 |
def __init__(self, parent): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
266 |
wx.TextDropTarget.__init__(self) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
267 |
self.ParentWindow = parent |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
268 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
269 |
def OnDropText(self, x, y, data): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
270 |
self.ParentWindow.ParentWindow.Select() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
271 |
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
272 |
col = self.ParentWindow.VariablesGrid.XToCol(x) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
273 |
row = self.ParentWindow.VariablesGrid.YToRow(y) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
274 |
message = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
275 |
element_type = self.ParentWindow.ElementType |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
276 |
try: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
277 |
values = eval(data) |
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1776
diff
changeset
|
278 |
except Exception: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
279 |
message = _("Invalid value \"%s\" for variable grid element") % data |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
280 |
values = None |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
281 |
if not isinstance(values, tuple): |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
282 |
message = _("Invalid value \"%s\" for variable grid element") % data |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
283 |
values = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
284 |
if values is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
285 |
if col != wx.NOT_FOUND and row != wx.NOT_FOUND: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
286 |
colname = self.ParentWindow.Table.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
287 |
if colname == "Location" and values[1] == "location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
288 |
if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
289 |
message = _("Can't give a location to a function block instance") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
290 |
elif self.ParentWindow.Table.GetValueByName(row, "Class") not in ["Local", "Global"]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
291 |
message = _("Can only give a location to local or global variables") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
292 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
293 |
location = values[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
294 |
variable_type = self.ParentWindow.Table.GetValueByName(row, "Type") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
295 |
base_type = self.ParentWindow.Controler.GetBaseType(variable_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
296 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
297 |
if values[2] is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
298 |
base_location_type = self.ParentWindow.Controler.GetBaseType(values[2]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
299 |
if values[2] != variable_type and base_type != base_location_type: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
300 |
message = _("Incompatible data types between \"{a1}\" and \"{a2}\"").\ |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
301 |
format(a1=values[2], a2=variable_type) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
302 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
303 |
if message is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
304 |
if not location.startswith("%"): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
305 |
if location[0].isdigit() and base_type != "BOOL": |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
306 |
message = _("Incompatible size of data between \"%s\" and \"BOOL\"") % location |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
307 |
elif location[0] not in LOCATIONDATATYPES: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
308 |
message = _("Unrecognized data size \"%s\"") % location[0] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
309 |
elif base_type not in LOCATIONDATATYPES[location[0]]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
310 |
message = _("Incompatible size of data between \"{a1}\" and \"{a2}\"").\ |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
311 |
format(a1=location, a2=variable_type) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
312 |
else: |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
313 |
dialog = wx.SingleChoiceDialog( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
314 |
self.ParentWindow.ParentWindow.ParentWindow, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
315 |
_("Select a variable class:"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
316 |
_("Variable class"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
317 |
[_("Input"), _("Output"), _("Memory")], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
318 |
wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
319 |
if dialog.ShowModal() == wx.ID_OK: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
320 |
selected = dialog.GetSelection() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
321 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
322 |
selected = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
323 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
324 |
if selected is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
325 |
return |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
326 |
if selected == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
327 |
location = "%I" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
328 |
elif selected == 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
329 |
location = "%Q" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
330 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
331 |
location = "%M" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
332 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
333 |
if message is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
334 |
self.ParentWindow.Table.SetValue(row, col, location) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
335 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
336 |
self.ParentWindow.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
337 |
elif colname == "Initial Value" and values[1] == "Constant": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
338 |
if not self.ParentWindow.Table.GetValueByName(row, "Edit"): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
339 |
message = _("Can't set an initial value to a function block instance") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
340 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
341 |
self.ParentWindow.Table.SetValue(row, col, values[0]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
342 |
self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
343 |
self.ParentWindow.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
344 |
elif (element_type not in ["config", "resource", "function"] and values[1] == "Global" and |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
345 |
self.ParentWindow.Filter in ["All", "Interface", "External"] or |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
346 |
element_type != "function" and values[1] in ["location", "NamedConstant"]): |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
347 |
if values[1] in ["location", "NamedConstant"]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
348 |
var_name = values[3] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
349 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
350 |
var_name = values[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
351 |
tagname = self.ParentWindow.GetTagName() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
352 |
dlg = wx.TextEntryDialog( |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
353 |
self.ParentWindow.ParentWindow.ParentWindow, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
354 |
_("Confirm or change variable name"), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
355 |
_('Variable Drop'), var_name) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
356 |
dlg.SetValue(var_name) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
357 |
var_name = dlg.GetValue() if dlg.ShowModal() == wx.ID_OK else None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
358 |
dlg.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
359 |
if var_name is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
360 |
return |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
361 |
elif var_name.upper() in [ |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
362 |
name.upper() for name in |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
363 |
self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
364 |
message = _("\"%s\" pou already exists!") % var_name |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
365 |
elif not var_name.upper() in [ |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
366 |
name.upper() |
1764
d5df428640ff
clean-up: fix PEP8 E502 the backslash is redundant between brackets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
367 |
for name in self.ParentWindow.Controler. |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
368 |
GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
369 |
var_infos = self.ParentWindow.DefaultValue.copy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
370 |
var_infos.Name = var_name |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
371 |
var_infos.Type = values[2] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
372 |
var_infos.Documentation = values[4] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
373 |
if values[1] == "location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
374 |
location = values[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
375 |
if not location.startswith("%"): |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
376 |
dialog = wx.SingleChoiceDialog( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
377 |
self.ParentWindow.ParentWindow.ParentWindow, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
378 |
_("Select a variable class:"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
379 |
_("Variable class"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
380 |
[_("Input"), _("Output"), _("Memory")], |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
381 |
wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
382 |
if dialog.ShowModal() == wx.ID_OK: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
383 |
selected = dialog.GetSelection() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
384 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
385 |
selected = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
386 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
387 |
if selected is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
388 |
return |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
389 |
if selected == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
390 |
location = "%I" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
391 |
elif selected == 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
392 |
location = "%Q" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
393 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
394 |
location = "%M" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
395 |
if element_type == "functionBlock": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
396 |
configs = self.ParentWindow.Controler.GetProjectConfigNames( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
397 |
self.ParentWindow.Debug) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
398 |
if len(configs) == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
399 |
return |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
400 |
if not var_name.upper() in [ |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
401 |
name.upper() for name in |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
402 |
self.ParentWindow.Controler.GetConfigurationVariableNames(configs[0])]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
403 |
self.ParentWindow.Controler.AddConfigurationGlobalVar( |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
404 |
configs[0], values[2], var_name, location, "") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
405 |
var_infos.Class = "External" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
406 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
407 |
if element_type == "program": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
408 |
var_infos.Class = "Local" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
409 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
410 |
var_infos.Class = "Global" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
411 |
var_infos.Location = location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
412 |
elif values[1] == "NamedConstant": |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
413 |
if element_type in ["functionBlock", "program"]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
414 |
var_infos.Class = "Local" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
415 |
var_infos.InitialValue = values[0] |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
416 |
else: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
417 |
return |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
418 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
419 |
var_infos.Class = "External" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
420 |
var_infos.Number = len(self.ParentWindow.Values) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
421 |
self.ParentWindow.Values.append(var_infos) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
422 |
self.ParentWindow.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
423 |
self.ParentWindow.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
424 |
else: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
425 |
message = _("\"%s\" element for this pou already exists!") % var_name |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
426 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
427 |
if message is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
428 |
wx.CallAfter(self.ShowMessage, message) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
429 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
430 |
def ShowMessage(self, message): |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
431 |
message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK | wx.ICON_ERROR) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
432 |
message.ShowModal() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
433 |
message.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
434 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
435 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
436 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
437 |
# Variable Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
438 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
439 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
440 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
441 |
class VariablePanel(wx.Panel): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
442 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
443 |
def __init__(self, parent, window, controler, element_type, debug=False): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
444 |
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
445 |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
446 |
self.VARIABLE_CHOICES_DICT = dict([(_(_class), _class) for |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
447 |
_class in GetFilterChoiceTransfer().iterkeys()]) |
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
448 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
449 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=0) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
450 |
self.MainSizer.AddGrowableCol(0) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
451 |
self.MainSizer.AddGrowableRow(1) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
452 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
453 |
controls_sizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=5) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
454 |
controls_sizer.AddGrowableCol(5) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
455 |
controls_sizer.AddGrowableRow(0) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
456 |
self.MainSizer.Add(controls_sizer, border=5, flag=wx.GROW | wx.ALL) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
457 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
458 |
self.ReturnTypeLabel = wx.StaticText(self, label=_('Return Type:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
459 |
controls_sizer.Add(self.ReturnTypeLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
460 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
461 |
self.ReturnType = wx.ComboBox(self, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
462 |
size=wx.Size(145, -1), style=wx.CB_READONLY) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
463 |
self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, self.ReturnType) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
464 |
controls_sizer.Add(self.ReturnType) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
465 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
466 |
self.DescriptionLabel = wx.StaticText(self, label=_('Description:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
467 |
controls_sizer.Add(self.DescriptionLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
468 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
469 |
self.Description = wx.TextCtrl(self, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
470 |
size=wx.Size(250, -1), style=wx.TE_PROCESS_ENTER) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
471 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnDescriptionChanged, self.Description) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
472 |
self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
473 |
controls_sizer.Add(self.Description) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
474 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
475 |
class_filter_label = wx.StaticText(self, label=_('Class Filter:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
476 |
controls_sizer.Add(class_filter_label, flag=wx.ALIGN_CENTER_VERTICAL) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
477 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
478 |
self.ClassFilter = wx.ComboBox(self, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
479 |
size=wx.Size(145, -1), style=wx.CB_READONLY) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
480 |
self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, self.ClassFilter) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
481 |
controls_sizer.Add(self.ClassFilter) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
482 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
483 |
for name, bitmap, help in [ |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
484 |
("AddButton", "add_element", _("Add variable")), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
485 |
("DeleteButton", "remove_element", _("Remove variable")), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
486 |
("UpButton", "up", _("Move variable up")), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
487 |
("DownButton", "down", _("Move variable down"))]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
488 |
button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
489 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
490 |
button.SetToolTip(help) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
491 |
setattr(self, name, button) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
492 |
controls_sizer.Add(button) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
493 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
494 |
self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL | wx.HSCROLL) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
495 |
self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) |
3388
6cde1a3ded58
Fix bug when updating data in variable panel.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3303
diff
changeset
|
496 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGED, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
497 |
self.OnVariablesGridCellChange) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
498 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
499 |
self.OnVariablesGridCellLeftClick) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
500 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
501 |
self.OnVariablesGridEditorShown) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
502 |
self.MainSizer.Add(self.VariablesGrid, flag=wx.GROW) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
503 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
504 |
self.SetSizer(self.MainSizer) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
505 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
506 |
self.ParentWindow = window |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
507 |
self.Controler = controler |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
508 |
self.ElementType = element_type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
509 |
self.Debug = debug |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
510 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
511 |
self.RefreshHighlightsTimer = wx.Timer(self, -1) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
512 |
self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
513 |
self.RefreshHighlightsTimer) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
514 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
515 |
self.Filter = "All" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
516 |
self.FilterChoices = [] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
517 |
self.FilterChoiceTransfer = GetFilterChoiceTransfer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
518 |
|
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
519 |
self.DefaultValue = _VariableInfos("LocalVar0", "", "", "", "", True, "", DefaultType, ([], []), 0) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
520 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
521 |
if element_type in ["config", "resource"]: |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
522 |
self.DefaultTypes = {"All": "Global"} |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
523 |
else: |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
524 |
self.DefaultTypes = {"All": "Local", "Interface": "Input", "Variables": "Local"} |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
525 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
526 |
if element_type in ["config", "resource"] \ |
1776
81aa8aaccdd4
clean-up: fix PEP8 E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
527 |
or element_type in ["program", "transition", "action"]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
528 |
# this is an element that can have located variables |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
529 |
self.Table = VariableTable(self, [], GetVariableTableColnames(True)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
530 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
531 |
if element_type in ["config", "resource"]: |
1760
ed2e2afb9573
clean-up: fix PEP8 E262 inline comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1758
diff
changeset
|
532 |
self.FilterChoices = ["All", "Global"] # ,"Access"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
533 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
534 |
self.FilterChoices = ["All", |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
535 |
"Interface", " Input", " Output", " InOut", " External", |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
536 |
"Variables", " Local", " Temp"] # ,"Access"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
537 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
538 |
# these condense the ColAlignements list |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
539 |
left = wx.ALIGN_LEFT |
1755
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
540 |
center = wx.ALIGN_CENTER |
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
541 |
|
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
542 |
# Num Name Class Type Loc Init Option Doc |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
543 |
self.ColSettings = { |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
544 |
"size": [40, 80, 100, 80, 110, 120, 100, 160], |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
545 |
"alignement": [center, left, left, left, left, left, left, left], |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
546 |
"fixed_size": [True, False, True, False, True, True, True, False], |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
547 |
} |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
548 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
549 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
550 |
# this is an element that cannot have located variables |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
551 |
self.Table = VariableTable(self, [], GetVariableTableColnames(False)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
552 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
553 |
if element_type == "function": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
554 |
self.FilterChoices = ["All", |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
555 |
"Interface", " Input", " Output", " InOut", |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
556 |
"Variables", " Local"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
557 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
558 |
self.FilterChoices = ["All", |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
559 |
"Interface", " Input", " Output", " InOut", " External", |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
560 |
"Variables", " Local", " Temp"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
561 |
|
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
562 |
# these condense the alignements list |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
563 |
left = wx.ALIGN_LEFT |
1755
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
564 |
center = wx.ALIGN_CENTER |
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
565 |
|
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
566 |
# Num Name Class Type Init Option Doc |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
567 |
self.ColSettings = { |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
568 |
"size": [40, 80, 100, 80, 120, 100, 160], |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
569 |
"alignement": [center, left, left, left, left, left, left], |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
570 |
"fixed_size": [True, False, True, False, True, True, False], |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
571 |
} |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
572 |
|
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
573 |
self.PanelWidthMin = sum(self.ColSettings["size"]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
574 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
575 |
self.ElementType = element_type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
576 |
self.BodyType = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
577 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
578 |
for choice in self.FilterChoices: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
579 |
self.ClassFilter.Append(_(choice)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
580 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
581 |
reverse_transfer = {} |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
582 |
for filter, choice in self.FilterChoiceTransfer.items(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
583 |
reverse_transfer[choice] = filter |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
584 |
self.ClassFilter.SetStringSelection(_(reverse_transfer[self.Filter])) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
585 |
self.RefreshTypeList() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
586 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
587 |
self.VariablesGrid.SetTable(self.Table) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
588 |
self.VariablesGrid.SetButtons({"Add": self.AddButton, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
589 |
"Delete": self.DeleteButton, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
590 |
"Up": self.UpButton, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
591 |
"Down": self.DownButton}) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
592 |
self.VariablesGrid.SetEditable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
593 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
594 |
def _AddVariable(new_row): |
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
595 |
row_content = self.DefaultValue.copy() |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
596 |
if new_row > 0: |
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
597 |
# doesn't copy values of previous var if it's non-editable (like a FB) |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
598 |
if self.Values[new_row-1].Edit: |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
599 |
row_content = self.Values[new_row-1].copy() |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
600 |
old_name = self.Values[new_row-1].Name |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
601 |
row_content.Name = self.Controler.GenerateNewName( |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
602 |
self.TagName, old_name, old_name+'%d') |
2240
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
603 |
|
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
604 |
# increment location address |
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
605 |
if row_content.Location != "" and LOCATION_MODEL_SET.match(row_content.Location): |
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
606 |
old_location = row_content.Location |
2439
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
607 |
model = re.compile(r"%[IQM][XBWLD]?(.*\.|)") |
2240
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
608 |
prefix = model.match(old_location).group(0) |
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
609 |
addr = int(re.split(model, old_location)[-1]) + 1 |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
610 |
row_content.Location = prefix + text(addr) |
2240
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
611 |
|
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
612 |
if not row_content.Class: |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
613 |
row_content.Class = self.DefaultTypes.get(self.Filter, self.Filter) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
614 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
615 |
if self.Filter == "All" and len(self.Values) > 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
616 |
self.Values.insert(new_row, row_content) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
617 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
618 |
self.Values.append(row_content) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
619 |
new_row = self.Table.GetNumberRows() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
620 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
621 |
if self.ElementType == "resource": |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
622 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
623 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
624 |
return new_row |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
625 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
626 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
627 |
def _DeleteVariable(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
628 |
if _GetRowEdit(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
629 |
self.Values.remove(self.Table.GetRow(row)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
630 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
631 |
if self.ElementType == "resource": |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
632 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
633 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
634 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
635 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
636 |
def _MoveVariable(row, move): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
637 |
if self.Filter == "All": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
638 |
new_row = max(0, min(row + move, len(self.Values) - 1)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
639 |
if new_row != row: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
640 |
self.Values.insert(new_row, self.Values.pop(row)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
641 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
642 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
643 |
return new_row |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
644 |
return row |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
645 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
646 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
647 |
def _GetRowEdit(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
648 |
row_edit = False |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
649 |
if self: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
650 |
row_edit = self.Table.GetValueByName(row, "Edit") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
651 |
bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
652 |
row_edit = row_edit or (bodytype in ["ST", "IL"]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
653 |
return row_edit |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
654 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
655 |
def _RefreshButtons(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
656 |
if self: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
657 |
table_length = len(self.Table.data) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
658 |
row_edit = True |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
659 |
row = 0 |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
660 |
if table_length > 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
661 |
row = self.VariablesGrid.GetGridCursorRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
662 |
row_edit = _GetRowEdit(row) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
663 |
self.AddButton.Enable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
664 |
self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
665 |
self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
666 |
self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
667 |
setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
668 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
669 |
panel_width = window.Parent.ScreenRect.Width - 35 |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
670 |
if panel_width > self.PanelWidthMin: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
671 |
stretch_cols_width = panel_width |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
672 |
stretch_cols_sum = 0 |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
673 |
for col in range(len(self.ColSettings["fixed_size"])): |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
674 |
if self.ColSettings["fixed_size"][col]: |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
675 |
stretch_cols_width -= self.ColSettings["size"][col] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
676 |
else: |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
677 |
stretch_cols_sum += self.ColSettings["size"][col] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
678 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
679 |
self.VariablesGrid.SetRowLabelSize(0) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
680 |
for col in range(self.Table.GetNumberCols()): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
681 |
attr = wx.grid.GridCellAttr() |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
682 |
attr.SetAlignment(self.ColSettings["alignement"][col], wx.ALIGN_CENTRE) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
683 |
self.VariablesGrid.SetColAttr(col, attr) |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
684 |
self.VariablesGrid.SetColMinimalWidth(col, self.ColSettings["size"][col]) |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
685 |
if (panel_width > self.PanelWidthMin) and not self.ColSettings["fixed_size"][col]: |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
686 |
self.VariablesGrid.SetColSize(col, int((self.ColSettings["size"][col]/stretch_cols_sum)*stretch_cols_width)) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
687 |
else: |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
688 |
self.VariablesGrid.SetColSize(col, self.ColSettings["size"][col]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
689 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
690 |
def __del__(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
691 |
self.RefreshHighlightsTimer.Stop() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
692 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
693 |
def SetTagName(self, tagname): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
694 |
self.TagName = tagname |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
695 |
self.BodyType = self.Controler.GetEditedElementBodyType(self.TagName) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
696 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
697 |
def GetTagName(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
698 |
return self.TagName |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
699 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
700 |
def IsFunctionBlockType(self, name): |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
701 |
if isinstance(name, tuple) or \ |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
702 |
self.ElementType != "function" and self.BodyType in ["ST", "IL"]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
703 |
return False |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
704 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
705 |
return self.Controler.GetBlockType(name, debug=self.Debug) is not None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
706 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
707 |
def RefreshView(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
708 |
self.PouNames = self.Controler.GetProjectPouNames(self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
709 |
returnType = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
710 |
description = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
711 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
712 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
713 |
if self.ElementType == "config": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
714 |
self.Values = self.Controler.GetConfigurationGlobalVars(words[1], self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
715 |
elif self.ElementType == "resource": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
716 |
self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2], self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
717 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
718 |
if self.ElementType == "function": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
719 |
self.ReturnType.Clear() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
720 |
for data_type in self.Controler.GetDataTypes(self.TagName, debug=self.Debug): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
721 |
self.ReturnType.Append(data_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
722 |
returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName, debug=self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
723 |
description = self.Controler.GetPouDescription(words[1]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
724 |
self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
725 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
726 |
if returnType is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
727 |
self.ReturnType.SetStringSelection(returnType) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
728 |
self.ReturnType.Enable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
729 |
self.ReturnTypeLabel.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
730 |
self.ReturnType.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
731 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
732 |
self.ReturnType.Enable(False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
733 |
self.ReturnTypeLabel.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
734 |
self.ReturnType.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
735 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
736 |
if description is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
737 |
self.Description.SetValue(description) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
738 |
self.Description.Enable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
739 |
self.DescriptionLabel.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
740 |
self.Description.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
741 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
742 |
self.Description.Enable(False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
743 |
self.DescriptionLabel.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
744 |
self.Description.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
745 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
746 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
747 |
self.VariablesGrid.RefreshButtons() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
748 |
self.MainSizer.Layout() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
749 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
750 |
def OnReturnTypeChanged(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
751 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
752 |
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection()) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
753 |
self.Controler.BufferProject() |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
754 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
755 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
756 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
757 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
758 |
def OnDescriptionChanged(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
759 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
760 |
old_description = self.Controler.GetPouDescription(words[1]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
761 |
new_description = self.Description.GetValue() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
762 |
if new_description != old_description: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
763 |
self.Controler.SetPouDescription(words[1], new_description) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
764 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
765 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
766 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
767 |
def OnClassFilter(self, event): |
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
768 |
self.Filter = self.FilterChoiceTransfer[self.VARIABLE_CHOICES_DICT[self.ClassFilter.GetStringSelection()]] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
769 |
self.RefreshTypeList() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
770 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
771 |
self.VariablesGrid.RefreshButtons() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
772 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
773 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
774 |
def RefreshTypeList(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
775 |
if self.Filter == "All": |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
776 |
self.ClassList = [self.FilterChoiceTransfer[choice] for choice in self.FilterChoices if self.FilterChoiceTransfer[choice] not in ["All", "Interface", "Variables"]] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
777 |
elif self.Filter == "Interface": |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
778 |
self.ClassList = ["Input", "Output", "InOut", "External"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
779 |
elif self.Filter == "Variables": |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
780 |
self.ClassList = ["Local", "Temp"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
781 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
782 |
self.ClassList = [self.Filter] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
783 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
784 |
def ShowErrorMessage(self, message): |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
785 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
786 |
dialog.ShowModal() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
787 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
788 |
|
2573
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
789 |
def OnVariableNameChange(self, old_name, new_name): |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
790 |
""" propagate renaming of variable to the rest of the project """ |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
791 |
if old_name != "": |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
792 |
self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_name, new_name) |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
793 |
self.Controler.BufferProject() |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
794 |
wx.CallAfter(self.ParentWindow.RefreshView, False) |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
795 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
796 |
|
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
797 |
def CheckVariableName(self, value, row): |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
798 |
if not TestIdentifier(value): |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
799 |
message = _("\"%s\" is not a valid identifier!") % value |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
800 |
elif value.upper() in IEC_KEYWORDS: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
801 |
message = _("\"%s\" is a keyword. It can't be used!") % value |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
802 |
elif value.upper() in self.PouNames: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
803 |
message = _("A POU named \"%s\" already exists!") % value |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
804 |
elif value.upper() in [var.Name.upper() for var in self.Values if var != self.Table.data[row]]: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
805 |
message = _("A variable with \"%s\" as name already exists in this pou!") % value |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
806 |
else: |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
807 |
return None |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
808 |
return message |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
809 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
810 |
def OnVariablesGridCellChange(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
811 |
row, col = event.GetRow(), event.GetCol() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
812 |
colname = self.Table.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
813 |
value = self.Table.GetValue(row, col) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
814 |
message = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
815 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
816 |
if colname == "Name" and value != "": |
2574
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
817 |
message = self.CheckVariableName(value, row) |
48a486000e84
LocationCellEditor use better source for variable name replacement, and validate variable name before applying it or complains otherwise.
Edouard Tisserant
parents:
2573
diff
changeset
|
818 |
if message is None: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
819 |
self.SaveValues(False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
820 |
old_value = self.Table.GetOldValue() |
2573
071d10c7ab8f
LocationCellEditor now systematically change variable name according to name given by CTN, calls VariablePanel' OnVariableNameChange to update POU accordingly.
Edouard Tisserant
parents:
2554
diff
changeset
|
821 |
self.OnVariableNameChange(old_value, value) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
822 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
823 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
824 |
if colname == "Class": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
825 |
self.ClearLocation(row, col, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
826 |
wx.CallAfter(self.ParentWindow.RefreshView) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
827 |
elif colname == "Location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
828 |
wx.CallAfter(self.ParentWindow.RefreshView) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
829 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
830 |
if message is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
831 |
wx.CallAfter(self.ShowErrorMessage, message) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
832 |
event.Veto() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
833 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
834 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
835 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
836 |
def ClearLocation(self, row, col, value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
837 |
if self.Values[row].Location != '': |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
838 |
if self.Table.GetColLabelValue(col, False) == 'Class' and value not in ["Local", "Global"] or \ |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
839 |
self.Table.GetColLabelValue(col, False) == 'Type' and not self.Controler.IsLocatableType(value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
840 |
self.Values[row].Location = '' |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
841 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
842 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
843 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
844 |
def BuildStdIECTypesMenu(self, type_menu): |
1838
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
845 |
# build a submenu containing standard IEC types |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
846 |
base_menu = wx.Menu(title='') |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
847 |
for base_type in self.Controler.GetBaseTypes(): |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
848 |
item = base_menu.Append(wx.ID_ANY, helpString='', kind=wx.ITEM_NORMAL, item=base_type) |
2554
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
849 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), item) |
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
850 |
|
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
851 |
type_menu.AppendMenu(wx.ID_ANY, _("Base Types"), base_menu) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
852 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
853 |
def BuildUserTypesMenu(self, type_menu): |
1838
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
854 |
# build a submenu containing user-defined types |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
855 |
datatype_menu = wx.Menu(title='') |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
856 |
datatypes = self.Controler.GetDataTypes(basetypes=False, confnodetypes=False) |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
857 |
for datatype in datatypes: |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
858 |
item = datatype_menu.Append(wx.ID_ANY, helpString='', kind=wx.ITEM_NORMAL, item=datatype) |
2554
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
859 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), item) |
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
860 |
|
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
861 |
type_menu.AppendMenu(wx.ID_ANY, _("User Data Types"), datatype_menu) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
862 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
863 |
def BuildLibsTypesMenu(self, type_menu): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
864 |
for category in self.Controler.GetConfNodeDataTypes(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
865 |
if len(category["list"]) > 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
866 |
# build a submenu containing confnode types |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
867 |
confnode_datatype_menu = wx.Menu(title='') |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
868 |
for datatype in category["list"]: |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
869 |
item = confnode_datatype_menu.Append(wx.ID_ANY, helpString='', kind=wx.ITEM_NORMAL, item=datatype) |
2554
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
870 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), item) |
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
871 |
|
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
872 |
type_menu.AppendMenu(wx.ID_ANY, category["name"], confnode_datatype_menu) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
873 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
874 |
def BuildProjectTypesMenu(self, type_menu, classtype): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
875 |
# build a submenu containing function block types |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
876 |
bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
877 |
_pouname, poutype = self.Controler.GetEditedElementType(self.TagName) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
878 |
if classtype in ["Input", "Output", "InOut", "External", "Global"] or \ |
1776
81aa8aaccdd4
clean-up: fix PEP8 E122 continuation line missing indentation or outdented
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1774
diff
changeset
|
879 |
poutype != "function" and bodytype in ["ST", "IL"]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
880 |
functionblock_menu = wx.Menu(title='') |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
881 |
fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
882 |
for functionblock_type in fbtypes: |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
883 |
item = functionblock_menu.Append(wx.ID_ANY, helpString='', kind=wx.ITEM_NORMAL, item=functionblock_type) |
2554
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
884 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), item) |
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
885 |
|
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
886 |
type_menu.AppendMenu(wx.ID_ANY, _("Function Block Types"), functionblock_menu) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
887 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
888 |
def BuildArrayTypesMenu(self, type_menu): |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
889 |
item = type_menu.Append(wx.ID_ANY, helpString='', kind=wx.ITEM_NORMAL, item=_("Array")) |
2554
45d4f9a84c60
VariablePanel's menu do not waste Wx IDs anymore (directly binds wx objects rather than crating new ID wit wx.NewId)
Edouard Tisserant
parents:
2450
diff
changeset
|
890 |
self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, item) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
891 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
892 |
def OnVariablesGridEditorShown(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
893 |
row, col = event.GetRow(), event.GetCol() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
894 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
895 |
label_value = self.Table.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
896 |
if label_value == "Type": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
897 |
old_value = self.Values[row].Type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
898 |
classtype = self.Table.GetValueByName(row, "Class") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
899 |
type_menu = wx.Menu(title='') # the root menu |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
900 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
901 |
self.BuildStdIECTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
902 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
903 |
self.BuildUserTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
904 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
905 |
self.BuildLibsTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
906 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
907 |
self.BuildProjectTypesMenu(type_menu, classtype) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
908 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
909 |
self.BuildArrayTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
910 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
911 |
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
912 |
corner_x = rect.x + rect.width |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
913 |
corner_y = rect.y + self.VariablesGrid.GetColLabelSize() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
914 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
915 |
# pop up this new menu |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3300
diff
changeset
|
916 |
self.VariablesGrid.PopupMenu(type_menu, corner_x, corner_y) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
917 |
type_menu.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
918 |
event.Veto() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
919 |
value = self.Values[row].Type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
920 |
if old_value != value: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
921 |
self.ClearLocation(row, col, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
922 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
923 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
924 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
925 |
def GetVariableTypeFunction(self, base_type): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
926 |
def VariableTypeFunction(event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
927 |
row = self.VariablesGrid.GetGridCursorRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
928 |
self.Table.SetValueByName(row, "Type", base_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
929 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
930 |
self.SaveValues(False) |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
931 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
932 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
933 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
934 |
return VariableTypeFunction |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
935 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
936 |
def VariableArrayTypeFunction(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
937 |
row = self.VariablesGrid.GetGridCursorRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
938 |
dialog = ArrayTypeDialog(self, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
939 |
self.Controler.GetDataTypes(self.TagName), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
940 |
self.Table.GetValueByName(row, "Type")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
941 |
if dialog.ShowModal() == wx.ID_OK: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
942 |
self.Table.SetValueByName(row, "Type", dialog.GetValue()) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
943 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
944 |
self.SaveValues(False) |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
945 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
946 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
947 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
948 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
949 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
950 |
def OnVariablesGridCellLeftClick(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
951 |
row = event.GetRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
952 |
if not self.Debug and (event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit")): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
953 |
var_name = self.Table.GetValueByName(row, "Name") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
954 |
var_class = self.Table.GetValueByName(row, "Class") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
955 |
var_type = self.Table.GetValueByName(row, "Type") |
3300
95fe62bfe920
Copy description when DnD variables from Globals in resources and configuration variable panels to POUs. Also prevent making exception in case some other DropSource wouldn't provide description.
Edouard Tisserant
parents:
2579
diff
changeset
|
956 |
var_doc = self.Table.GetValueByName(row, "Documentation") |
95fe62bfe920
Copy description when DnD variables from Globals in resources and configuration variable panels to POUs. Also prevent making exception in case some other DropSource wouldn't provide description.
Edouard Tisserant
parents:
2579
diff
changeset
|
957 |
data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName, var_doc))) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
958 |
dragSource = wx.DropSource(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
959 |
dragSource.SetData(data) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
960 |
dragSource.DoDragDrop() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
961 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
962 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
963 |
def RefreshValues(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
964 |
data = [] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
965 |
for num, variable in enumerate(self.Values): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
966 |
if variable.Class in self.ClassList: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
967 |
variable.Number = num + 1 |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
968 |
data.append(variable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
969 |
self.Table.SetData(data) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
970 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
971 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
972 |
def SaveValues(self, buffer=True): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
973 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
974 |
if self.ElementType == "config": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
975 |
self.Controler.SetConfigurationGlobalVars(words[1], self.Values) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
976 |
elif self.ElementType == "resource": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
977 |
self.Controler.SetConfigurationResourceGlobalVars(words[1], words[2], self.Values) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
978 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
979 |
if self.ReturnType.IsEnabled(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
980 |
self.Controler.SetPouInterfaceReturnType(words[1], self.ReturnType.GetStringSelection()) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
981 |
self.Controler.SetPouInterfaceVars(words[1], self.Values) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
982 |
if buffer: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
983 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
984 |
self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
985 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
986 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
987 |
# Highlights showing functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
988 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
989 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
990 |
def OnRefreshHighlightsTimer(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
991 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
992 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
993 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
994 |
def AddVariableHighlight(self, infos, highlight_type): |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
995 |
if isinstance(infos[0], tuple): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
996 |
for i in xrange(*infos[0]): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
997 |
self.Table.AddHighlight((i,) + infos[1:], highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
998 |
cell_visible = infos[0][0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
999 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1000 |
self.Table.AddHighlight(infos, highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1001 |
cell_visible = infos[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1002 |
colnames = [colname.lower() for colname in self.Table.colnames] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1003 |
self.VariablesGrid.MakeCellVisible(cell_visible, colnames.index(infos[1])) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1004 |
self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1005 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1006 |
def RemoveVariableHighlight(self, infos, highlight_type): |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2439
diff
changeset
|
1007 |
if isinstance(infos[0], tuple): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1008 |
for i in xrange(*infos[0]): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1009 |
self.Table.RemoveHighlight((i,) + infos[1:], highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1010 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1011 |
self.Table.RemoveHighlight(infos, highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1012 |
self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1013 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1014 |
def ClearHighlights(self, highlight_type=None): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1015 |
self.Table.ClearHighlights(highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1016 |
self.Table.ResetView(self.VariablesGrid) |