author | Edouard Tisserant |
Tue, 20 Aug 2019 10:30:59 +0200 | |
branch | svghmi |
changeset 2762 | 282500e03dbc |
parent 1957 | 2d1cc4f5e4ef |
child 3303 | 0ffb41625592 |
permissions | -rw-r--r-- |
814 | 1 |
# -*- coding: utf-8 -*- |
2 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
3 |
# 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:
1347
diff
changeset
|
4 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
5 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
6 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
7 |
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
8 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
10 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
11 |
# 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:
1347
diff
changeset
|
12 |
# 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:
1347
diff
changeset
|
13 |
# 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:
1347
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
15 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
16 |
# 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:
1347
diff
changeset
|
17 |
# 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:
1347
diff
changeset
|
18 |
# 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:
1347
diff
changeset
|
19 |
# GNU General Public License for more details. |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
20 |
# |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1347
diff
changeset
|
21 |
# 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:
1347
diff
changeset
|
22 |
# 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:
1347
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
25 |
|
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1834
diff
changeset
|
26 |
from __future__ import absolute_import |
814 | 27 |
import wx |
28 |
import wx.grid |
|
29 |
import wx.lib.buttons |
|
30 |
||
31 |
from controls import CustomGrid, CustomTable |
|
1957
2d1cc4f5e4ef
GetEditedElementInstancesInfos now optimized as well. Forgotten because not using [R.I.P]LibraryResolver, but still XSLT compiling was hapenning on each call.
Edouard Tisserant
parents:
1881
diff
changeset
|
32 |
from plcopen.BlockInstanceCollector import _ActionInfos |
814 | 33 |
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:
1745
diff
changeset
|
34 |
from util.TranslationCatalogs import NoTranslate |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
35 |
# ------------------------------------------------------------------------------- |
814 | 36 |
# Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
37 |
# ------------------------------------------------------------------------------- |
814 | 38 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
39 |
|
814 | 40 |
def GetActionTableColnames(): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
41 |
_ = NoTranslate |
814 | 42 |
return [_("Qualifier"), _("Duration"), _("Type"), _("Value"), _("Indicator")] |
43 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
44 |
|
814 | 45 |
def GetTypeList(): |
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
46 |
_ = NoTranslate |
814 | 47 |
return [_("Action"), _("Variable"), _("Inline")] |
48 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
49 |
# ------------------------------------------------------------------------------- |
814 | 50 |
# Action Table |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
51 |
# ------------------------------------------------------------------------------- |
814 | 52 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
53 |
|
814 | 54 |
class ActionTable(CustomTable): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
55 |
|
814 | 56 |
def GetValue(self, row, col): |
57 |
if row < self.GetNumberRows(): |
|
58 |
colname = self.GetColLabelValue(col, False) |
|
1339 | 59 |
value = getattr(self.data[row], colname.lower()) |
814 | 60 |
if colname == "Type": |
1339 | 61 |
return _(value) |
62 |
return value |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
63 |
|
814 | 64 |
def SetValue(self, row, col, value): |
65 |
if col < len(self.colnames): |
|
66 |
colname = self.GetColLabelValue(col, False) |
|
67 |
if colname == "Type": |
|
68 |
value = self.Parent.TranslateType[value] |
|
1339 | 69 |
elif colname == "Qualifier" and not self.Parent.DurationList[value]: |
70 |
self.data[row].duration = "" |
|
71 |
setattr(self.data[row], colname.lower(), value) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
72 |
|
814 | 73 |
def _updateColAttrs(self, grid): |
74 |
""" |
|
75 |
wx.Grid -> update the column attributes to add the |
|
76 |
appropriate renderer given the column name. |
|
77 |
||
78 |
Otherwise default to the default renderer. |
|
79 |
""" |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
80 |
|
814 | 81 |
for row in range(self.GetNumberRows()): |
82 |
for col in range(self.GetNumberCols()): |
|
83 |
editor = None |
|
84 |
renderer = None |
|
85 |
readonly = False |
|
86 |
colname = self.GetColLabelValue(col, False) |
|
87 |
if colname == "Qualifier": |
|
88 |
editor = wx.grid.GridCellChoiceEditor() |
|
89 |
editor.SetParameters(self.Parent.QualifierList) |
|
90 |
if colname == "Duration": |
|
91 |
editor = wx.grid.GridCellTextEditor() |
|
92 |
renderer = wx.grid.GridCellStringRenderer() |
|
1339 | 93 |
readonly = not self.Parent.DurationList[self.data[row].qualifier] |
814 | 94 |
elif colname == "Type": |
95 |
editor = wx.grid.GridCellChoiceEditor() |
|
96 |
editor.SetParameters(self.Parent.TypeList) |
|
97 |
elif colname == "Value": |
|
1339 | 98 |
value_type = self.data[row].type |
99 |
if value_type == "Action": |
|
814 | 100 |
editor = wx.grid.GridCellChoiceEditor() |
101 |
editor.SetParameters(self.Parent.ActionList) |
|
1339 | 102 |
elif value_type == "Variable": |
814 | 103 |
editor = wx.grid.GridCellChoiceEditor() |
104 |
editor.SetParameters(self.Parent.VariableList) |
|
1339 | 105 |
elif value_type == "Inline": |
814 | 106 |
editor = wx.grid.GridCellTextEditor() |
107 |
renderer = wx.grid.GridCellStringRenderer() |
|
108 |
elif colname == "Indicator": |
|
109 |
editor = wx.grid.GridCellChoiceEditor() |
|
110 |
editor.SetParameters(self.Parent.VariableList) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
111 |
|
814 | 112 |
grid.SetCellEditor(row, col, editor) |
113 |
grid.SetCellRenderer(row, col, renderer) |
|
114 |
grid.SetReadOnly(row, col, readonly) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
115 |
|
814 | 116 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
117 |
self.ResizeRow(grid, row) |
|
118 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
119 |
# ------------------------------------------------------------------------------- |
814 | 120 |
# Action Block Dialog |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
121 |
# ------------------------------------------------------------------------------- |
814 | 122 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
123 |
|
814 | 124 |
class ActionBlockDialog(wx.Dialog): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
125 |
|
814 | 126 |
def __init__(self, parent): |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
127 |
wx.Dialog.__init__(self, parent, title=_('Edit action block properties')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
128 |
|
814 | 129 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) |
130 |
main_sizer.AddGrowableCol(0) |
|
131 |
main_sizer.AddGrowableRow(1) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
132 |
|
814 | 133 |
top_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
134 |
top_sizer.AddGrowableCol(0) |
|
135 |
top_sizer.AddGrowableRow(0) |
|
136 |
main_sizer.AddSizer(top_sizer, border=20, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
137 |
flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
138 |
|
814 | 139 |
actions_label = wx.StaticText(self, label=_('Actions:')) |
140 |
top_sizer.AddWindow(actions_label, flag=wx.ALIGN_BOTTOM) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
141 |
|
814 | 142 |
for name, bitmap, help in [ |
143 |
("AddButton", "add_element", _("Add action")), |
|
144 |
("DeleteButton", "remove_element", _("Remove action")), |
|
145 |
("UpButton", "up", _("Move action up")), |
|
146 |
("DownButton", "down", _("Move action down"))]: |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
147 |
button = wx.lib.buttons.GenBitmapButton( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
148 |
self, 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
|
149 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
814 | 150 |
button.SetToolTipString(help) |
151 |
setattr(self, name, button) |
|
152 |
top_sizer.AddWindow(button) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
153 |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
154 |
self.ActionsGrid = CustomGrid(self, size=wx.Size(-1, 250), style=wx.VSCROLL) |
814 | 155 |
self.ActionsGrid.DisableDragGridSize() |
156 |
self.ActionsGrid.EnableScrolling(False, True) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
157 |
self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, |
814 | 158 |
self.OnActionsGridCellChange) |
159 |
main_sizer.AddSizer(self.ActionsGrid, border=20, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
160 |
flag=wx.GROW | wx.LEFT | wx.RIGHT) |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
161 |
|
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
162 |
button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE) |
814 | 163 |
self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
164 |
main_sizer.AddSizer(button_sizer, border=20, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
165 |
flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
166 |
|
814 | 167 |
self.SetSizer(main_sizer) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
168 |
|
814 | 169 |
self.Table = ActionTable(self, [], GetActionTableColnames()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
170 |
typelist = GetTypeList() |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
171 |
self.TypeList = ",".join(map(_, typelist)) |
814 | 172 |
self.TranslateType = dict([(_(value), value) for value in typelist]) |
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
173 |
self.ColSizes = [60, 90, 130, 200, 50] |
814 | 174 |
self.ColAlignements = [wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
175 |
|
814 | 176 |
self.ActionsGrid.SetTable(self.Table) |
1339 | 177 |
self.ActionsGrid.SetDefaultValue(_ActionInfos("N", "Action", "", "", "")) |
814 | 178 |
self.ActionsGrid.SetButtons({"Add": self.AddButton, |
179 |
"Delete": self.DeleteButton, |
|
180 |
"Up": self.UpButton, |
|
181 |
"Down": self.DownButton}) |
|
182 |
self.ActionsGrid.SetRowLabelSize(0) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
183 |
|
814 | 184 |
for col in range(self.Table.GetNumberCols()): |
185 |
attr = wx.grid.GridCellAttr() |
|
186 |
attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE) |
|
187 |
self.ActionsGrid.SetColAttr(col, attr) |
|
188 |
self.ActionsGrid.SetColMinimalWidth(col, self.ColSizes[col]) |
|
189 |
self.ActionsGrid.AutoSizeColumn(col, False) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
190 |
|
814 | 191 |
self.Table.ResetView(self.ActionsGrid) |
192 |
self.ActionsGrid.SetFocus() |
|
193 |
self.ActionsGrid.RefreshButtons() |
|
1696
8043f32de7b8
make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
194 |
self.Fit() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
195 |
|
814 | 196 |
def OnOK(self, event): |
197 |
self.ActionsGrid.CloseEditControl() |
|
198 |
self.EndModal(wx.ID_OK) |
|
199 |
||
200 |
def OnActionsGridCellChange(self, event): |
|
201 |
wx.CallAfter(self.Table.ResetView, self.ActionsGrid) |
|
202 |
event.Skip() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
203 |
|
814 | 204 |
def SetQualifierList(self, list): |
1339 | 205 |
self.QualifierList = ",".join(list) |
814 | 206 |
self.DurationList = list |
207 |
||
208 |
def SetVariableList(self, list): |
|
1347
533741e5075c
Fixed pou variables information loading stylesheet
Laurent Bessard
parents:
1340
diff
changeset
|
209 |
self.VariableList = "," + ",".join([variable.Name for variable in list]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
210 |
|
814 | 211 |
def SetActionList(self, list): |
212 |
self.ActionList = "," + ",".join(list) |
|
213 |
||
214 |
def SetValues(self, actions): |
|
215 |
for action in actions: |
|
1340
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
216 |
row = action.copy() |
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
217 |
if row.type == "reference" and row.value in self.ActionList: |
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
218 |
row.type = "Action" |
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
219 |
elif row.type == "reference" and row.value in self.VariableList: |
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
220 |
row.type = "Variable" |
814 | 221 |
else: |
1340
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
222 |
row.type = "Inline" |
7e5702d1f246
Fixed bug when cancelling ActionBlockDialog
Laurent Bessard
parents:
1339
diff
changeset
|
223 |
self.Table.AppendRow(row) |
814 | 224 |
self.Table.ResetView(self.ActionsGrid) |
225 |
if len(actions) > 0: |
|
226 |
self.ActionsGrid.SetGridCursor(0, 0) |
|
227 |
self.ActionsGrid.RefreshButtons() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1696
diff
changeset
|
228 |
|
814 | 229 |
def GetValues(self): |
1339 | 230 |
actions = self.Table.GetData() |
231 |
for action in actions: |
|
232 |
if action.type in ["Action", "Variable"]: |
|
233 |
action.type = "reference" |
|
814 | 234 |
else: |
1339 | 235 |
action.type = "inline" |
236 |
return actions |