author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 04 Oct 2023 16:24:00 +0200 | |
branch | python3 |
changeset 3854 | d29d67e86532 |
parent 3765 | 88fe6fc9fd38 |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
8 |
# Copyright (C) 2017: Andrey Skvortsov |
814 | 9 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
10 |
# See COPYING file for copyrights details. |
814 | 11 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
12 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
13 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
14 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
15 |
# of the License, or (at your option) any later version. |
814 | 16 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
17 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
20 |
# GNU General Public License for more details. |
814 | 21 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
22 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
23 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1508
diff
changeset
|
24 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 25 |
|
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1847
diff
changeset
|
26 |
|
814 | 27 |
import re |
28 |
||
29 |
import wx |
|
30 |
import wx.grid |
|
31 |
import wx.lib.buttons |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
32 |
from plcopen.structures import IEC_KEYWORDS, TestIdentifier, DefaultType |
814 | 33 |
from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD |
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
34 |
from controls import CustomEditableListBox, CustomGrid, CustomTable, CustomIntCtrl |
864
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
35 |
from dialogs import ArrayTypeDialog |
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1847
diff
changeset
|
36 |
from editors.EditorPanel import EditorPanel |
814 | 37 |
from util.BitmapLibrary import GetBitmap |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
38 |
from util.TranslationCatalogs import NoTranslate |
814 | 39 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
40 |
# ------------------------------------------------------------------------------- |
814 | 41 |
# Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
42 |
# ------------------------------------------------------------------------------- |
814 | 43 |
|
2439
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
44 |
DIMENSION_MODEL = re.compile(r"([0-9]+)\.\.([0-9]+)$") |
814 | 45 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1735
diff
changeset
|
46 |
|
2737
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
47 |
def AppendMenu(parent, help, kind, text): |
3449
6279ec06df98
wxPython4 sequels: usual naming problem in grid cell change events, non kw-args to menu.Append and event not being skipped.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3303
diff
changeset
|
48 |
return parent.Append(wx.MenuItem(helpString=help, id=wx.ID_ANY, kind=kind, text=text)) |
814 | 49 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1735
diff
changeset
|
50 |
|
814 | 51 |
def GetElementsTableColnames(): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
52 |
_ = NoTranslate |
814 | 53 |
return ["#", _("Name"), _("Type"), _("Initial Value")] |
54 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1735
diff
changeset
|
55 |
|
814 | 56 |
def GetDatatypeTypes(): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1754
diff
changeset
|
57 |
_ = NoTranslate |
814 | 58 |
return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")] |
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
|
59 |
|
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
|
60 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
61 |
# ------------------------------------------------------------------------------- |
814 | 62 |
# Structure Elements Table |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
63 |
# ------------------------------------------------------------------------------- |
814 | 64 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1735
diff
changeset
|
65 |
|
814 | 66 |
class ElementsTable(CustomTable): |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
67 |
|
814 | 68 |
""" |
69 |
A custom wx.grid.Grid Table using user supplied data |
|
70 |
""" |
|
71 |
def __init__(self, parent, data, colnames): |
|
72 |
# The base class must be initialized *first* |
|
73 |
CustomTable.__init__(self, parent, data, colnames) |
|
74 |
self.old_value = None |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
75 |
|
814 | 76 |
def GetValue(self, row, col): |
77 |
if row < self.GetNumberRows(): |
|
78 |
if col == 0: |
|
79 |
return row + 1 |
|
864
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
80 |
colname = self.GetColLabelValue(col, False) |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
81 |
value = self.data[row].get(colname, "") |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
82 |
|
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
|
83 |
if colname == "Type" and isinstance(value, tuple): |
864
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
84 |
if value[0] == "array": |
1833
2269739dd098
fix unnecessary lambda and enable corresponding pylint check
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1821
diff
changeset
|
85 |
return "ARRAY [%s] OF %s" % (",".join(map("..".join, value[2])), value[1]) |
1508
4c645e6b8c98
fix error if non-latin character was entered in initial value in
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1412
diff
changeset
|
86 |
return value |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
87 |
|
814 | 88 |
def SetValue(self, row, col, value): |
89 |
if col < len(self.colnames): |
|
90 |
colname = self.GetColLabelValue(col, False) |
|
91 |
if colname == "Name": |
|
92 |
self.old_value = self.data[row][colname] |
|
93 |
self.data[row][colname] = value |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
94 |
|
814 | 95 |
def GetOldValue(self): |
96 |
return self.old_value |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
97 |
|
814 | 98 |
def _updateColAttrs(self, grid): |
99 |
""" |
|
100 |
wx.grid.Grid -> update the column attributes to add the |
|
101 |
appropriate renderer given the column name. |
|
102 |
||
103 |
Otherwise default to the default renderer. |
|
104 |
""" |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
105 |
|
814 | 106 |
for row in range(self.GetNumberRows()): |
107 |
row_highlights = self.Highlights.get(row, {}) |
|
108 |
for col in range(self.GetNumberCols()): |
|
109 |
editor = None |
|
110 |
renderer = None |
|
111 |
colname = self.GetColLabelValue(col, False) |
|
112 |
if col != 0: |
|
113 |
grid.SetReadOnly(row, col, False) |
|
114 |
if colname == "Name": |
|
115 |
editor = wx.grid.GridCellTextEditor() |
|
116 |
renderer = wx.grid.GridCellStringRenderer() |
|
117 |
elif colname == "Initial Value": |
|
118 |
editor = wx.grid.GridCellTextEditor() |
|
119 |
renderer = wx.grid.GridCellStringRenderer() |
|
120 |
elif colname == "Type": |
|
121 |
editor = wx.grid.GridCellTextEditor() |
|
122 |
else: |
|
123 |
grid.SetReadOnly(row, col, True) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
124 |
|
814 | 125 |
grid.SetCellEditor(row, col, editor) |
126 |
grid.SetCellRenderer(row, col, renderer) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
127 |
|
814 | 128 |
highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1] |
129 |
grid.SetCellBackgroundColour(row, col, highlight_colours[0]) |
|
130 |
grid.SetCellTextColour(row, col, highlight_colours[1]) |
|
131 |
self.ResizeRow(grid, row) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
132 |
|
814 | 133 |
def AddHighlight(self, infos, highlight_type): |
134 |
row_highlights = self.Highlights.setdefault(infos[0], {}) |
|
135 |
if infos[1] == "initial": |
|
136 |
col_highlights = row_highlights.setdefault("initial value", []) |
|
137 |
else: |
|
138 |
col_highlights = row_highlights.setdefault(infos[1], []) |
|
139 |
col_highlights.append(highlight_type) |
|
140 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
141 |
# ------------------------------------------------------------------------------- |
814 | 142 |
# Datatype Editor class |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
143 |
# ------------------------------------------------------------------------------- |
814 | 144 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1735
diff
changeset
|
145 |
|
814 | 146 |
class DataTypeEditor(EditorPanel): |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
147 |
|
814 | 148 |
def _init_Editor(self, parent): |
149 |
self.Editor = wx.Panel(parent, style=wx.SUNKEN_BORDER) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
150 |
|
814 | 151 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
152 |
self.MainSizer.AddGrowableCol(0) |
|
153 |
self.MainSizer.AddGrowableRow(1) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
154 |
|
814 | 155 |
top_sizer = wx.BoxSizer(wx.HORIZONTAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
156 |
self.MainSizer.Add(top_sizer, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
157 |
flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
158 |
|
814 | 159 |
derivation_type_label = wx.StaticText(self.Editor, label=_('Derivation Type:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
160 |
top_sizer.Add(derivation_type_label, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
161 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT | wx.RIGHT) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
162 |
|
814 | 163 |
self.DerivationType = wx.ComboBox(self.Editor, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
164 |
size=wx.Size(200, -1), style=wx.CB_READONLY) |
814 | 165 |
self.Bind(wx.EVT_COMBOBOX, self.OnDerivationTypeChanged, self.DerivationType) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
166 |
top_sizer.Add(self.DerivationType, border=5, flag=wx.GROW | wx.RIGHT) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
167 |
|
814 | 168 |
typeinfos_staticbox = wx.StaticBox(self.Editor, label=_('Type infos:')) |
169 |
typeinfos_sizer = wx.StaticBoxSizer(typeinfos_staticbox, wx.HORIZONTAL) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
170 |
self.MainSizer.Add(typeinfos_sizer, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
171 |
flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
172 |
|
814 | 173 |
# Panel for Directly derived data types |
174 |
||
175 |
self.DirectlyPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
176 |
typeinfos_sizer.Add(self.DirectlyPanel, 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
177 |
|
814 | 178 |
directly_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
179 |
|
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
180 |
directly_basetype_label = wx.StaticText(self.DirectlyPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
181 |
label=_('Base Type:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
182 |
directly_panel_sizer.Add(directly_basetype_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
183 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
184 |
|
814 | 185 |
self.DirectlyBaseType = wx.ComboBox(self.DirectlyPanel, style=wx.CB_READONLY) |
947 | 186 |
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.DirectlyBaseType) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
187 |
directly_panel_sizer.Add(self.DirectlyBaseType, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
188 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
189 |
|
814 | 190 |
directly_initialvalue_label = wx.StaticText(self.DirectlyPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
191 |
label=_('Initial Value:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
192 |
directly_panel_sizer.Add(directly_initialvalue_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
193 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
194 |
|
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
195 |
self.DirectlyInitialValue = wx.TextCtrl(self.DirectlyPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
196 |
style=wx.TE_PROCESS_ENTER | wx.TE_RICH) |
814 | 197 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, self.DirectlyInitialValue) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
198 |
directly_panel_sizer.Add(self.DirectlyInitialValue, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
199 |
flag=wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
200 |
|
814 | 201 |
self.DirectlyPanel.SetSizer(directly_panel_sizer) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
202 |
|
814 | 203 |
# Panel for Subrange data types |
204 |
||
205 |
self.SubrangePanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
206 |
typeinfos_sizer.Add(self.SubrangePanel, 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
207 |
|
814 | 208 |
subrange_panel_sizer = wx.GridSizer(cols=4, hgap=5, rows=3, vgap=0) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
209 |
|
814 | 210 |
subrange_basetype_label = wx.StaticText(self.SubrangePanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
211 |
label=_('Base Type:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
212 |
subrange_panel_sizer.Add(subrange_basetype_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
213 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
214 |
|
814 | 215 |
self.SubrangeBaseType = wx.ComboBox(self.SubrangePanel, style=wx.CB_READONLY) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
216 |
self.Bind(wx.EVT_COMBOBOX, self.OnSubrangeBaseTypeChanged, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
217 |
self.SubrangeBaseType) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
218 |
subrange_panel_sizer.Add(self.SubrangeBaseType, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
219 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
220 |
|
814 | 221 |
subrange_initialvalue_label = wx.StaticText(self.SubrangePanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
222 |
label=_('Initial Value:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
223 |
subrange_panel_sizer.Add(subrange_initialvalue_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
224 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
225 |
|
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
226 |
self.SubrangeInitialValue = CustomIntCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL) |
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
227 |
self.SubrangeInitialValue.Bind(CustomIntCtrl.EVT_CUSTOM_INT, self.OnInfosChanged) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
228 |
subrange_panel_sizer.Add(self.SubrangeInitialValue, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
229 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
230 |
|
814 | 231 |
subrange_minimum_label = wx.StaticText(self.SubrangePanel, label=_('Minimum:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
232 |
subrange_panel_sizer.Add(subrange_minimum_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
233 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
234 |
|
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
235 |
self.SubrangeMinimum = CustomIntCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL) |
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
236 |
self.SubrangeMinimum.Bind(CustomIntCtrl.EVT_CUSTOM_INT, self.OnSubrangeMinimumChanged) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
237 |
subrange_panel_sizer.Add(self.SubrangeMinimum, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
238 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
239 |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
3449
diff
changeset
|
240 |
for dummy in range(2): |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
241 |
subrange_panel_sizer.Add(wx.Size(0, 0), 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
242 |
|
814 | 243 |
subrange_maximum_label = wx.StaticText(self.SubrangePanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
244 |
label=_('Maximum:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
245 |
subrange_panel_sizer.Add(subrange_maximum_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
246 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
247 |
|
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
248 |
self.SubrangeMaximum = CustomIntCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL) |
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
249 |
self.SubrangeMaximum.Bind(CustomIntCtrl.EVT_CUSTOM_INT, self.OnSubrangeMaximumChanged) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
250 |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
251 |
subrange_panel_sizer.Add(self.SubrangeMaximum, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
252 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
253 |
|
814 | 254 |
self.SubrangePanel.SetSizer(subrange_panel_sizer) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
255 |
|
814 | 256 |
# Panel for Enumerated data types |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
257 |
|
814 | 258 |
self.EnumeratedPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
259 |
typeinfos_sizer.Add(self.EnumeratedPanel, 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
260 |
|
814 | 261 |
enumerated_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
262 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
263 |
self.EnumeratedValues = CustomEditableListBox( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
264 |
self.EnumeratedPanel, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
265 |
label=_("Values:"), |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
266 |
style=(wx.adv.EL_ALLOW_NEW | |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
267 |
wx.adv.EL_ALLOW_EDIT | |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
268 |
wx.adv.EL_ALLOW_DELETE)) |
814 | 269 |
setattr(self.EnumeratedValues, "_OnLabelEndEdit", self.OnEnumeratedValueEndEdit) |
270 |
for func in ["_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]: |
|
271 |
setattr(self.EnumeratedValues, func, self.OnEnumeratedValuesChanged) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
272 |
enumerated_panel_sizer.Add(self.EnumeratedValues, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
273 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
274 |
|
814 | 275 |
enumerated_panel_rightsizer = wx.BoxSizer(wx.HORIZONTAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
276 |
enumerated_panel_sizer.Add(enumerated_panel_rightsizer, 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
277 |
|
814 | 278 |
enumerated_initialvalue_label = wx.StaticText(self.EnumeratedPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
279 |
label=_('Initial Value:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
280 |
enumerated_panel_rightsizer.Add(enumerated_initialvalue_label, 1, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
281 |
border=5, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
282 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
283 |
|
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
284 |
self.EnumeratedInitialValue = wx.ComboBox(self.EnumeratedPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
285 |
style=wx.CB_READONLY) |
814 | 286 |
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.EnumeratedInitialValue) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
287 |
enumerated_panel_rightsizer.Add(self.EnumeratedInitialValue, 1, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
288 |
border=5, flag=wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
289 |
|
814 | 290 |
self.EnumeratedPanel.SetSizer(enumerated_panel_sizer) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
291 |
|
814 | 292 |
# Panel for Array data types |
293 |
||
294 |
self.ArrayPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
295 |
typeinfos_sizer.Add(self.ArrayPanel, 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
296 |
|
814 | 297 |
array_panel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0) |
298 |
array_panel_sizer.AddGrowableCol(0) |
|
299 |
array_panel_sizer.AddGrowableCol(1) |
|
300 |
array_panel_sizer.AddGrowableRow(1) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
301 |
|
814 | 302 |
array_panel_leftSizer = wx.BoxSizer(wx.HORIZONTAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
303 |
array_panel_sizer.Add(array_panel_leftSizer, flag=wx.GROW) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
304 |
|
814 | 305 |
array_basetype_label = wx.StaticText(self.ArrayPanel, label=_('Base Type:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
306 |
array_panel_leftSizer.Add(array_basetype_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
307 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
308 |
|
814 | 309 |
self.ArrayBaseType = wx.ComboBox(self.ArrayPanel, style=wx.CB_READONLY) |
310 |
self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.ArrayBaseType) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
311 |
array_panel_leftSizer.Add(self.ArrayBaseType, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
312 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
313 |
|
814 | 314 |
array_panel_rightsizer = wx.BoxSizer(wx.HORIZONTAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
315 |
array_panel_sizer.Add(array_panel_rightsizer, flag=wx.GROW) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
316 |
|
814 | 317 |
array_initialvalue_label = wx.StaticText(self.ArrayPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
318 |
label=_('Initial Value:')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
319 |
array_panel_rightsizer.Add(array_initialvalue_label, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
320 |
flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
321 |
|
814 | 322 |
self.ArrayInitialValue = wx.TextCtrl(self.ArrayPanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
323 |
style=wx.TE_PROCESS_ENTER | wx.TE_RICH) |
814 | 324 |
self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, self.ArrayInitialValue) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
325 |
array_panel_rightsizer.Add(self.ArrayInitialValue, 1, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
326 |
flag=wx.ALL) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
327 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
328 |
self.ArrayDimensions = CustomEditableListBox( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
329 |
self.ArrayPanel, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
330 |
label=_("Dimensions:"), |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
331 |
style=(wx.adv.EL_ALLOW_NEW | |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
332 |
wx.adv.EL_ALLOW_EDIT | |
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
333 |
wx.adv.EL_ALLOW_DELETE)) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
334 |
for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton", |
814 | 335 |
"_OnUpButton", "_OnDownButton"]: |
336 |
setattr(self.ArrayDimensions, func, self.OnDimensionsChanged) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
337 |
array_panel_sizer.Add(self.ArrayDimensions, 0, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
338 |
flag=wx.GROW | wx.ALL) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
339 |
|
814 | 340 |
self.ArrayPanel.SetSizer(array_panel_sizer) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
341 |
|
814 | 342 |
# Panel for Structure data types |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
343 |
|
814 | 344 |
self.StructurePanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
345 |
typeinfos_sizer.Add(self.StructurePanel, 1) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
346 |
|
814 | 347 |
structure_panel_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
348 |
structure_panel_sizer.AddGrowableCol(0) |
|
349 |
structure_panel_sizer.AddGrowableRow(1) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
350 |
|
814 | 351 |
structure_button_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
352 |
structure_button_sizer.AddGrowableCol(0) |
|
353 |
structure_button_sizer.AddGrowableRow(0) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
354 |
structure_panel_sizer.Add(structure_button_sizer, 0, border=5, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
355 |
flag=wx.ALL | wx.GROW) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
356 |
|
814 | 357 |
structure_elements_label = wx.StaticText(self.StructurePanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
358 |
label=_('Elements :')) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
359 |
structure_button_sizer.Add(structure_elements_label, flag=wx.ALIGN_BOTTOM) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
360 |
|
814 | 361 |
for name, bitmap, help in [ |
362 |
("StructureAddButton", "add_element", _("Add element")), |
|
363 |
("StructureDeleteButton", "remove_element", _("Remove element")), |
|
364 |
("StructureUpButton", "up", _("Move element up")), |
|
365 |
("StructureDownButton", "down", _("Move element down"))]: |
|
366 |
button = wx.lib.buttons.GenBitmapButton(self.StructurePanel, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
367 |
bitmap=GetBitmap(bitmap), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
368 |
size=wx.Size(28, 28), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
369 |
style=wx.NO_BORDER) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
370 |
button.SetToolTip(help) |
814 | 371 |
setattr(self, name, button) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
372 |
structure_button_sizer.Add(button) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
373 |
|
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
374 |
self.StructureElementsGrid = CustomGrid(self.StructurePanel, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
375 |
size=wx.Size(0, 150), style=wx.VSCROLL) |
3449
6279ec06df98
wxPython4 sequels: usual naming problem in grid cell change events, non kw-args to menu.Append and event not being skipped.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3303
diff
changeset
|
376 |
self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGED, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
377 |
self.OnStructureElementsGridCellChange) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
378 |
self.StructureElementsGrid.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:
1762
diff
changeset
|
379 |
self.OnStructureElementsGridEditorShown) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
380 |
structure_panel_sizer.Add(self.StructureElementsGrid, flag=wx.GROW) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
381 |
|
814 | 382 |
self.StructurePanel.SetSizer(structure_panel_sizer) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
383 |
|
814 | 384 |
self.Editor.SetSizer(self.MainSizer) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
385 |
|
814 | 386 |
def __init__(self, parent, tagname, window, controler): |
387 |
EditorPanel.__init__(self, parent, tagname, window, controler) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
388 |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
389 |
self.StructureElementDefaultValue = {"Name": "", "Type": DefaultType, "Initial Value": ""} |
814 | 390 |
self.StructureElementsTable = ElementsTable(self, [], GetElementsTableColnames()) |
391 |
self.StructureColSizes = [40, 150, 100, 250] |
|
392 |
self.StructureColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
393 |
|
814 | 394 |
self.StructureElementsGrid.SetTable(self.StructureElementsTable) |
395 |
self.StructureElementsGrid.SetButtons({"Add": self.StructureAddButton, |
|
396 |
"Delete": self.StructureDeleteButton, |
|
397 |
"Up": self.StructureUpButton, |
|
398 |
"Down": self.StructureDownButton}) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
399 |
|
1821
44a47d255d36
fix problem if DataTypeEditor was imported before localization is
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1812
diff
changeset
|
400 |
self.DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()]) |
44a47d255d36
fix problem if DataTypeEditor was imported before localization is
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1812
diff
changeset
|
401 |
|
814 | 402 |
def _AddStructureElement(new_row): |
403 |
self.StructureElementsTable.InsertRow(new_row, self.StructureElementDefaultValue.copy()) |
|
404 |
self.RefreshTypeInfos() |
|
405 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
|
406 |
return new_row |
|
407 |
setattr(self.StructureElementsGrid, "_AddRow", _AddStructureElement) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
408 |
|
814 | 409 |
def _DeleteStructureElement(row): |
410 |
self.StructureElementsTable.RemoveRow(row) |
|
411 |
self.RefreshTypeInfos() |
|
412 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
|
413 |
setattr(self.StructureElementsGrid, "_DeleteRow", _DeleteStructureElement) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
414 |
|
814 | 415 |
def _MoveStructureElement(row, move): |
416 |
new_row = self.StructureElementsTable.MoveRow(row, move) |
|
417 |
if new_row != row: |
|
418 |
self.RefreshTypeInfos() |
|
419 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
|
420 |
return new_row |
|
421 |
setattr(self.StructureElementsGrid, "_MoveRow", _MoveStructureElement) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
422 |
|
814 | 423 |
self.StructureElementsGrid.SetRowLabelSize(0) |
424 |
for col in range(self.StructureElementsTable.GetNumberCols()): |
|
425 |
attr = wx.grid.GridCellAttr() |
|
426 |
attr.SetAlignment(self.StructureColAlignements[col], wx.ALIGN_CENTRE) |
|
427 |
self.StructureElementsGrid.SetColAttr(col, attr) |
|
428 |
self.StructureElementsGrid.SetColMinimalWidth(col, self.StructureColSizes[col]) |
|
429 |
self.StructureElementsGrid.AutoSizeColumn(col, False) |
|
430 |
self.StructureElementsGrid.RefreshButtons() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
431 |
|
814 | 432 |
for datatype in GetDatatypeTypes(): |
433 |
self.DerivationType.Append(_(datatype)) |
|
434 |
self.SubrangePanel.Hide() |
|
435 |
self.EnumeratedPanel.Hide() |
|
436 |
self.ArrayPanel.Hide() |
|
437 |
self.StructurePanel.Hide() |
|
438 |
self.CurrentPanel = "Directly" |
|
439 |
self.Highlights = [] |
|
440 |
self.Initializing = False |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
441 |
|
814 | 442 |
self.HighlightControls = { |
443 |
("Directly", "base"): self.DirectlyBaseType, |
|
444 |
("Directly", "initial"): self.DirectlyInitialValue, |
|
445 |
("Subrange", "base"): self.SubrangeBaseType, |
|
446 |
("Subrange", "lower"): self.SubrangeMinimum, |
|
447 |
("Subrange", "upper"): self.SubrangeMaximum, |
|
448 |
("Subrange", "initial"): self.SubrangeInitialValue, |
|
449 |
("Enumerated", "value"): self.EnumeratedValues, |
|
450 |
("Enumerated", "initial"): self.EnumeratedInitialValue, |
|
451 |
("Array", "initial"): self.ArrayInitialValue, |
|
452 |
("Array", "base"): self.ArrayBaseType, |
|
453 |
("Array", "range"): self.ArrayDimensions, |
|
454 |
} |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
455 |
|
814 | 456 |
self.RefreshHighlightsTimer = wx.Timer(self, -1) |
457 |
self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
458 |
|
814 | 459 |
def GetBufferState(self): |
460 |
return self.Controler.GetBufferState() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
461 |
|
814 | 462 |
def Undo(self): |
463 |
self.Controler.LoadPrevious() |
|
464 |
self.ParentWindow.CloseTabsWithoutModel() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
465 |
|
814 | 466 |
def Redo(self): |
467 |
self.Controler.LoadNext() |
|
468 |
self.ParentWindow.CloseTabsWithoutModel() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
469 |
|
814 | 470 |
def HasNoModel(self): |
471 |
return self.Controler.GetEditedElement(self.TagName) is None |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
472 |
|
814 | 473 |
def RefreshView(self): |
474 |
self.Initializing = True |
|
475 |
self.DirectlyBaseType.Clear() |
|
476 |
self.ArrayBaseType.Clear() |
|
477 |
for datatype in self.Controler.GetDataTypes(self.TagName): |
|
478 |
self.DirectlyBaseType.Append(datatype) |
|
479 |
self.ArrayBaseType.Append(datatype) |
|
480 |
self.DirectlyBaseType.SetSelection(0) |
|
481 |
self.SubrangeBaseType.Clear() |
|
482 |
words = self.TagName.split("::") |
|
483 |
for base_type in self.Controler.GetSubrangeBaseTypes(words[1]): |
|
484 |
self.SubrangeBaseType.Append(base_type) |
|
485 |
self.SubrangeBaseType.SetSelection(0) |
|
486 |
self.RefreshBoundsRange() |
|
487 |
type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
|
488 |
if type_infos is not None: |
|
489 |
datatype = type_infos["type"] |
|
490 |
self.DerivationType.SetStringSelection(_(datatype)) |
|
491 |
if type_infos["type"] == "Directly": |
|
492 |
self.DirectlyBaseType.SetStringSelection(type_infos["base_type"]) |
|
493 |
self.DirectlyInitialValue.SetValue(type_infos["initial"]) |
|
494 |
elif type_infos["type"] == "Subrange": |
|
495 |
self.SubrangeBaseType.SetStringSelection(type_infos["base_type"]) |
|
496 |
self.RefreshBoundsRange() |
|
497 |
self.SubrangeMinimum.SetValue(int(type_infos["min"])) |
|
498 |
self.SubrangeMaximum.SetValue(int(type_infos["max"])) |
|
499 |
self.RefreshSubrangeInitialValueRange() |
|
500 |
if type_infos["initial"] != "": |
|
501 |
self.SubrangeInitialValue.SetValue(int(type_infos["initial"])) |
|
502 |
else: |
|
503 |
self.SubrangeInitialValue.SetValue(type_infos["min"]) |
|
504 |
elif type_infos["type"] == "Enumerated": |
|
505 |
self.EnumeratedValues.SetStrings(type_infos["values"]) |
|
506 |
self.RefreshEnumeratedValues() |
|
507 |
self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"]) |
|
508 |
elif type_infos["type"] == "Array": |
|
509 |
self.ArrayBaseType.SetStringSelection(type_infos["base_type"]) |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
3449
diff
changeset
|
510 |
self.ArrayDimensions.SetStrings(list(map("..".join, type_infos["dimensions"]))) |
814 | 511 |
self.ArrayInitialValue.SetValue(type_infos["initial"]) |
512 |
elif type_infos["type"] == "Structure": |
|
513 |
self.StructureElementsTable.SetData(type_infos["elements"]) |
|
514 |
self.RefreshDisplayedInfos() |
|
515 |
self.ShowHighlights() |
|
516 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
|
517 |
self.StructureElementsGrid.RefreshButtons() |
|
518 |
self.Initializing = False |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
519 |
|
814 | 520 |
def OnDerivationTypeChanged(self, event): |
521 |
wx.CallAfter(self.RefreshDisplayedInfos) |
|
522 |
wx.CallAfter(self.RefreshTypeInfos) |
|
523 |
event.Skip() |
|
524 |
||
525 |
def OnReturnKeyPressed(self, event): |
|
526 |
self.RefreshTypeInfos() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
527 |
|
814 | 528 |
def OnInfosChanged(self, event): |
529 |
self.RefreshTypeInfos() |
|
530 |
event.Skip() |
|
531 |
||
532 |
def OnSubrangeBaseTypeChanged(self, event): |
|
533 |
self.RefreshBoundsRange() |
|
534 |
self.RefreshTypeInfos() |
|
535 |
event.Skip() |
|
536 |
||
537 |
def OnSubrangeMinimumChanged(self, event): |
|
538 |
if not self.Initializing: |
|
539 |
wx.CallAfter(self.SubrangeMinimum.SetValue, min(self.SubrangeMaximum.GetValue(), self.SubrangeMinimum.GetValue())) |
|
540 |
wx.CallAfter(self.RefreshSubrangeInitialValueRange) |
|
541 |
wx.CallAfter(self.RefreshTypeInfos) |
|
542 |
event.Skip() |
|
543 |
||
544 |
def OnSubrangeMaximumChanged(self, event): |
|
545 |
if not self.Initializing: |
|
546 |
wx.CallAfter(self.SubrangeMaximum.SetValue, max(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue())) |
|
547 |
wx.CallAfter(self.RefreshSubrangeInitialValueRange) |
|
548 |
wx.CallAfter(self.RefreshTypeInfos) |
|
549 |
event.Skip() |
|
550 |
||
551 |
def OnDimensionsChanged(self, event): |
|
552 |
wx.CallAfter(self.RefreshTypeInfos) |
|
553 |
event.Skip() |
|
554 |
||
555 |
def OnEnumeratedValueEndEdit(self, event): |
|
556 |
text = event.GetText() |
|
557 |
values = self.EnumeratedValues.GetStrings() |
|
558 |
index = event.GetIndex() |
|
559 |
if index >= len(values) or values[index].upper() != text.upper(): |
|
560 |
if text.upper() in [value.upper() for value in values]: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
561 |
message = wx.MessageDialog(self, _("\"%s\" value already defined!") % text, _("Error"), wx.OK | wx.ICON_ERROR) |
814 | 562 |
message.ShowModal() |
563 |
message.Destroy() |
|
564 |
event.Veto() |
|
565 |
elif text.upper() in IEC_KEYWORDS: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
566 |
message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!") % text, _("Error"), wx.OK | wx.ICON_ERROR) |
814 | 567 |
message.ShowModal() |
568 |
message.Destroy() |
|
569 |
else: |
|
570 |
initial_selected = None |
|
571 |
if index < len(values) and self.EnumeratedInitialValue.GetStringSelection() == values[index]: |
|
572 |
initial_selected = text |
|
573 |
wx.CallAfter(self.RefreshEnumeratedValues, initial_selected) |
|
574 |
wx.CallAfter(self.RefreshTypeInfos) |
|
575 |
event.Skip() |
|
576 |
else: |
|
577 |
event.Skip() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
578 |
|
814 | 579 |
def OnEnumeratedValuesChanged(self, event): |
580 |
wx.CallAfter(self.RefreshEnumeratedValues) |
|
581 |
wx.CallAfter(self.RefreshTypeInfos) |
|
582 |
event.Skip() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
583 |
|
1658
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
584 |
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:
1742
diff
changeset
|
585 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
1658
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
586 |
dialog.ShowModal() |
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
587 |
dialog.Destroy() |
1735
c02818d7e29f
clean-up: fix PEP8 W293 blank line contains whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
588 |
|
814 | 589 |
def OnStructureElementsGridCellChange(self, event): |
590 |
row, col = event.GetRow(), event.GetCol() |
|
947 | 591 |
colname = self.StructureElementsTable.GetColLabelValue(col, False) |
814 | 592 |
value = self.StructureElementsTable.GetValue(row, col) |
593 |
if colname == "Name": |
|
1658
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
594 |
message = None |
814 | 595 |
if not TestIdentifier(value): |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1658
diff
changeset
|
596 |
message = _("\"%s\" is not a valid identifier!") % value |
814 | 597 |
elif value.upper() in IEC_KEYWORDS: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1658
diff
changeset
|
598 |
message = _("\"%s\" is a keyword. It can't be used!") % value |
1753
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
599 |
# elif value.upper() in self.PouNames: |
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
600 |
# message = _("A pou with \"%s\" as name exists!")%value |
814 | 601 |
elif value.upper() in [var["Name"].upper() for idx, var in enumerate(self.StructureElementsTable.GetData()) if idx != row]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1658
diff
changeset
|
602 |
message = _("An element named \"%s\" already exists in this structure!") % value |
814 | 603 |
else: |
604 |
self.RefreshTypeInfos() |
|
605 |
wx.CallAfter(self.StructureElementsTable.ResetView, self.StructureElementsGrid) |
|
1753
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
606 |
# old_value = self.Table.GetOldValue() |
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
607 |
# if old_value != "": |
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
608 |
# self.Controler.UpdateEditedElementUsedVariable(self.TagName, old_value, value) |
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
609 |
# self.Controler.BufferProject() |
814 | 610 |
event.Skip() |
1658
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
611 |
|
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
612 |
if message is not None: |
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
613 |
event.Veto() |
ba6a6d6e989c
fix twice shown error message box, when wrong non-valid IEC identifier entered
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
614 |
wx.CallAfter(self.ShowErrorMessage, message) |
814 | 615 |
else: |
616 |
self.RefreshTypeInfos() |
|
617 |
wx.CallAfter(self.StructureElementsTable.ResetView, self.StructureElementsGrid) |
|
618 |
event.Skip() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
619 |
|
814 | 620 |
def OnStructureElementsGridSelectCell(self, event): |
621 |
wx.CallAfter(self.RefreshStructureButtons) |
|
622 |
event.Skip() |
|
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
623 |
|
814 | 624 |
def OnStructureElementsGridEditorShown(self, event): |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
625 |
row, col = event.GetRow(), event.GetCol() |
947 | 626 |
if self.StructureElementsTable.GetColLabelValue(col, False) == "Type": |
814 | 627 |
type_menu = wx.Menu(title='') |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
628 |
|
814 | 629 |
base_menu = wx.Menu(title='') |
630 |
for base_type in self.Controler.GetBaseTypes(): |
|
2737
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
631 |
new_entry = AppendMenu(base_menu, help='', kind=wx.ITEM_NORMAL, text=base_type) |
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
632 |
self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(base_type), new_entry) |
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
633 |
type_menu.AppendMenu(wx.ID_ANY, _("Base Types"), base_menu) |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
634 |
|
814 | 635 |
datatype_menu = wx.Menu(title='') |
636 |
for datatype in self.Controler.GetDataTypes(self.TagName, False): |
|
2737
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
637 |
new_entry = AppendMenu(datatype_menu, help='', kind=wx.ITEM_NORMAL, text=datatype) |
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
638 |
self.Bind(wx.EVT_MENU, self.GetElementTypeFunction(datatype), new_entry) |
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
639 |
type_menu.AppendMenu(wx.ID_ANY, _("User Data Types"), datatype_menu) |
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
640 |
|
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
641 |
new_entry = AppendMenu(type_menu, help='', kind=wx.ITEM_NORMAL, text=_("Array")) |
38afed869ff6
Finished fixing Wx IDs abuse. There was still some wasted IDs because of wx.NewId calls in many places where it wasn't needed, and those IDs were not re-used. As a consequence Beremiz was making exception crashing after a few hours of intensive use.
Edouard Tisserant
parents:
2450
diff
changeset
|
642 |
self.Bind(wx.EVT_MENU, self.ElementArrayTypeFunction, new_entry) |
864
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
643 |
|
814 | 644 |
rect = self.StructureElementsGrid.BlockToDeviceRect((row, col), (row, col)) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
645 |
self.StructureElementsGrid.PopupMenu(type_menu, rect.x + rect.width, rect.y + self.StructureElementsGrid.GetColLabelSize()) |
814 | 646 |
type_menu.Destroy() |
647 |
event.Veto() |
|
648 |
else: |
|
649 |
event.Skip() |
|
650 |
||
651 |
def GetElementTypeFunction(self, base_type): |
|
652 |
def ElementTypeFunction(event): |
|
653 |
row = self.StructureElementsGrid.GetGridCursorRow() |
|
654 |
self.StructureElementsTable.SetValueByName(row, "Type", base_type) |
|
655 |
self.RefreshTypeInfos() |
|
656 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
|
657 |
return ElementTypeFunction |
|
658 |
||
864
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
659 |
def ElementArrayTypeFunction(self, event): |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
660 |
row = self.StructureElementsGrid.GetGridCursorRow() |
1412
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
661 |
dialog = ArrayTypeDialog(self, |
50192dd2f5ff
Added plcopen.definitions.DefaultType, set to INT.
Edouard Tisserant
parents:
947
diff
changeset
|
662 |
self.Controler.GetDataTypes(self.TagName), |
864
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
663 |
self.StructureElementsTable.GetValueByName(row, "Type")) |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
664 |
if dialog.ShowModal() == wx.ID_OK: |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
665 |
self.StructureElementsTable.SetValueByName(row, "Type", dialog.GetValue()) |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
666 |
self.RefreshTypeInfos() |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
667 |
self.StructureElementsTable.ResetView(self.StructureElementsGrid) |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
668 |
dialog.Destroy() |
bf4f7f0801b9
Adding support for direct array declaration in structure element declaration
Laurent Bessard
parents:
814
diff
changeset
|
669 |
|
814 | 670 |
def RefreshDisplayedInfos(self): |
1821
44a47d255d36
fix problem if DataTypeEditor was imported before localization is
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1812
diff
changeset
|
671 |
selected = self.DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()] |
814 | 672 |
if selected != self.CurrentPanel: |
673 |
if self.CurrentPanel == "Directly": |
|
674 |
self.DirectlyPanel.Hide() |
|
675 |
elif self.CurrentPanel == "Subrange": |
|
676 |
self.SubrangePanel.Hide() |
|
677 |
elif self.CurrentPanel == "Enumerated": |
|
678 |
self.EnumeratedPanel.Hide() |
|
679 |
elif self.CurrentPanel == "Array": |
|
680 |
self.ArrayPanel.Hide() |
|
681 |
elif self.CurrentPanel == "Structure": |
|
682 |
self.StructurePanel.Hide() |
|
683 |
self.CurrentPanel = selected |
|
684 |
if selected == "Directly": |
|
685 |
self.DirectlyPanel.Show() |
|
686 |
elif selected == "Subrange": |
|
687 |
self.SubrangePanel.Show() |
|
688 |
elif selected == "Enumerated": |
|
689 |
self.EnumeratedPanel.Show() |
|
690 |
elif selected == "Array": |
|
691 |
self.ArrayPanel.Show() |
|
692 |
elif selected == "Structure": |
|
693 |
self.StructurePanel.Show() |
|
694 |
self.MainSizer.Layout() |
|
695 |
||
696 |
def RefreshEnumeratedValues(self, initial_selected=None): |
|
697 |
if initial_selected is None: |
|
698 |
initial_selected = self.EnumeratedInitialValue.GetStringSelection() |
|
699 |
self.EnumeratedInitialValue.Clear() |
|
700 |
self.EnumeratedInitialValue.Append("") |
|
701 |
for value in self.EnumeratedValues.GetStrings(): |
|
702 |
self.EnumeratedInitialValue.Append(value) |
|
703 |
self.EnumeratedInitialValue.SetStringSelection(initial_selected) |
|
704 |
||
705 |
def RefreshBoundsRange(self): |
|
706 |
range = self.Controler.GetDataTypeRange(self.SubrangeBaseType.GetStringSelection()) |
|
707 |
if range is not None: |
|
708 |
min_value, max_value = range |
|
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
709 |
self.SubrangeMinimum.SetBounds(min_value, max_value) |
814 | 710 |
self.SubrangeMinimum.SetValue(min(max(min_value, self.SubrangeMinimum.GetValue()), max_value)) |
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
711 |
self.SubrangeMaximum.SetBounds(min_value, max_value) |
814 | 712 |
self.SubrangeMaximum.SetValue(min(max(min_value, self.SubrangeMaximum.GetValue()), max_value)) |
713 |
||
714 |
def RefreshSubrangeInitialValueRange(self): |
|
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
715 |
self.SubrangeInitialValue.SetBounds(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue()) |
814 | 716 |
|
717 |
def RefreshTypeInfos(self): |
|
1821
44a47d255d36
fix problem if DataTypeEditor was imported before localization is
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1812
diff
changeset
|
718 |
selected = self.DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()] |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
719 |
infos = {"type": selected} |
814 | 720 |
if selected == "Directly": |
721 |
infos["base_type"] = self.DirectlyBaseType.GetStringSelection() |
|
722 |
infos["initial"] = self.DirectlyInitialValue.GetValue() |
|
723 |
elif selected == "Subrange": |
|
724 |
infos["base_type"] = self.SubrangeBaseType.GetStringSelection() |
|
725 |
infos["min"] = str(self.SubrangeMinimum.GetValue()) |
|
726 |
infos["max"] = str(self.SubrangeMaximum.GetValue()) |
|
727 |
initial_value = self.SubrangeInitialValue.GetValue() |
|
728 |
if initial_value == infos["min"]: |
|
729 |
infos["initial"] = "" |
|
730 |
else: |
|
731 |
infos["initial"] = str(initial_value) |
|
732 |
elif selected == "Enumerated": |
|
733 |
infos["values"] = self.EnumeratedValues.GetStrings() |
|
734 |
infos["initial"] = self.EnumeratedInitialValue.GetStringSelection() |
|
735 |
elif selected == "Array": |
|
736 |
infos["base_type"] = self.ArrayBaseType.GetStringSelection() |
|
737 |
infos["dimensions"] = [] |
|
738 |
for dimensions in self.ArrayDimensions.GetStrings(): |
|
739 |
result = DIMENSION_MODEL.match(dimensions) |
|
740 |
if result is None: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
741 |
message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!") % dimensions, _("Error"), wx.OK | wx.ICON_ERROR) |
814 | 742 |
message.ShowModal() |
743 |
message.Destroy() |
|
744 |
self.RefreshView() |
|
745 |
return |
|
746 |
bounds = result.groups() |
|
747 |
if int(bounds[0]) >= int(bounds[1]): |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
748 |
message = wx.MessageDialog(self, _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.") % dimensions, _("Error"), wx.OK | wx.ICON_ERROR) |
814 | 749 |
message.ShowModal() |
750 |
message.Destroy() |
|
751 |
self.RefreshView() |
|
752 |
return |
|
753 |
infos["dimensions"].append(bounds) |
|
754 |
infos["initial"] = self.ArrayInitialValue.GetValue() |
|
755 |
elif selected == "Structure": |
|
756 |
infos["elements"] = self.StructureElementsTable.GetData() |
|
757 |
infos["initial"] = "" |
|
758 |
self.Controler.SetDataTypeInfos(self.TagName, infos) |
|
759 |
self.ParentWindow.RefreshTitle() |
|
760 |
self.ParentWindow.RefreshFileMenu() |
|
761 |
self.ParentWindow.RefreshEditMenu() |
|
762 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
763 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
764 |
# Highlights showing functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
765 |
# ------------------------------------------------------------------------------- |
814 | 766 |
|
767 |
def OnRefreshHighlightsTimer(self, event): |
|
768 |
self.RefreshView() |
|
769 |
event.Skip() |
|
770 |
||
771 |
def ClearHighlights(self, highlight_type=None): |
|
772 |
if highlight_type is None: |
|
773 |
self.Highlights = [] |
|
774 |
else: |
|
775 |
self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type] |
|
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
3449
diff
changeset
|
776 |
for control in self.HighlightControls.values(): |
814 | 777 |
if isinstance(control, (wx.ComboBox, wx.SpinCtrl)): |
778 |
control.SetBackgroundColour(wx.NullColour) |
|
779 |
control.SetForegroundColour(wx.NullColour) |
|
780 |
elif isinstance(control, wx.TextCtrl): |
|
1812
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
781 |
value = control.GetValueStr() if isinstance(control, CustomIntCtrl) else \ |
8626a4948d5e
use CustomIntCtrl instead of wx.SpinCtrl because it doesn't support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
782 |
control.GetValue() |
814 | 783 |
control.SetStyle(0, len(value), wx.TextAttr(wx.NullColour)) |
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
784 |
elif isinstance(control, wx.adv.EditableListBox): |
814 | 785 |
listctrl = control.GetListCtrl() |
3750
f62625418bff
automated conversion using 2to3-3.9 tool
GP Orcullo <kinsamanka@gmail.com>
parents:
3449
diff
changeset
|
786 |
for i in range(listctrl.GetItemCount()): |
814 | 787 |
listctrl.SetItemBackgroundColour(i, wx.NullColour) |
788 |
listctrl.SetItemTextColour(i, wx.NullColour) |
|
789 |
self.StructureElementsTable.ClearHighlights(highlight_type) |
|
790 |
self.RefreshView() |
|
791 |
||
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
792 |
def AddHighlight(self, infos, start, end, highlight_type): |
814 | 793 |
self.Highlights.append((infos, start, end, highlight_type)) |
794 |
self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True) |
|
795 |
||
796 |
def ShowHighlights(self): |
|
797 |
type_infos = self.Controler.GetDataTypeInfos(self.TagName) |
|
798 |
for infos, start, end, highlight_type in self.Highlights: |
|
799 |
if infos[0] == "struct": |
|
800 |
self.StructureElementsTable.AddHighlight(infos[1:], highlight_type) |
|
801 |
else: |
|
802 |
control = self.HighlightControls.get((type_infos["type"], infos[0]), None) |
|
803 |
if control is not None: |
|
804 |
if isinstance(control, (wx.ComboBox, wx.SpinCtrl)): |
|
805 |
control.SetBackgroundColour(highlight_type[0]) |
|
806 |
control.SetForegroundColour(highlight_type[1]) |
|
807 |
elif isinstance(control, wx.TextCtrl): |
|
808 |
control.SetStyle(start[1], end[1] + 1, wx.TextAttr(highlight_type[1], highlight_type[0])) |
|
3303
0ffb41625592
Preliminary support for WxPython 4.1.0. Needs more testing. Grid selection/focus seems broken, and probably many other bugs hidden in dialogs and editors.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2737
diff
changeset
|
809 |
elif isinstance(control, wx.adv.EditableListBox): |
814 | 810 |
listctrl = control.GetListCtrl() |
811 |
listctrl.SetItemBackgroundColour(infos[1], highlight_type[0]) |
|
812 |
listctrl.SetItemTextColour(infos[1], highlight_type[1]) |
|
813 |
listctrl.Select(listctrl.FocusedItem, False) |