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