author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Mon, 24 Dec 2018 16:20:20 +0300 | |
changeset 2494 | a30dfc8a0c29 |
parent 2450 | 5024c19ca8f0 |
child 2554 | 45d4f9a84c60 |
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 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
37 |
from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS, DefaultType |
1953
5736d25bb393
PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents:
1951
diff
changeset
|
38 |
from plcopen.VariableInfoCollector import _VariableInfos |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
from controls.LocationCellEditor import LocationCellEditor |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
44 |
from util.BitmapLibrary import GetBitmap |
1834
cd42b426028b
fix ungrouped imports from package X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1833
diff
changeset
|
45 |
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
|
46 |
|
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 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
49 |
# Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
50 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
51 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
52 |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
53 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
54 |
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
|
55 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
56 |
] = range(10) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
57 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
58 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
59 |
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
|
60 |
_ = NoTranslate |
1772
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
61 |
cols = ["#", |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
62 |
_("Name"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
63 |
_("Class"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
64 |
_("Type"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
65 |
_("Location"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
66 |
_("Initial Value"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
67 |
_("Option"), |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
68 |
_("Documentation")] |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
69 |
if not location: |
c3679f96020b
clean-up: fix PEP8 W191 indentation contains tabs
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
70 |
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
|
71 |
return cols |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
72 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
73 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
74 |
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
|
75 |
_ = NoTranslate |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
76 |
options = [""] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
77 |
if constant: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
78 |
options.append(_("Constant")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
79 |
if retain: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
80 |
options.append(_("Retain")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
81 |
if non_retain: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
82 |
options.append(_("Non-Retain")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
83 |
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
|
84 |
|
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 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
86 |
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
|
87 |
_ = NoTranslate |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
88 |
return {_("All"): _("All"), _("Interface"): _("Interface"), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
89 |
_(" Input"): _("Input"), _(" Output"): _("Output"), _(" InOut"): _("InOut"), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
90 |
_(" 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
|
91 |
_(" 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
|
92 |
|
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 |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1772
diff
changeset
|
94 |
CheckOptionForClass = { |
1774
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
95 |
"Local": lambda x: x, |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
96 |
"Temp": lambda x: "", |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
97 |
"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
|
98 |
"InOut": lambda x: "", |
ac0fe8aabb5e
clean-up: fix PEP8 E272 multiple spaces before keyword
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
99 |
"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
|
100 |
"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
|
101 |
"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
|
102 |
} |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
103 |
|
2439
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
107 |
|
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
108 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
109 |
# 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
|
110 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
111 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
112 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
113 |
class VariableTable(CustomTable): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
114 |
|
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 |
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
|
117 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
118 |
def __init__(self, parent, data, colnames): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
119 |
# 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
|
120 |
CustomTable.__init__(self, parent, data, colnames) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
for _class in GetFilterChoiceTransfer().itervalues()]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
126 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
127 |
def GetValueByName(self, row, colname): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
128 |
if row < self.GetNumberRows(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
129 |
return getattr(self.data[row], colname) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
130 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
131 |
def SetValueByName(self, row, colname, value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
132 |
if row < self.GetNumberRows(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
133 |
setattr(self.data[row], colname, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
134 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
135 |
def GetValue(self, row, col): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
136 |
if row < self.GetNumberRows(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
137 |
if col == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
138 |
return self.data[row].Number |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
139 |
colname = self.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
140 |
if colname == "Initial Value": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
141 |
colname = "InitialValue" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
142 |
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
|
143 |
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
|
144 |
if value[0] == "array": |
1833
2269739dd098
fix unnecessary lambda and enable corresponding pylint check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
145 |
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
|
146 |
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
|
147 |
value = str(value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
148 |
if colname in ["Class", "Option"]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
149 |
return _(value) |
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 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
152 |
def SetValue(self, row, col, value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
153 |
if col < len(self.colnames): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
154 |
colname = self.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
155 |
if colname == "Name": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
if value == "External": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
161 |
self.SetValueByName(row, "InitialValue", "") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
162 |
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
|
163 |
value = self.OPTIONS_DICT[value] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
164 |
elif colname == "Initial Value": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
165 |
colname = "InitialValue" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
166 |
setattr(self.data[row], colname, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
167 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
168 |
def GetOldValue(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
169 |
return self.old_value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
170 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
171 |
def _GetRowEdit(self, row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
172 |
row_edit = self.GetValueByName(row, "Edit") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
173 |
var_type = self.Parent.GetTagName() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
174 |
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
|
175 |
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
|
176 |
row_edit = True |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
177 |
return row_edit |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
178 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
179 |
def _updateColAttrs(self, grid): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
180 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
181 |
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
|
182 |
appropriate renderer given the column name. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
183 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
184 |
Otherwise default to the default renderer. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
185 |
""" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
186 |
for row in range(self.GetNumberRows()): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
187 |
var_class = self.GetValueByName(row, "Class") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
188 |
var_type = self.GetValueByName(row, "Type") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
189 |
row_highlights = self.Highlights.get(row, {}) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
190 |
for col in range(self.GetNumberCols()): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
191 |
editor = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
192 |
renderer = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
193 |
colname = self.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
194 |
if self.Parent.Debug: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
195 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
196 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
197 |
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
|
198 |
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
|
199 |
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
|
200 |
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
|
201 |
if len(options) > 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
202 |
editor = wx.grid.GridCellChoiceEditor() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
203 |
editor.SetParameters(",".join(map(_, options))) |
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): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
214 |
editor = wx.grid.GridCellChoiceEditor() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
215 |
editor.SetParameters(",".join([""] + self.Parent.Controler.GetEnumeratedDataValues(var_type))) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
216 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
217 |
editor = wx.grid.GridCellTextEditor() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
218 |
renderer = wx.grid.GridCellStringRenderer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
219 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
220 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
221 |
elif colname == "Location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
222 |
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
|
223 |
editor = LocationCellEditor(self, self.Parent.Controler) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
224 |
renderer = wx.grid.GridCellStringRenderer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
225 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
226 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
227 |
elif colname == "Class": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
228 |
if len(self.Parent.ClassList) == 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
229 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
230 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
231 |
editor = wx.grid.GridCellChoiceEditor() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
232 |
excluded = [] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
233 |
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
|
234 |
excluded.extend(["Local", "Temp"]) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
235 |
editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded])) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
236 |
elif colname != "Documentation": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
237 |
grid.SetReadOnly(row, col, True) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
238 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
239 |
grid.SetCellEditor(row, col, editor) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
240 |
grid.SetCellRenderer(row, col, renderer) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
241 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
242 |
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
|
243 |
highlight_colours = ERROR_HIGHLIGHT |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
244 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
self.ResizeRow(grid, row) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
249 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
250 |
|
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 |
# 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
|
253 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
254 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
255 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
256 |
class VariableDropTarget(wx.TextDropTarget): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
257 |
''' |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
258 |
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
|
259 |
column of a variable row. |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
260 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
261 |
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
|
262 |
('%ID0.0.0', 'location', 'REAL') |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
263 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
264 |
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
|
265 |
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
|
266 |
''' |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
267 |
def __init__(self, parent): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
268 |
wx.TextDropTarget.__init__(self) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
269 |
self.ParentWindow = parent |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
270 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
271 |
def OnDropText(self, x, y, data): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
272 |
self.ParentWindow.ParentWindow.Select() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
273 |
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
|
274 |
col = self.ParentWindow.VariablesGrid.XToCol(x) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
275 |
row = self.ParentWindow.VariablesGrid.YToRow(y) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
276 |
message = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
277 |
element_type = self.ParentWindow.ElementType |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
278 |
try: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
values = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
286 |
if values is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
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
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
295 |
location = values[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
296 |
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
|
297 |
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
|
298 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
299 |
if values[2] is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
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
|
304 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
305 |
if message is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
306 |
if not location.startswith("%"): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
307 |
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
|
308 |
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
|
309 |
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
|
310 |
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
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
|
315 |
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
|
316 |
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
|
317 |
_("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
|
318 |
_("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
|
319 |
[_("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
|
320 |
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
|
321 |
if dialog.ShowModal() == wx.ID_OK: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
322 |
selected = dialog.GetSelection() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
323 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
324 |
selected = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
325 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
326 |
if selected is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
327 |
return |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
328 |
if selected == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
329 |
location = "%I" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
330 |
elif selected == 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
331 |
location = "%Q" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
332 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
333 |
location = "%M" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
334 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
335 |
if message is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
336 |
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
|
337 |
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
|
338 |
self.ParentWindow.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
339 |
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
|
340 |
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
|
341 |
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
|
342 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
343 |
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
|
344 |
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
|
345 |
self.ParentWindow.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
346 |
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
|
347 |
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
|
348 |
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
|
349 |
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
|
350 |
var_name = values[3] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
351 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
352 |
var_name = values[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
353 |
tagname = self.ParentWindow.GetTagName() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
354 |
dlg = wx.TextEntryDialog( |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
355 |
self.ParentWindow.ParentWindow.ParentWindow, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
356 |
_("Confirm or change variable name"), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
357 |
_('Variable Drop'), var_name) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
358 |
dlg.SetValue(var_name) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
359 |
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
|
360 |
dlg.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
361 |
if var_name is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
362 |
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
|
363 |
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
|
364 |
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
|
365 |
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
|
366 |
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
|
367 |
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
|
368 |
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
|
369 |
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
|
370 |
GetEditedElementVariables(tagname, self.ParentWindow.Debug)]: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
371 |
var_infos = self.ParentWindow.DefaultValue.copy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
372 |
var_infos.Name = var_name |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
373 |
var_infos.Type = values[2] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
374 |
var_infos.Documentation = values[4] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
375 |
if values[1] == "location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
376 |
location = values[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
377 |
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
|
378 |
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
|
379 |
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
|
380 |
_("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
|
381 |
_("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
|
382 |
[_("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
|
383 |
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
|
384 |
if dialog.ShowModal() == wx.ID_OK: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
385 |
selected = dialog.GetSelection() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
386 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
387 |
selected = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
388 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
389 |
if selected is None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
390 |
return |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
391 |
if selected == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
392 |
location = "%I" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
393 |
elif selected == 1: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
394 |
location = "%Q" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
395 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
396 |
location = "%M" + location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
397 |
if element_type == "functionBlock": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
398 |
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
|
399 |
self.ParentWindow.Debug) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
400 |
if len(configs) == 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
401 |
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
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
self.ParentWindow.Controler.AddConfigurationGlobalVar( |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
406 |
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
|
407 |
var_infos.Class = "External" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
408 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
409 |
if element_type == "program": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
410 |
var_infos.Class = "Local" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
411 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
412 |
var_infos.Class = "Global" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
413 |
var_infos.Location = location |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
414 |
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
|
415 |
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
|
416 |
var_infos.Class = "Local" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
417 |
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
|
418 |
else: |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
419 |
return |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
420 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
421 |
var_infos.Class = "External" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
422 |
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
|
423 |
self.ParentWindow.Values.append(var_infos) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
424 |
self.ParentWindow.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
425 |
self.ParentWindow.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
426 |
else: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1731
diff
changeset
|
427 |
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
|
428 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
429 |
if message is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
430 |
wx.CallAfter(self.ShowMessage, message) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
431 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
432 |
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
|
433 |
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
|
434 |
message.ShowModal() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
435 |
message.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
436 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
437 |
|
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 |
# Variable Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
440 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
441 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
442 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
443 |
class VariablePanel(wx.Panel): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
444 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
445 |
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
|
446 |
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
|
447 |
|
2301
5b8a7dd43f9f
Avoid usage of localized strings before initialization during import in many modules
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2240
diff
changeset
|
448 |
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
|
449 |
_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
|
450 |
|
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
451 |
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
|
452 |
self.MainSizer.AddGrowableCol(0) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
453 |
self.MainSizer.AddGrowableRow(1) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
454 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
455 |
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
|
456 |
controls_sizer.AddGrowableCol(5) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
457 |
controls_sizer.AddGrowableRow(0) |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
458 |
self.MainSizer.AddSizer(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
|
459 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
460 |
self.ReturnTypeLabel = wx.StaticText(self, label=_('Return Type:')) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
461 |
controls_sizer.AddWindow(self.ReturnTypeLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
462 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
463 |
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
|
464 |
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
|
465 |
self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, self.ReturnType) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
466 |
controls_sizer.AddWindow(self.ReturnType) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
467 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
468 |
self.DescriptionLabel = wx.StaticText(self, label=_('Description:')) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
469 |
controls_sizer.AddWindow(self.DescriptionLabel, flag=wx.ALIGN_CENTER_VERTICAL) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
470 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
471 |
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
|
472 |
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
|
473 |
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
|
474 |
self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
475 |
controls_sizer.AddWindow(self.Description) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
476 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
477 |
class_filter_label = wx.StaticText(self, label=_('Class Filter:')) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
478 |
controls_sizer.AddWindow(class_filter_label, flag=wx.ALIGN_CENTER_VERTICAL) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
479 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
480 |
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
|
481 |
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
|
482 |
self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, self.ClassFilter) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
483 |
controls_sizer.AddWindow(self.ClassFilter) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
484 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
485 |
for name, bitmap, help in [ |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
486 |
("AddButton", "add_element", _("Add variable")), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
487 |
("DeleteButton", "remove_element", _("Remove variable")), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
488 |
("UpButton", "up", _("Move variable up")), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
489 |
("DownButton", "down", _("Move variable down"))]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
490 |
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
|
491 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
492 |
button.SetToolTipString(help) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
493 |
setattr(self, name, button) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
494 |
controls_sizer.AddWindow(button) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
495 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
496 |
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
|
497 |
self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) |
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_CHANGE, |
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.OnVariablesGridCellChange) |
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_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
|
501 |
self.OnVariablesGridCellLeftClick) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
502 |
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
|
503 |
self.OnVariablesGridEditorShown) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
504 |
self.MainSizer.AddWindow(self.VariablesGrid, flag=wx.GROW) |
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.SetSizer(self.MainSizer) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
507 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
508 |
self.ParentWindow = window |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
509 |
self.Controler = controler |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
510 |
self.ElementType = element_type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
511 |
self.Debug = debug |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
512 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
513 |
self.RefreshHighlightsTimer = wx.Timer(self, -1) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
514 |
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
|
515 |
self.RefreshHighlightsTimer) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
516 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
517 |
self.Filter = "All" |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
518 |
self.FilterChoices = [] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
519 |
self.FilterChoiceTransfer = GetFilterChoiceTransfer() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
520 |
|
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
521 |
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
|
522 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
523 |
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
|
524 |
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
|
525 |
else: |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1738
diff
changeset
|
526 |
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
|
527 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
528 |
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
|
529 |
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
|
530 |
# 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
|
531 |
self.Table = VariableTable(self, [], GetVariableTableColnames(True)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
532 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
533 |
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
|
534 |
self.FilterChoices = ["All", "Global"] # ,"Access"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
535 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
536 |
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
|
537 |
"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
|
538 |
"Variables", " Local", " Temp"] # ,"Access"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
539 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
540 |
# 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
|
541 |
left = wx.ALIGN_LEFT |
1755
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
542 |
center = wx.ALIGN_CENTER |
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
543 |
|
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
544 |
# 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
|
545 |
self.ColSettings = { |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
546 |
"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
|
547 |
"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
|
548 |
"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
|
549 |
} |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
550 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
551 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
552 |
# 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
|
553 |
self.Table = VariableTable(self, [], GetVariableTableColnames(False)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
554 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
555 |
if element_type == "function": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
556 |
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
|
557 |
"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
|
558 |
"Variables", " Local"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
559 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
560 |
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
|
561 |
"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
|
562 |
"Variables", " Local", " Temp"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
563 |
|
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
564 |
# 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
|
565 |
left = wx.ALIGN_LEFT |
1755
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
566 |
center = wx.ALIGN_CENTER |
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
567 |
|
624b9694cb0d
clean-up: fix PEP8 E741 ambiguous variable name
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
568 |
# 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
|
569 |
self.ColSettings = { |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
570 |
"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
|
571 |
"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
|
572 |
"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
|
573 |
} |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
574 |
|
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
575 |
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
|
576 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
577 |
self.ElementType = element_type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
578 |
self.BodyType = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
579 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
580 |
for choice in self.FilterChoices: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
581 |
self.ClassFilter.Append(_(choice)) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
582 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
583 |
reverse_transfer = {} |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
584 |
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
|
585 |
reverse_transfer[choice] = filter |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
586 |
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
|
587 |
self.RefreshTypeList() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
588 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
589 |
self.VariablesGrid.SetTable(self.Table) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
590 |
self.VariablesGrid.SetButtons({"Add": self.AddButton, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
591 |
"Delete": self.DeleteButton, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
592 |
"Up": self.UpButton, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
593 |
"Down": self.DownButton}) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
594 |
self.VariablesGrid.SetEditable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
595 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
596 |
def _AddVariable(new_row): |
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
597 |
row_content = self.DefaultValue.copy() |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
598 |
if new_row > 0: |
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
599 |
# 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
|
600 |
if self.Values[new_row-1].Edit: |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
601 |
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
|
602 |
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
|
603 |
row_content.Name = self.Controler.GenerateNewName( |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
604 |
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
|
605 |
|
e684aed23407
Automatically increment IEC-location address if copy of the variable is created
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
606 |
# 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
|
607 |
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
|
608 |
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
|
609 |
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
|
610 |
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
|
611 |
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
|
612 |
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
|
613 |
|
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
614 |
if not row_content.Class: |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
615 |
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
|
616 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
617 |
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
|
618 |
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
|
619 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
620 |
self.Values.append(row_content) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
621 |
new_row = self.Table.GetNumberRows() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
622 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
623 |
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
|
624 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
625 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
626 |
return new_row |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
627 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
628 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
629 |
def _DeleteVariable(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
630 |
if _GetRowEdit(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
631 |
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
|
632 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
633 |
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
|
634 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
635 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
636 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
637 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
638 |
def _MoveVariable(row, move): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
639 |
if self.Filter == "All": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
640 |
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
|
641 |
if new_row != row: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
642 |
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
|
643 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
644 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
645 |
return new_row |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
646 |
return row |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
647 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
648 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
649 |
def _GetRowEdit(row): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
650 |
row_edit = False |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
651 |
if self: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
652 |
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
|
653 |
bodytype = self.Controler.GetEditedElementBodyType(self.TagName) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
654 |
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
|
655 |
return row_edit |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
656 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
657 |
def _RefreshButtons(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
658 |
if self: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
659 |
table_length = len(self.Table.data) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
660 |
row_edit = True |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
661 |
row = 0 |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
662 |
if table_length > 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
663 |
row = self.VariablesGrid.GetGridCursorRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
664 |
row_edit = _GetRowEdit(row) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
665 |
self.AddButton.Enable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
666 |
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
|
667 |
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
|
668 |
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
|
669 |
setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
670 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
671 |
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
|
672 |
if panel_width > self.PanelWidthMin: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
673 |
stretch_cols_width = panel_width |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
674 |
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
|
675 |
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
|
676 |
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
|
677 |
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
|
678 |
else: |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
679 |
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
|
680 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
681 |
self.VariablesGrid.SetRowLabelSize(0) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
682 |
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
|
683 |
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
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
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
|
688 |
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
|
689 |
else: |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1755
diff
changeset
|
690 |
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
|
691 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
692 |
def __del__(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
693 |
self.RefreshHighlightsTimer.Stop() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
694 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
695 |
def SetTagName(self, tagname): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
696 |
self.TagName = tagname |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
697 |
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
|
698 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
699 |
def GetTagName(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
700 |
return self.TagName |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
701 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
return False |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
706 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
707 |
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
|
708 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
709 |
def RefreshView(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
710 |
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
|
711 |
returnType = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
712 |
description = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
713 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
714 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
715 |
if self.ElementType == "config": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
716 |
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
|
717 |
elif self.ElementType == "resource": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
718 |
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
|
719 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
720 |
if self.ElementType == "function": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
721 |
self.ReturnType.Clear() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
722 |
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
|
723 |
self.ReturnType.Append(data_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
724 |
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
|
725 |
description = self.Controler.GetPouDescription(words[1]) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
726 |
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
|
727 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
728 |
if returnType is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
729 |
self.ReturnType.SetStringSelection(returnType) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
730 |
self.ReturnType.Enable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
731 |
self.ReturnTypeLabel.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
732 |
self.ReturnType.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
733 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
734 |
self.ReturnType.Enable(False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
735 |
self.ReturnTypeLabel.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
736 |
self.ReturnType.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
737 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
738 |
if description is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
739 |
self.Description.SetValue(description) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
740 |
self.Description.Enable(not self.Debug) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
741 |
self.DescriptionLabel.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
742 |
self.Description.Show() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
743 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
744 |
self.Description.Enable(False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
745 |
self.DescriptionLabel.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
746 |
self.Description.Hide() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
747 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
748 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
749 |
self.VariablesGrid.RefreshButtons() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
750 |
self.MainSizer.Layout() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
751 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
752 |
def OnReturnTypeChanged(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
753 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
757 |
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
|
758 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
759 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
760 |
def OnDescriptionChanged(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
761 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
762 |
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
|
763 |
new_description = self.Description.GetValue() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
764 |
if new_description != old_description: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
765 |
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
|
766 |
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
|
767 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
768 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
769 |
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
|
770 |
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
|
771 |
self.RefreshTypeList() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
772 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
773 |
self.VariablesGrid.RefreshButtons() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
774 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
775 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
776 |
def RefreshTypeList(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
777 |
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
|
778 |
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
|
779 |
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
|
780 |
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
|
781 |
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
|
782 |
self.ClassList = ["Local", "Temp"] |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
783 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
784 |
self.ClassList = [self.Filter] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
785 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
786 |
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
|
787 |
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
|
788 |
dialog.ShowModal() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
789 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
790 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
791 |
def OnVariablesGridCellChange(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
792 |
row, col = event.GetRow(), event.GetCol() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
793 |
colname = self.Table.GetColLabelValue(col, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
794 |
value = self.Table.GetValue(row, col) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
795 |
message = None |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
796 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
797 |
if colname == "Name" and value != "": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
798 |
if not TestIdentifier(value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
799 |
message = _("\"%s\" is not a valid identifier!") % value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
800 |
elif value.upper() in IEC_KEYWORDS: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
801 |
message = _("\"%s\" is a keyword. It can't be used!") % value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
802 |
elif value.upper() in self.PouNames: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
803 |
message = _("A POU named \"%s\" already exists!") % value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
804 |
elif value.upper() in [var.Name.upper() for var in self.Values if var != self.Table.data[row]]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
805 |
message = _("A variable with \"%s\" as name already exists in this pou!") % value |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
806 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
807 |
self.SaveValues(False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
808 |
old_value = self.Table.GetOldValue() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
809 |
if old_value != "": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
810 |
self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
811 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
812 |
wx.CallAfter(self.ParentWindow.RefreshView, False) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
813 |
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
|
814 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
815 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
816 |
if colname == "Class": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
817 |
self.ClearLocation(row, col, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
818 |
wx.CallAfter(self.ParentWindow.RefreshView) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
819 |
elif colname == "Location": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
820 |
wx.CallAfter(self.ParentWindow.RefreshView) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
821 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
822 |
if message is not None: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
823 |
wx.CallAfter(self.ShowErrorMessage, message) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
824 |
event.Veto() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
825 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
826 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
827 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
828 |
def ClearLocation(self, row, col, value): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
829 |
if self.Values[row].Location != '': |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
830 |
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
|
831 |
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
|
832 |
self.Values[row].Location = '' |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
833 |
self.RefreshValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
834 |
self.SaveValues() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
835 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
836 |
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
|
837 |
# 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
|
838 |
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
|
839 |
for base_type in self.Controler.GetBaseTypes(): |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
840 |
new_id = wx.NewId() |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
841 |
base_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
842 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
843 |
|
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
844 |
type_menu.AppendMenu(wx.NewId(), _("Base Types"), base_menu) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
845 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
846 |
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
|
847 |
# 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
|
848 |
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
|
849 |
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
|
850 |
for datatype in datatypes: |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
851 |
new_id = wx.NewId() |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
852 |
datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
853 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
854 |
|
646245c1c0d9
fix pylint warning (bad-indentation) Bad indentation. Found X spaces, expected Y
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
855 |
type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
856 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
857 |
def BuildLibsTypesMenu(self, type_menu): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
858 |
for category in self.Controler.GetConfNodeDataTypes(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
859 |
if len(category["list"]) > 0: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
860 |
# build a submenu containing confnode types |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
861 |
confnode_datatype_menu = wx.Menu(title='') |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
862 |
for datatype in category["list"]: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
863 |
new_id = wx.NewId() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
864 |
confnode_datatype_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
865 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
866 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
867 |
type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
868 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
869 |
def BuildProjectTypesMenu(self, type_menu, classtype): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
870 |
# 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
|
871 |
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
|
872 |
_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
|
873 |
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
|
874 |
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
|
875 |
functionblock_menu = wx.Menu(title='') |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
876 |
fbtypes = self.Controler.GetFunctionBlockTypes(self.TagName) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
877 |
for functionblock_type in fbtypes: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
878 |
new_id = wx.NewId() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
879 |
functionblock_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=functionblock_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
880 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(functionblock_type), id=new_id) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
881 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
882 |
type_menu.AppendMenu(wx.NewId(), _("Function Block Types"), functionblock_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
883 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
884 |
def BuildArrayTypesMenu(self, type_menu): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
885 |
new_id = wx.NewId() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
886 |
type_menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Array")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
887 |
self.Bind(wx.EVT_MENU, self.VariableArrayTypeFunction, id=new_id) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
888 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
889 |
def OnVariablesGridEditorShown(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
890 |
row, col = event.GetRow(), event.GetCol() |
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 |
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
|
893 |
if label_value == "Type": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
894 |
old_value = self.Values[row].Type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
895 |
classtype = self.Table.GetValueByName(row, "Class") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
896 |
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
|
897 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
898 |
self.BuildStdIECTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
899 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
900 |
self.BuildUserTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
901 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
902 |
self.BuildLibsTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
903 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
904 |
self.BuildProjectTypesMenu(type_menu, classtype) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
905 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
906 |
self.BuildArrayTypesMenu(type_menu) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
907 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
908 |
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
|
909 |
corner_x = rect.x + rect.width |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
910 |
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
|
911 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
912 |
# pop up this new menu |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
913 |
self.VariablesGrid.PopupMenuXY(type_menu, corner_x, corner_y) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
914 |
type_menu.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
915 |
event.Veto() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
916 |
value = self.Values[row].Type |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
917 |
if old_value != value: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
918 |
self.ClearLocation(row, col, value) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
919 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
920 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
921 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
922 |
def GetVariableTypeFunction(self, base_type): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
923 |
def VariableTypeFunction(event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
924 |
row = self.VariablesGrid.GetGridCursorRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
925 |
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
|
926 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
927 |
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
|
928 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
929 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
930 |
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
|
931 |
return VariableTypeFunction |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
932 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
933 |
def VariableArrayTypeFunction(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
934 |
row = self.VariablesGrid.GetGridCursorRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
935 |
dialog = ArrayTypeDialog(self, |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
936 |
self.Controler.GetDataTypes(self.TagName), |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
937 |
self.Table.GetValueByName(row, "Type")) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
938 |
if dialog.ShowModal() == wx.ID_OK: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
939 |
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
|
940 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
941 |
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
|
942 |
self.ParentWindow.RefreshView(variablepanel=False) |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
943 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
944 |
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
|
945 |
dialog.Destroy() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
946 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
947 |
def OnVariablesGridCellLeftClick(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
948 |
row = event.GetRow() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
949 |
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
|
950 |
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
|
951 |
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
|
952 |
var_type = self.Table.GetValueByName(row, "Type") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
953 |
data = wx.TextDataObject(str((var_name, var_class, var_type, self.TagName))) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
954 |
dragSource = wx.DropSource(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
955 |
dragSource.SetData(data) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
956 |
dragSource.DoDragDrop() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
957 |
event.Skip() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
958 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
959 |
def RefreshValues(self): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
960 |
data = [] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
961 |
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
|
962 |
if variable.Class in self.ClassList: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
963 |
variable.Number = num + 1 |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
964 |
data.append(variable) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
965 |
self.Table.SetData(data) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
966 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
967 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
968 |
def SaveValues(self, buffer=True): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
969 |
words = self.TagName.split("::") |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
970 |
if self.ElementType == "config": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
971 |
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
|
972 |
elif self.ElementType == "resource": |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
973 |
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
|
974 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
975 |
if self.ReturnType.IsEnabled(): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
976 |
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
|
977 |
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
|
978 |
if buffer: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
979 |
self.Controler.BufferProject() |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
980 |
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
|
981 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
982 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
983 |
# Highlights showing functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
984 |
# ------------------------------------------------------------------------------- |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
985 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
986 |
def OnRefreshHighlightsTimer(self, event): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
987 |
self.Table.ResetView(self.VariablesGrid) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
988 |
event.Skip() |
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 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
|
991 |
if isinstance(infos[0], tuple): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
992 |
for i in xrange(*infos[0]): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
993 |
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
|
994 |
cell_visible = infos[0][0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
995 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
996 |
self.Table.AddHighlight(infos, highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
997 |
cell_visible = infos[0] |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
998 |
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
|
999 |
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
|
1000 |
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
|
1001 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1002 |
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
|
1003 |
if isinstance(infos[0], tuple): |
1731
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1004 |
for i in xrange(*infos[0]): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1005 |
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
|
1006 |
else: |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1007 |
self.Table.RemoveHighlight(infos, highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1008 |
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
|
1009 |
|
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1010 |
def ClearHighlights(self, highlight_type=None): |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1011 |
self.Table.ClearHighlights(highlight_type) |
6ebd9c40b2be
convert some files from CRLF to LF
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
1012 |
self.Table.ResetView(self.VariablesGrid) |