author | gabriele at naustech dot com |
Thu, 12 Jun 2014 14:07:16 +0200 | |
changeset 791 | 7740ac6fdedc |
parent 789 | a82d867e7850 |
permissions | -rw-r--r-- |
205 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of CanFestival, a library implementing CanOpen Stack. |
|
5 |
# |
|
6 |
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD |
|
7 |
# |
|
8 |
#See COPYING file for copyrights details. |
|
9 |
# |
|
10 |
#This library is free software; you can redistribute it and/or |
|
11 |
#modify it under the terms of the GNU Lesser General Public |
|
12 |
#License as published by the Free Software Foundation; either |
|
13 |
#version 2.1 of the License, or (at your option) any later version. |
|
14 |
# |
|
15 |
#This library is distributed in the hope that it will be useful, |
|
16 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 |
#Lesser General Public License for more details. |
|
19 |
# |
|
20 |
#You should have received a copy of the GNU Lesser General Public |
|
21 |
#License along with this library; if not, write to the Free Software |
|
22 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
||
24 |
import wx |
|
25 |
import wx.grid |
|
26 |
||
27 |
from types import * |
|
281
685d9a26e4f9
Obsolete example files in objdictgen/examples replaced by some new equivalents
lbessard
parents:
277
diff
changeset
|
28 |
from commondialogs import * |
205 | 29 |
|
206 | 30 |
from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes |
205 | 31 |
|
32 |
ColSizes = [75, 250, 150, 125, 100, 60, 250] |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
33 |
ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_RIGHT, wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_LEFT] |
580 | 34 |
|
35 |
def GetAccessList(write=True): |
|
36 |
_ = lambda x : x |
|
37 |
if write: |
|
38 |
return [_("Read Only"), _("Write Only"), _("Read/Write")] |
|
39 |
return [_("Read Only"), _("Read/Write")] |
|
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
40 |
AccessList = ",".join(map(_, GetAccessList())) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
41 |
RAccessList = ",".join(map(_, GetAccessList(False))) |
580 | 42 |
ACCESS_LIST_DICT = dict([(_(access), access) for access in GetAccessList()]) |
43 |
||
44 |
def GetBoolList(): |
|
45 |
_ = lambda x : x |
|
46 |
return [_("True"), _("False")] |
|
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
47 |
BoolList = ",".join(map(_, GetBoolList())) |
580 | 48 |
BOOL_LIST_DICT = dict([(_(bool), bool) for bool in GetBoolList()]) |
49 |
||
50 |
def GetOptionList(): |
|
51 |
_ = lambda x : x |
|
52 |
return [_("Yes"), _("No")] |
|
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
53 |
OptionList = ",".join(map(_, GetOptionList())) |
580 | 54 |
OPTION_LIST_DICT = dict([(_(option), option) for option in GetOptionList()]) |
55 |
||
56 |
[USER_TYPE, SDO_SERVER, SDO_CLIENT, |
|
57 |
PDO_TRANSMIT, PDO_RECEIVE, MAP_VARIABLE] = range(6) |
|
58 |
||
59 |
INDEXCHOICE_OPTIONS = { |
|
60 |
USER_TYPE: (_("User Type"), 0, "AddUserType"), |
|
61 |
SDO_SERVER: (_("SDO Server"), 1, "AddSDOServerToCurrent"), |
|
62 |
SDO_CLIENT: (_("SDO Client"), 1, "AddSDOClientToCurrent"), |
|
63 |
PDO_RECEIVE: (_("PDO Receive"), 1, "AddPDOReceiveToCurrent"), |
|
64 |
PDO_TRANSMIT: (_("PDO Transmit"), 1, "AddPDOTransmitToCurrent"), |
|
65 |
MAP_VARIABLE: (_("Map Variable"), 0, "AddMapVariable") |
|
66 |
} |
|
67 |
||
68 |
INDEXCHOICE_OPTIONS_DICT = dict([(translation, option) for option, (translation, object, function) in INDEXCHOICE_OPTIONS.iteritems()]) |
|
69 |
||
70 |
INDEXCHOICE_SECTIONS = { |
|
71 |
0 : [USER_TYPE], |
|
72 |
2 : [SDO_SERVER, SDO_CLIENT], |
|
73 |
3 : [PDO_RECEIVE], |
|
74 |
4 : [PDO_RECEIVE], |
|
75 |
5 : [PDO_TRANSMIT], |
|
76 |
6 : [PDO_TRANSMIT], |
|
77 |
8 : [MAP_VARIABLE], |
|
78 |
} |
|
79 |
||
80 |
def GetSubindexTableColnames(): |
|
81 |
_ = lambda x : x |
|
82 |
return [_("subindex"), _("name"), _("type"), _("value"), _("access"), _("save"), _("comment")] |
|
205 | 83 |
|
84 |
DictionaryOrganisation = [ |
|
85 |
{"minIndex" : 0x0001, "maxIndex" : 0x0FFF, "name" : "Data Type Definitions"}, |
|
86 |
{"minIndex" : 0x1000, "maxIndex" : 0x1029, "name" : "Communication Parameters"}, |
|
87 |
{"minIndex" : 0x1200, "maxIndex" : 0x12FF, "name" : "SDO Parameters"}, |
|
88 |
{"minIndex" : 0x1400, "maxIndex" : 0x15FF, "name" : "Receive PDO Parameters"}, |
|
89 |
{"minIndex" : 0x1600, "maxIndex" : 0x17FF, "name" : "Receive PDO Mapping"}, |
|
90 |
{"minIndex" : 0x1800, "maxIndex" : 0x19FF, "name" : "Transmit PDO Parameters"}, |
|
91 |
{"minIndex" : 0x1A00, "maxIndex" : 0x1BFF, "name" : "Transmit PDO Mapping"}, |
|
92 |
{"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"}, |
|
93 |
{"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"}, |
|
94 |
{"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"}, |
|
95 |
{"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}] |
|
96 |
||
747
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
97 |
IECTypeConversion = { |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
98 |
"BOOLEAN": "BOOL", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
99 |
"INTEGER8": "SINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
100 |
"INTEGER16": "INT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
101 |
"INTEGER32": "DINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
102 |
"UNSIGNED8": "USINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
103 |
"UNSIGNED16": "UINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
104 |
"UNSIGNED32": "UDINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
105 |
"REAL32": "REAL", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
106 |
"VISIBLE_STRING": "STRING", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
107 |
"OCTET_STRING": "STRING", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
108 |
"UNICODE_STRING": "WSTRING", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
109 |
"DOMAIN": "STRING", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
110 |
"INTEGER24": "DINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
111 |
"REAL64": "LREAL", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
112 |
"INTEGER40": "LINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
113 |
"INTEGER48": "LINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
114 |
"INTEGER56": "LINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
115 |
"INTEGER64": "LINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
116 |
"UNSIGNED24": "UDINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
117 |
"UNSIGNED40": "ULINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
118 |
"UNSIGNED48": "ULINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
119 |
"UNSIGNED56": "ULINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
120 |
"UNSIGNED64": "ULINT", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
121 |
} |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
237
diff
changeset
|
122 |
SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"} |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
237
diff
changeset
|
123 |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
124 |
class SubindexTable(wx.grid.PyGridTableBase): |
205 | 125 |
|
126 |
""" |
|
127 |
A custom wxGrid Table using user supplied data |
|
128 |
""" |
|
129 |
def __init__(self, parent, data, editors, colnames): |
|
130 |
# The base class must be initialized *first* |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
131 |
wx.grid.PyGridTableBase.__init__(self) |
205 | 132 |
self.data = data |
133 |
self.editors = editors |
|
134 |
self.CurrentIndex = 0 |
|
135 |
self.colnames = colnames |
|
136 |
self.Parent = parent |
|
137 |
self.Editable = True |
|
138 |
# XXX |
|
139 |
# we need to store the row length and collength to |
|
140 |
# see if the table has changed size |
|
141 |
self._rows = self.GetNumberRows() |
|
142 |
self._cols = self.GetNumberCols() |
|
143 |
||
144 |
def Disable(self): |
|
145 |
self.Editable = False |
|
146 |
||
147 |
def Enable(self): |
|
148 |
self.Editable = True |
|
149 |
||
150 |
def GetNumberCols(self): |
|
151 |
return len(self.colnames) |
|
152 |
||
153 |
def GetNumberRows(self): |
|
154 |
return len(self.data) |
|
155 |
||
580 | 156 |
def GetColLabelValue(self, col, translate=True): |
205 | 157 |
if col < len(self.colnames): |
580 | 158 |
if translate: |
159 |
return _(self.colnames[col]) |
|
205 | 160 |
return self.colnames[col] |
161 |
||
580 | 162 |
def GetRowLabelValues(self, row, translate=True): |
205 | 163 |
return row |
164 |
||
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
165 |
def GetValue(self, row, col, translate=True): |
205 | 166 |
if row < self.GetNumberRows(): |
580 | 167 |
colname = self.GetColLabelValue(col, False) |
168 |
value = unicode(self.data[row].get(colname, "")) |
|
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
169 |
if translate and (colname == "access" or |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
170 |
self.editors[row][colname] in ["bool", "option"] or |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
171 |
self.editors[row][colname] == "map" and value == "None"): |
580 | 172 |
value = _(value) |
173 |
return value |
|
266 | 174 |
|
205 | 175 |
def GetEditor(self, row, col): |
176 |
if row < self.GetNumberRows(): |
|
580 | 177 |
return self.editors[row].get(self.GetColLabelValue(col, False), "") |
205 | 178 |
|
179 |
def GetValueByName(self, row, colname): |
|
180 |
return self.data[row].get(colname) |
|
181 |
||
182 |
def SetValue(self, row, col, value): |
|
183 |
if col < len(self.colnames): |
|
580 | 184 |
colname = self.GetColLabelValue(col, False) |
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
185 |
if colname == "access": |
580 | 186 |
value = ACCESS_LIST_DICT[value] |
187 |
elif self.editors[row][colname] == "bool": |
|
188 |
value = BOOL_LIST_DICT[value] |
|
189 |
elif self.editors[row][colname] == "option": |
|
190 |
value = OPTION_LIST_DICT[value] |
|
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
191 |
elif self.editors[row][colname] == "map" and value == _("None"): |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
192 |
value = "None" |
580 | 193 |
self.data[row][colname] = value |
205 | 194 |
|
195 |
def ResetView(self, grid): |
|
196 |
""" |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
197 |
(wx.grid.Grid) -> Reset the grid view. Call this to |
205 | 198 |
update the grid if rows and columns have been added or deleted |
199 |
""" |
|
200 |
grid.BeginBatch() |
|
201 |
for current, new, delmsg, addmsg in [ |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
202 |
(self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
203 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
205 | 204 |
]: |
205 |
if new < current: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
206 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
205 | 207 |
grid.ProcessTableMessage(msg) |
208 |
elif new > current: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
209 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
205 | 210 |
grid.ProcessTableMessage(msg) |
211 |
self.UpdateValues(grid) |
|
212 |
grid.EndBatch() |
|
213 |
||
214 |
self._rows = self.GetNumberRows() |
|
215 |
self._cols = self.GetNumberCols() |
|
216 |
# update the column rendering scheme |
|
217 |
self._updateColAttrs(grid) |
|
218 |
||
219 |
# update the scrollbars and the displayed part of the grid |
|
220 |
grid.AdjustScrollbars() |
|
221 |
grid.ForceRefresh() |
|
222 |
||
223 |
||
224 |
def UpdateValues(self, grid): |
|
225 |
"""Update all displayed values""" |
|
226 |
# This sends an event to the grid table to update all of the values |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
227 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
205 | 228 |
grid.ProcessTableMessage(msg) |
229 |
||
230 |
def _updateColAttrs(self, grid): |
|
231 |
""" |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
232 |
wx.grid.Grid -> update the column attributes to add the |
205 | 233 |
appropriate renderer given the column name. |
234 |
||
235 |
Otherwise default to the default renderer. |
|
236 |
""" |
|
237 |
||
238 |
for col in range(self.GetNumberCols()): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
239 |
attr = wx.grid.GridCellAttr() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
240 |
attr.SetAlignment(ColAlignements[col], wx.ALIGN_CENTRE) |
205 | 241 |
grid.SetColAttr(col, attr) |
580 | 242 |
grid.SetColMinimalWidth(col, ColSizes[col]) |
243 |
grid.AutoSizeColumn(col, False) |
|
205 | 244 |
|
245 |
typelist = None |
|
246 |
maplist = None |
|
247 |
for row in range(self.GetNumberRows()): |
|
248 |
editors = self.editors[row] |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
249 |
if wx.Platform == '__WXMSW__': |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
250 |
grid.SetRowMinimalHeight(row, 20) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
251 |
else: |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
252 |
grid.SetRowMinimalHeight(row, 28) |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
584
diff
changeset
|
253 |
grid.AutoSizeRow(row, False) |
205 | 254 |
for col in range(self.GetNumberCols()): |
255 |
editor = None |
|
256 |
renderer = None |
|
257 |
||
580 | 258 |
colname = self.GetColLabelValue(col, False) |
205 | 259 |
editortype = editors[colname] |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
260 |
if editortype == "dcf": |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
261 |
editor = wx.grid.GridCellTextEditor() |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
262 |
renderer = wx.grid.GridCellStringRenderer() |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
263 |
elif editortype and self.Editable: |
205 | 264 |
grid.SetReadOnly(row, col, False) |
265 |
if editortype == "string": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
266 |
editor = wx.grid.GridCellTextEditor() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
267 |
renderer = wx.grid.GridCellStringRenderer() |
205 | 268 |
if colname == "value" and "length" in editors: |
269 |
editor.SetParameters(editors["length"]) |
|
270 |
elif editortype == "number": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
271 |
editor = wx.grid.GridCellNumberEditor() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
272 |
renderer = wx.grid.GridCellNumberRenderer() |
205 | 273 |
if colname == "value" and "min" in editors and "max" in editors: |
274 |
editor.SetParameters("%s,%s"%(editors["min"],editors["max"])) |
|
453 | 275 |
elif editortype == "float": |
276 |
editor = wx.grid.GridCellTextEditor() |
|
277 |
renderer = wx.grid.GridCellStringRenderer() |
|
205 | 278 |
elif editortype == "bool": |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
279 |
editor = wx.grid.GridCellChoiceEditor() |
205 | 280 |
editor.SetParameters(BoolList) |
281 |
elif editortype == "access": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
282 |
editor = wx.grid.GridCellChoiceEditor() |
205 | 283 |
editor.SetParameters(AccessList) |
284 |
elif editortype == "raccess": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
285 |
editor = wx.grid.GridCellChoiceEditor() |
205 | 286 |
editor.SetParameters(RAccessList) |
287 |
elif editortype == "option": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
288 |
editor = wx.grid.GridCellChoiceEditor() |
205 | 289 |
editor.SetParameters(OptionList) |
290 |
elif editortype == "type": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
291 |
editor = wx.grid.GridCellChoiceEditor() |
205 | 292 |
if typelist == None: |
293 |
typelist = self.Parent.Manager.GetCurrentTypeList() |
|
294 |
editor.SetParameters(typelist) |
|
295 |
elif editortype == "map": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
296 |
editor = wx.grid.GridCellChoiceEditor() |
205 | 297 |
if maplist == None: |
298 |
maplist = self.Parent.Manager.GetCurrentMapList() |
|
299 |
editor.SetParameters(maplist) |
|
300 |
elif editortype == "time": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
301 |
editor = wx.grid.GridCellTextEditor() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
302 |
renderer = wx.grid.GridCellStringRenderer() |
205 | 303 |
elif editortype == "domain": |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
304 |
editor = wx.grid.GridCellTextEditor() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
305 |
renderer = wx.grid.GridCellStringRenderer() |
205 | 306 |
else: |
307 |
grid.SetReadOnly(row, col, True) |
|
308 |
||
309 |
grid.SetCellEditor(row, col, editor) |
|
310 |
grid.SetCellRenderer(row, col, renderer) |
|
311 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
312 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
205 | 313 |
|
314 |
def SetData(self, data): |
|
315 |
self.data = data |
|
316 |
||
317 |
def SetEditors(self, editors): |
|
318 |
self.editors = editors |
|
319 |
||
320 |
def GetCurrentIndex(self): |
|
321 |
return self.CurrentIndex |
|
322 |
||
323 |
def SetCurrentIndex(self, index): |
|
324 |
self.CurrentIndex = index |
|
325 |
||
326 |
def AppendRow(self, row_content): |
|
327 |
self.data.append(row_content) |
|
328 |
||
329 |
def Empty(self): |
|
330 |
self.data = [] |
|
331 |
self.editors = [] |
|
332 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
333 |
[ID_EDITINGPANEL, ID_EDITINGPANELADDBUTTON, ID_EDITINGPANELINDEXCHOICE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
334 |
ID_EDITINGPANELINDEXLIST, ID_EDITINGPANELINDEXLISTPANEL, ID_EDITINGPANELPARTLIST, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
335 |
ID_EDITINGPANELSECONDSPLITTER, ID_EDITINGPANELSUBINDEXGRID, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
336 |
ID_EDITINGPANELSUBINDEXGRIDPANEL, ID_EDITINGPANELCALLBACKCHECK, |
205 | 337 |
] = [wx.NewId() for _init_ctrls in range(10)] |
338 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
339 |
[ID_EDITINGPANELINDEXLISTMENUITEMS0, ID_EDITINGPANELINDEXLISTMENUITEMS1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
340 |
ID_EDITINGPANELINDEXLISTMENUITEMS2, |
205 | 341 |
] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)] |
342 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
343 |
[ID_EDITINGPANELMENU1ITEMS0, ID_EDITINGPANELMENU1ITEMS1, |
327 | 344 |
ID_EDITINGPANELMENU1ITEMS3, ID_EDITINGPANELMENU1ITEMS4, |
345 |
] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(4)] |
|
205 | 346 |
|
347 |
class EditingPanel(wx.SplitterWindow): |
|
348 |
def _init_coll_AddToListSizer_Items(self, parent): |
|
349 |
parent.AddWindow(self.AddButton, 0, border=0, flag=0) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
350 |
parent.AddWindow(self.IndexChoice, 0, border=0, flag=wx.GROW) |
205 | 351 |
|
352 |
def _init_coll_SubindexGridSizer_Items(self, parent): |
|
353 |
parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
354 |
parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wx.GROW) |
205 | 355 |
|
356 |
def _init_coll_IndexListSizer_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
357 |
parent.AddWindow(self.IndexList, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
358 |
parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wx.GROW) |
205 | 359 |
|
360 |
def _init_coll_AddToListSizer_Growables(self, parent): |
|
361 |
parent.AddGrowableCol(1) |
|
362 |
||
363 |
def _init_coll_SubindexGridSizer_Growables(self, parent): |
|
364 |
parent.AddGrowableCol(0) |
|
365 |
parent.AddGrowableRow(1) |
|
366 |
||
367 |
def _init_coll_IndexListSizer_Growables(self, parent): |
|
368 |
parent.AddGrowableCol(0) |
|
369 |
parent.AddGrowableRow(0) |
|
370 |
||
371 |
def _init_coll_SubindexGridMenu_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
372 |
parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS0, |
580 | 373 |
kind=wx.ITEM_NORMAL, text=_('Add subindexes')) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
374 |
parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS1, |
580 | 375 |
kind=wx.ITEM_NORMAL, text=_('Delete subindexes')) |
299 | 376 |
parent.AppendSeparator() |
377 |
parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS3, |
|
580 | 378 |
kind=wx.ITEM_NORMAL, text=_('Default value')) |
327 | 379 |
if not self.Editable: |
380 |
parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS4, |
|
580 | 381 |
kind=wx.ITEM_NORMAL, text=_('Add to DCF')) |
205 | 382 |
self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
383 |
id=ID_EDITINGPANELMENU1ITEMS0) |
205 | 384 |
self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
385 |
id=ID_EDITINGPANELMENU1ITEMS1) |
299 | 386 |
self.Bind(wx.EVT_MENU, self.OnDefaultValueSubindexMenu, |
387 |
id=ID_EDITINGPANELMENU1ITEMS3) |
|
327 | 388 |
if not self.Editable: |
389 |
self.Bind(wx.EVT_MENU, self.OnAddToDCFSubindexMenu, |
|
390 |
id=ID_EDITINGPANELMENU1ITEMS4) |
|
205 | 391 |
|
392 |
def _init_coll_IndexListMenu_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
393 |
parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS0, |
580 | 394 |
kind=wx.ITEM_NORMAL, text=_('Rename')) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
395 |
parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS2, |
580 | 396 |
kind=wx.ITEM_NORMAL, text=_('Modify')) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
397 |
parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS1, |
580 | 398 |
kind=wx.ITEM_NORMAL, text=_('Delete')) |
205 | 399 |
self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
400 |
id=ID_EDITINGPANELINDEXLISTMENUITEMS0) |
205 | 401 |
self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
402 |
id=ID_EDITINGPANELINDEXLISTMENUITEMS1) |
205 | 403 |
self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
404 |
id=ID_EDITINGPANELINDEXLISTMENUITEMS2) |
205 | 405 |
|
406 |
def _init_utils(self): |
|
407 |
self.IndexListMenu = wx.Menu(title='') |
|
408 |
self.SubindexGridMenu = wx.Menu(title='') |
|
409 |
||
410 |
self._init_coll_IndexListMenu_Items(self.IndexListMenu) |
|
411 |
self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu) |
|
412 |
||
413 |
def _init_sizers(self): |
|
414 |
self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
415 |
self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
416 |
self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) |
|
417 |
||
418 |
self._init_coll_IndexListSizer_Growables(self.IndexListSizer) |
|
419 |
self._init_coll_IndexListSizer_Items(self.IndexListSizer) |
|
420 |
self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer) |
|
421 |
self._init_coll_SubindexGridSizer_Items(self.SubindexGridSizer) |
|
422 |
self._init_coll_AddToListSizer_Growables(self.AddToListSizer) |
|
423 |
self._init_coll_AddToListSizer_Items(self.AddToListSizer) |
|
424 |
||
425 |
self.SubindexGridPanel.SetSizer(self.SubindexGridSizer) |
|
426 |
self.IndexListPanel.SetSizer(self.IndexListSizer) |
|
427 |
||
428 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
429 |
wx.SplitterWindow.__init__(self, id=ID_EDITINGPANEL, |
205 | 430 |
name='MainSplitter', parent=prnt, point=wx.Point(0, 0), |
431 |
size=wx.Size(-1, -1), style=wx.SP_3D) |
|
432 |
self._init_utils() |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
433 |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
434 |
self.PartList = wx.ListBox(choices=[], id=ID_EDITINGPANELPARTLIST, |
205 | 435 |
name='PartList', parent=self, pos=wx.Point(0, 0), |
436 |
size=wx.Size(-1, -1), style=0) |
|
437 |
self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
438 |
id=ID_EDITINGPANELPARTLIST) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
439 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
440 |
self.SecondSplitter = wx.SplitterWindow(id=ID_EDITINGPANELSECONDSPLITTER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
441 |
name='SecondSplitter', parent=self, point=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
442 |
size=wx.Size(-1, -1), style=wx.SP_3D) |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
443 |
self.SplitHorizontally(self.PartList, self.SecondSplitter, 110) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
444 |
self.SetMinimumPaneSize(1) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
445 |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
446 |
self.SubindexGridPanel = wx.Panel(id=ID_EDITINGPANELSUBINDEXGRIDPANEL, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
447 |
name='SubindexGridPanel', parent=self.SecondSplitter, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
448 |
pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
449 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
450 |
self.IndexListPanel = wx.Panel(id=ID_EDITINGPANELINDEXLISTPANEL, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
451 |
name='IndexListPanel', parent=self.SecondSplitter, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
452 |
pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL) |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
453 |
self.SecondSplitter.SplitVertically(self.IndexListPanel, self.SubindexGridPanel, 280) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
454 |
self.SecondSplitter.SetMinimumPaneSize(1) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
455 |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
456 |
self.SubindexGrid = wx.grid.Grid(id=ID_EDITINGPANELSUBINDEXGRID, |
205 | 457 |
name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0, |
458 |
0), size=wx.Size(-1, -1), style=0) |
|
789 | 459 |
self.SubindexGrid.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, |
205 | 460 |
'Sans')) |
789 | 461 |
self.SubindexGrid.SetLabelFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL, |
205 | 462 |
False, 'Sans')) |
463 |
self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, |
|
464 |
self.OnSubindexGridCellChange) |
|
465 |
self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
|
466 |
self.OnSubindexGridRightClick) |
|
467 |
self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, |
|
468 |
self.OnSubindexGridSelectCell) |
|
324 | 469 |
self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, |
470 |
self.OnSubindexGridCellLeftClick) |
|
327 | 471 |
self.SubindexGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, |
472 |
self.OnSubindexGridEditorShown) |
|
205 | 473 |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
474 |
self.CallbackCheck = wx.CheckBox(id=ID_EDITINGPANELCALLBACKCHECK, |
580 | 475 |
label=_('Have Callbacks'), name='CallbackCheck', |
205 | 476 |
parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
477 |
24), style=0) |
|
478 |
self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
479 |
id=ID_EDITINGPANELCALLBACKCHECK) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
480 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
481 |
self.IndexList = wx.ListBox(choices=[], id=ID_EDITINGPANELINDEXLIST, |
205 | 482 |
name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
483 |
size=wx.Size(-1, -1), style=0) |
|
484 |
self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
485 |
id=ID_EDITINGPANELINDEXLIST) |
205 | 486 |
self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp) |
487 |
||
580 | 488 |
self.AddButton = wx.Button(id=ID_EDITINGPANELADDBUTTON, label=_('Add'), |
205 | 489 |
name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
580 | 490 |
size=wx.DefaultSize, style=0) |
205 | 491 |
self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
492 |
id=ID_EDITINGPANELADDBUTTON) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
493 |
|
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
584
diff
changeset
|
494 |
self.IndexChoice = wx.ComboBox(choices=[], id=ID_EDITINGPANELINDEXCHOICE, |
205 | 495 |
name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50, |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
584
diff
changeset
|
496 |
0), size=wx.Size(-1, 30), style=wx.CB_READONLY) |
205 | 497 |
|
498 |
self._init_sizers() |
|
499 |
||
299 | 500 |
def __init__(self, parent, window, manager, editable = True): |
327 | 501 |
self.Editable = editable |
299 | 502 |
self._init_ctrls(parent) |
503 |
self.ParentWindow = window |
|
205 | 504 |
self.Manager = manager |
505 |
self.ListIndex = [] |
|
506 |
self.ChoiceIndex = [] |
|
507 |
self.FirstCall = False |
|
508 |
self.Index = None |
|
509 |
||
510 |
for values in DictionaryOrganisation: |
|
299 | 511 |
text = " 0x%04X-0x%04X %s"%(values["minIndex"], values["maxIndex"], values["name"]) |
205 | 512 |
self.PartList.Append(text) |
580 | 513 |
self.Table = SubindexTable(self, [], [], GetSubindexTableColnames()) |
205 | 514 |
self.SubindexGrid.SetTable(self.Table) |
515 |
self.SubindexGrid.SetRowLabelSize(0) |
|
516 |
self.CallbackCheck.Disable() |
|
517 |
self.Table.ResetView(self.SubindexGrid) |
|
518 |
||
519 |
if not self.Editable: |
|
520 |
self.AddButton.Disable() |
|
521 |
self.IndexChoice.Disable() |
|
522 |
self.CallbackCheck.Disable() |
|
523 |
self.Table.Disable() |
|
785
b72a88dbc7c3
Fixed SplitterWindows sash position at creation when subindextable is used in notebook tab
Laurent Bessard
parents:
782
diff
changeset
|
524 |
|
b72a88dbc7c3
Fixed SplitterWindows sash position at creation when subindextable is used in notebook tab
Laurent Bessard
parents:
782
diff
changeset
|
525 |
wx.CallAfter(self.SetSashPosition, 110) |
b72a88dbc7c3
Fixed SplitterWindows sash position at creation when subindextable is used in notebook tab
Laurent Bessard
parents:
782
diff
changeset
|
526 |
wx.CallAfter(self.SecondSplitter.SetSashPosition, 280) |
205 | 527 |
|
528 |
def GetIndex(self): |
|
529 |
return self.Index |
|
530 |
||
531 |
def SetIndex(self, index): |
|
532 |
self.Index = index |
|
533 |
||
534 |
def GetSelection(self): |
|
535 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
536 |
if selected != wx.NOT_FOUND: |
205 | 537 |
index = self.ListIndex[selected] |
538 |
subIndex = self.SubindexGrid.GetGridCursorRow() |
|
539 |
return index, subIndex |
|
540 |
return None |
|
541 |
||
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
237
diff
changeset
|
542 |
def OnSubindexGridCellLeftClick(self, event): |
324 | 543 |
if not self.ParentWindow.ModeSolo: |
544 |
col = event.GetCol() |
|
485
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
545 |
if self.Editable and col == 0: |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
546 |
selected = self.IndexList.GetSelection() |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
547 |
if selected != wx.NOT_FOUND: |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
548 |
index = self.ListIndex[selected] |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
549 |
subindex = event.GetRow() |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
550 |
entry_infos = self.Manager.GetEntryInfos(index) |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
551 |
if not entry_infos["struct"] & OD_MultipleSubindexes or subindex != 0: |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
552 |
subentry_infos = self.Manager.GetSubentryInfos(index, subindex) |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
553 |
typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"]) |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
554 |
if typeinfos: |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
555 |
bus_id = '.'.join(map(str, self.ParentWindow.GetBusId())) |
748
18ed0f3b030a
Fixing networkedit to deal with non-null master nodeid
Laurent Bessard
parents:
747
diff
changeset
|
556 |
var_name = "%s_%04x_%02x" % (self.Manager.GetCurrentNodeName(), index, subindex) |
485
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
557 |
size = typeinfos["size"] |
747
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
558 |
data = wx.TextDataObject(str( |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
559 |
("%s%s.%d.%d"%(SizeConversion[size], bus_id, index, subindex), |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
560 |
"location", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
561 |
IECTypeConversion.get(typeinfos["name"]), |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
562 |
var_name, ""))) |
485
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
563 |
dragSource = wx.DropSource(self.SubindexGrid) |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
564 |
dragSource.SetData(data) |
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
565 |
dragSource.DoDragDrop() |
761
efff55931763
Fix bug when Drag'n Dropping located variables on Windows
Laurent Bessard
parents:
757
diff
changeset
|
566 |
return |
485
24b506ea314b
Added embedded mode in objdictedit, for integration in Beremiz.
etisserant
parents:
453
diff
changeset
|
567 |
elif col == 0: |
324 | 568 |
selected = self.IndexList.GetSelection() |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
569 |
node_id = self.ParentWindow.GetCurrentNodeId() |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
570 |
if selected != wx.NOT_FOUND and node_id is not None: |
324 | 571 |
index = self.ListIndex[selected] |
572 |
subindex = event.GetRow() |
|
573 |
entry_infos = self.Manager.GetEntryInfos(index) |
|
574 |
if not entry_infos["struct"] & OD_MultipleSubindexes or subindex != 0: |
|
575 |
subentry_infos = self.Manager.GetSubentryInfos(index, subindex) |
|
576 |
typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"]) |
|
577 |
if subentry_infos["pdo"] and typeinfos: |
|
578 |
bus_id = '.'.join(map(str, self.ParentWindow.GetBusId())) |
|
741
b1a73ddc514b
Adding informations in data send when drag'n dropping locations
Laurent Bessard
parents:
622
diff
changeset
|
579 |
var_name = "%s_%04x_%02x" % (self.Manager.GetSlaveName(node_id), index, subindex) |
324 | 580 |
size = typeinfos["size"] |
747
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
581 |
data = wx.TextDataObject(str( |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
582 |
("%s%s.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
583 |
"location", |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
584 |
IECTypeConversion.get(typeinfos["name"]), |
4725d8f909ff
Adding support for translating CANOpen type to corresponding IEC type for location drag'n drop
Laurent Bessard
parents:
741
diff
changeset
|
585 |
var_name, ""))) |
324 | 586 |
dragSource = wx.DropSource(self.SubindexGrid) |
587 |
dragSource.SetData(data) |
|
588 |
dragSource.DoDragDrop() |
|
761
efff55931763
Fix bug when Drag'n Dropping located variables on Windows
Laurent Bessard
parents:
757
diff
changeset
|
589 |
return |
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
237
diff
changeset
|
590 |
event.Skip() |
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
237
diff
changeset
|
591 |
|
205 | 592 |
def OnAddButtonClick(self, event): |
593 |
if self.Editable: |
|
594 |
self.SubindexGrid.SetGridCursor(0, 0) |
|
595 |
selected = self.IndexChoice.GetStringSelection() |
|
596 |
if selected != "": |
|
580 | 597 |
choice = INDEXCHOICE_OPTIONS_DICT.get(selected, None) |
598 |
if choice is not None: |
|
599 |
if INDEXCHOICE_OPTIONS[choice][1] == 0: |
|
600 |
getattr(self.ParentWindow, INDEXCHOICE_OPTIONS[choice][2])() |
|
601 |
elif INDEXCHOICE_OPTIONS[choice][1] == 1: |
|
602 |
getattr(self.Manager, INDEXCHOICE_OPTIONS[choice][2])() |
|
205 | 603 |
elif selected in [menu for menu, indexes in self.Manager.GetCurrentSpecificMenu()]: |
604 |
self.Manager.AddSpecificEntryToCurrent(selected) |
|
605 |
else: |
|
606 |
index = self.ChoiceIndex[self.IndexChoice.GetSelection()] |
|
607 |
self.Manager.ManageEntriesOfCurrent([index], []) |
|
271 | 608 |
self.ParentWindow.RefreshBufferState() |
205 | 609 |
self.RefreshIndexList() |
610 |
event.Skip() |
|
611 |
||
612 |
def OnPartListBoxClick(self, event): |
|
491 | 613 |
if not self.ParentWindow.IsClosing(): |
614 |
self.SubindexGrid.SetGridCursor(0, 0) |
|
615 |
self.RefreshIndexList() |
|
205 | 616 |
event.Skip() |
617 |
||
618 |
def OnIndexListClick(self, event): |
|
491 | 619 |
if not self.ParentWindow.IsClosing(): |
620 |
self.SubindexGrid.SetGridCursor(0, 0) |
|
621 |
self.RefreshTable() |
|
205 | 622 |
event.Skip() |
623 |
||
624 |
def OnSubindexGridSelectCell(self, event): |
|
491 | 625 |
if not self.ParentWindow.IsClosing(): |
626 |
wx.CallAfter(self.ParentWindow.RefreshStatusBar) |
|
205 | 627 |
event.Skip() |
628 |
||
629 |
#------------------------------------------------------------------------------- |
|
630 |
# Refresh Functions |
|
631 |
#------------------------------------------------------------------------------- |
|
632 |
||
633 |
def RefreshIndexList(self): |
|
634 |
selected = self.IndexList.GetSelection() |
|
635 |
choice = self.IndexChoice.GetStringSelection() |
|
636 |
choiceindex = self.IndexChoice.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
637 |
if selected != wx.NOT_FOUND: |
205 | 638 |
selectedindex = self.ListIndex[selected] |
639 |
self.IndexList.Clear() |
|
640 |
self.IndexChoice.Clear() |
|
641 |
i = self.PartList.GetSelection() |
|
642 |
if i < len(DictionaryOrganisation): |
|
643 |
values = DictionaryOrganisation[i] |
|
644 |
self.ListIndex = [] |
|
645 |
for name, index in self.Manager.GetCurrentValidIndexes(values["minIndex"], values["maxIndex"]): |
|
646 |
self.IndexList.Append("0x%04X %s"%(index, name)) |
|
647 |
self.ListIndex.append(index) |
|
648 |
if self.Editable: |
|
649 |
self.ChoiceIndex = [] |
|
580 | 650 |
choices = INDEXCHOICE_SECTIONS.get(i, None) |
651 |
if choices is not None: |
|
652 |
for c in choices: |
|
653 |
self.IndexChoice.Append(INDEXCHOICE_OPTIONS[c][0]) |
|
654 |
if len(choices) > 1: |
|
655 |
if choiceindex != wx.NOT_FOUND and choice == self.IndexChoice.GetString(choiceindex): |
|
656 |
self.IndexChoice.SetStringSelection(choice) |
|
657 |
else: |
|
658 |
self.IndexChoice.SetSelection(0) |
|
205 | 659 |
else: |
660 |
for name, index in self.Manager.GetCurrentValidChoices(values["minIndex"], values["maxIndex"]): |
|
661 |
if index: |
|
662 |
self.IndexChoice.Append("0x%04X %s"%(index, name)) |
|
663 |
else: |
|
664 |
self.IndexChoice.Append(name) |
|
665 |
self.ChoiceIndex.append(index) |
|
312 | 666 |
if choiceindex != wx.NOT_FOUND and choiceindex < self.IndexChoice.GetCount() and choice == self.IndexChoice.GetString(choiceindex): |
205 | 667 |
self.IndexChoice.SetStringSelection(choice) |
668 |
if self.Editable: |
|
669 |
self.IndexChoice.Enable(self.IndexChoice.GetCount() != 0) |
|
670 |
self.AddButton.Enable(self.IndexChoice.GetCount() != 0) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
671 |
if selected == wx.NOT_FOUND or selected >= len(self.ListIndex) or selectedindex != self.ListIndex[selected]: |
205 | 672 |
self.Table.Empty() |
673 |
self.CallbackCheck.SetValue(False) |
|
674 |
self.CallbackCheck.Disable() |
|
675 |
self.Table.ResetView(self.SubindexGrid) |
|
271 | 676 |
self.ParentWindow.RefreshStatusBar() |
205 | 677 |
else: |
678 |
self.IndexList.SetSelection(selected) |
|
679 |
self.RefreshTable() |
|
680 |
||
681 |
def RefreshTable(self): |
|
682 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
683 |
if selected != wx.NOT_FOUND: |
205 | 684 |
index = self.ListIndex[selected] |
685 |
if index > 0x260 and self.Editable: |
|
686 |
self.CallbackCheck.Enable() |
|
687 |
self.CallbackCheck.SetValue(self.Manager.HasCurrentEntryCallbacks(index)) |
|
688 |
result = self.Manager.GetCurrentEntryValues(index) |
|
689 |
if result != None: |
|
690 |
self.Table.SetCurrentIndex(index) |
|
691 |
data, editors = result |
|
692 |
self.Table.SetData(data) |
|
693 |
self.Table.SetEditors(editors) |
|
694 |
self.Table.ResetView(self.SubindexGrid) |
|
271 | 695 |
self.ParentWindow.RefreshStatusBar() |
205 | 696 |
|
697 |
#------------------------------------------------------------------------------- |
|
698 |
# Editing Table value function |
|
699 |
#------------------------------------------------------------------------------- |
|
700 |
||
327 | 701 |
def OnSubindexGridEditorShown(self, event): |
702 |
row, col = event.GetRow(), event.GetCol() |
|
703 |
if self.Table.GetEditor(row, col) == "dcf": |
|
704 |
wx.CallAfter(self.ShowDCFEntryDialog, row, col) |
|
705 |
event.Veto() |
|
706 |
else: |
|
707 |
event.Skip() |
|
708 |
||
709 |
def ShowDCFEntryDialog(self, row, col): |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
710 |
if self.Editable or self.ParentWindow.GetCurrentNodeId() is None: |
327 | 711 |
selected = self.IndexList.GetSelection() |
712 |
if selected != wx.NOT_FOUND: |
|
713 |
index = self.ListIndex[selected] |
|
714 |
if self.Manager.IsCurrentEntry(index): |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
715 |
dialog = DCFEntryValuesDialog(self, self.Editable) |
327 | 716 |
dialog.SetValues(self.Table.GetValue(row, col).decode("hex_codec")) |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
717 |
if dialog.ShowModal() == wx.ID_OK and self.Editable: |
327 | 718 |
value = dialog.GetValues() |
719 |
self.Manager.SetCurrentEntry(index, row, value, "value", "dcf") |
|
720 |
self.ParentWindow.RefreshBufferState() |
|
721 |
wx.CallAfter(self.RefreshTable) |
|
722 |
||
205 | 723 |
def OnSubindexGridCellChange(self, event): |
724 |
if self.Editable: |
|
725 |
index = self.Table.GetCurrentIndex() |
|
726 |
subIndex = event.GetRow() |
|
727 |
col = event.GetCol() |
|
584
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
728 |
name = self.Table.GetColLabelValue(col, False) |
e23359f62023
Bug with in access value translation and modification on subindex 0 of PDOmapping entries fixed
laurent
parents:
580
diff
changeset
|
729 |
value = self.Table.GetValue(subIndex, col, False) |
205 | 730 |
editor = self.Table.GetEditor(subIndex, col) |
731 |
self.Manager.SetCurrentEntry(index, subIndex, value, name, editor) |
|
271 | 732 |
self.ParentWindow.RefreshBufferState() |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
733 |
wx.CallAfter(self.RefreshTable) |
205 | 734 |
event.Skip() |
735 |
||
736 |
def OnCallbackCheck(self, event): |
|
737 |
if self.Editable: |
|
738 |
index = self.Table.GetCurrentIndex() |
|
739 |
self.Manager.SetCurrentEntryCallbacks(index, self.CallbackCheck.GetValue()) |
|
271 | 740 |
self.ParentWindow.RefreshBufferState() |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
741 |
wx.CallAfter(self.RefreshTable) |
205 | 742 |
event.Skip() |
743 |
||
744 |
#------------------------------------------------------------------------------- |
|
745 |
# Contextual Menu functions |
|
746 |
#------------------------------------------------------------------------------- |
|
747 |
||
748 |
def OnIndexListRightUp(self, event): |
|
749 |
if self.Editable: |
|
750 |
if not self.FirstCall: |
|
751 |
self.FirstCall = True |
|
752 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
753 |
if selected != wx.NOT_FOUND: |
205 | 754 |
index = self.ListIndex[selected] |
755 |
if index < 0x260: |
|
756 |
self.IndexListMenu.FindItemByPosition(0).Enable(False) |
|
757 |
self.IndexListMenu.FindItemByPosition(1).Enable(True) |
|
758 |
self.PopupMenu(self.IndexListMenu) |
|
273 | 759 |
elif 0x1000 <= index <= 0x1FFF: |
205 | 760 |
self.IndexListMenu.FindItemByPosition(0).Enable(False) |
761 |
self.IndexListMenu.FindItemByPosition(1).Enable(False) |
|
762 |
self.PopupMenu(self.IndexListMenu) |
|
763 |
elif 0x2000 <= index <= 0x5FFF: |
|
764 |
self.IndexListMenu.FindItemByPosition(0).Enable(True) |
|
765 |
self.IndexListMenu.FindItemByPosition(1).Enable(False) |
|
766 |
self.PopupMenu(self.IndexListMenu) |
|
767 |
elif index >= 0x6000: |
|
768 |
self.IndexListMenu.FindItemByPosition(0).Enable(False) |
|
769 |
self.IndexListMenu.FindItemByPosition(1).Enable(False) |
|
770 |
self.PopupMenu(self.IndexListMenu) |
|
771 |
else: |
|
772 |
self.FirstCall = False |
|
773 |
event.Skip() |
|
774 |
||
775 |
def OnSubindexGridRightClick(self, event): |
|
299 | 776 |
self.SubindexGrid.SetGridCursor(event.GetRow(), event.GetCol()) |
205 | 777 |
if self.Editable: |
778 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
779 |
if selected != wx.NOT_FOUND: |
205 | 780 |
index = self.ListIndex[selected] |
781 |
if self.Manager.IsCurrentEntry(index): |
|
299 | 782 |
showpopup = False |
205 | 783 |
infos = self.Manager.GetEntryInfos(index) |
310 | 784 |
if 0x2000 <= index <= 0x5FFF and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes: |
299 | 785 |
showpopup = True |
786 |
self.SubindexGridMenu.FindItemByPosition(0).Enable(True) |
|
787 |
self.SubindexGridMenu.FindItemByPosition(1).Enable(True) |
|
788 |
else: |
|
789 |
self.SubindexGridMenu.FindItemByPosition(0).Enable(False) |
|
790 |
self.SubindexGridMenu.FindItemByPosition(1).Enable(False) |
|
622 | 791 |
if self.Table.GetColLabelValue(event.GetCol(), False) == "value": |
299 | 792 |
showpopup = True |
793 |
self.SubindexGridMenu.FindItemByPosition(3).Enable(True) |
|
794 |
else: |
|
795 |
self.SubindexGridMenu.FindItemByPosition(3).Enable(False) |
|
796 |
if showpopup: |
|
242
4864f7f01e1d
Changes in networkedit for integration with beremiz
lbessard
parents:
237
diff
changeset
|
797 |
self.PopupMenu(self.SubindexGridMenu) |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
798 |
elif self.Table.GetColLabelValue(event.GetCol(), False) == "value" and self.ParentWindow.GetCurrentNodeId() is not None: |
327 | 799 |
selected = self.IndexList.GetSelection() |
800 |
if selected != wx.NOT_FOUND: |
|
801 |
index = self.ListIndex[selected] |
|
802 |
if self.Manager.IsCurrentEntry(index): |
|
803 |
infos = self.Manager.GetEntryInfos(index) |
|
804 |
if not infos["struct"] & OD_MultipleSubindexes or event.GetRow() > 0: |
|
805 |
self.SubindexGridMenu.FindItemByPosition(0).Enable(False) |
|
806 |
self.SubindexGridMenu.FindItemByPosition(1).Enable(False) |
|
807 |
self.SubindexGridMenu.FindItemByPosition(3).Enable(False) |
|
808 |
self.SubindexGridMenu.FindItemByPosition(4).Enable(True) |
|
809 |
self.PopupMenu(self.SubindexGridMenu) |
|
810 |
event.Skip() |
|
811 |
||
812 |
def OnAddToDCFSubindexMenu(self, event): |
|
813 |
if not self.Editable: |
|
814 |
selected = self.IndexList.GetSelection() |
|
815 |
if selected != wx.NOT_FOUND: |
|
816 |
index = self.ListIndex[selected] |
|
817 |
subindex = self.SubindexGrid.GetGridCursorRow() |
|
818 |
entry_infos = self.Manager.GetEntryInfos(index) |
|
819 |
if not entry_infos["struct"] & OD_MultipleSubindexes or subindex != 0: |
|
820 |
subentry_infos = self.Manager.GetSubentryInfos(index, subindex) |
|
821 |
typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"]) |
|
822 |
if typeinfos: |
|
823 |
node_id = self.ParentWindow.GetCurrentNodeId() |
|
336 | 824 |
value = self.Table.GetValueByName(subindex, "value") |
825 |
if value == "True": |
|
340 | 826 |
value = 1 |
827 |
elif value == "False": |
|
336 | 828 |
value = 0 |
829 |
elif value.isdigit(): |
|
830 |
value = int(value) |
|
831 |
elif value.startswith("0x"): |
|
832 |
value = int(value, 16) |
|
833 |
else: |
|
834 |
value = int(value.encode("hex_codec"), 16) |
|
835 |
self.Manager.AddToMasterDCF(node_id, index, subindex, max(1, typeinfos["size"] / 8), value) |
|
327 | 836 |
self.ParentWindow.OpenMasterDCFDialog(node_id) |
837 |
||
336 | 838 |
def OpenDCFDialog(self, node_id): |
327 | 839 |
self.PartList.SetSelection(7) |
840 |
self.RefreshIndexList() |
|
841 |
self.IndexList.SetSelection(self.ListIndex.index(0x1F22)) |
|
842 |
self.RefreshTable() |
|
843 |
self.SubindexGrid.SetGridCursor(node_id, 3) |
|
844 |
self.ShowDCFEntryDialog(node_id, 3) |
|
205 | 845 |
|
846 |
def OnRenameIndexMenu(self, event): |
|
847 |
if self.Editable: |
|
848 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
849 |
if selected != wx.NOT_FOUND: |
205 | 850 |
index = self.ListIndex[selected] |
851 |
if self.Manager.IsCurrentEntry(index): |
|
852 |
infos = self.Manager.GetEntryInfos(index) |
|
580 | 853 |
dialog = wx.TextEntryDialog(self, _("Give a new name for index 0x%04X")%index, |
854 |
_("Rename an index"), infos["name"], wx.OK|wx.CANCEL) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
855 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 856 |
self.Manager.SetCurrentEntryName(index, dialog.GetValue()) |
271 | 857 |
self.ParentWindow.RefreshBufferState() |
205 | 858 |
self.RefreshIndexList() |
859 |
dialog.Destroy() |
|
608 | 860 |
|
205 | 861 |
def OnModifyIndexMenu(self, event): |
862 |
if self.Editable: |
|
863 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
864 |
if selected != wx.NOT_FOUND: |
205 | 865 |
index = self.ListIndex[selected] |
866 |
if self.Manager.IsCurrentEntry(index) and index < 0x260: |
|
867 |
values, valuetype = self.Manager.GetCustomisedTypeValues(index) |
|
868 |
dialog = UserTypeDialog(self) |
|
869 |
dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1]) |
|
870 |
if valuetype == 0: |
|
871 |
dialog.SetValues(min = values[2], max = values[3]) |
|
872 |
elif valuetype == 1: |
|
873 |
dialog.SetValues(length = values[2]) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
874 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 875 |
type, min, max, length = dialog.GetValues() |
876 |
self.Manager.SetCurrentUserType(index, type, min, max, length) |
|
271 | 877 |
self.ParentWindow.RefreshBufferState() |
205 | 878 |
self.RefreshIndexList() |
879 |
||
880 |
def OnDeleteIndexMenu(self, event): |
|
881 |
if self.Editable: |
|
882 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
883 |
if selected != wx.NOT_FOUND: |
205 | 884 |
index = self.ListIndex[selected] |
885 |
if self.Manager.IsCurrentEntry(index): |
|
886 |
self.Manager.ManageEntriesOfCurrent([],[index]) |
|
271 | 887 |
self.ParentWindow.RefreshBufferState() |
205 | 888 |
self.RefreshIndexList() |
608 | 889 |
|
205 | 890 |
def OnAddSubindexMenu(self, event): |
891 |
if self.Editable: |
|
892 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
893 |
if selected != wx.NOT_FOUND: |
205 | 894 |
index = self.ListIndex[selected] |
895 |
if self.Manager.IsCurrentEntry(index): |
|
580 | 896 |
dialog = wx.TextEntryDialog(self, _("Number of subindexes to add:"), |
897 |
_("Add subindexes"), "1", wx.OK|wx.CANCEL) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
898 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 899 |
try: |
900 |
number = int(dialog.GetValue()) |
|
901 |
self.Manager.AddSubentriesToCurrent(index, number) |
|
271 | 902 |
self.ParentWindow.RefreshBufferState() |
205 | 903 |
self.RefreshIndexList() |
904 |
except: |
|
580 | 905 |
message = wx.MessageDialog(self, _("An integer is required!"), _("ERROR"), wx.OK|wx.ICON_ERROR) |
205 | 906 |
message.ShowModal() |
907 |
message.Destroy() |
|
908 |
dialog.Destroy() |
|
608 | 909 |
|
205 | 910 |
def OnDeleteSubindexMenu(self, event): |
911 |
if self.Editable: |
|
912 |
selected = self.IndexList.GetSelection() |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
913 |
if selected != wx.NOT_FOUND: |
205 | 914 |
index = self.ListIndex[selected] |
915 |
if self.Manager.IsCurrentEntry(index): |
|
580 | 916 |
dialog = wx.TextEntryDialog(self, _("Number of subindexes to delete:"), |
917 |
_("Delete subindexes"), "1", wx.OK|wx.CANCEL) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
243
diff
changeset
|
918 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 919 |
try: |
920 |
number = int(dialog.GetValue()) |
|
921 |
self.Manager.RemoveSubentriesFromCurrent(index, number) |
|
271 | 922 |
self.ParentWindow.RefreshBufferState() |
205 | 923 |
self.RefreshIndexList() |
924 |
except: |
|
580 | 925 |
message = wx.MessageDialog(self, _("An integer is required!"), _("ERROR"), wx.OK|wx.ICON_ERROR) |
205 | 926 |
message.ShowModal() |
927 |
message.Destroy() |
|
928 |
dialog.Destroy() |
|
608 | 929 |
|
299 | 930 |
def OnDefaultValueSubindexMenu(self, event): |
931 |
if self.Editable: |
|
932 |
selected = self.IndexList.GetSelection() |
|
933 |
if selected != wx.NOT_FOUND: |
|
934 |
index = self.ListIndex[selected] |
|
935 |
if self.Manager.IsCurrentEntry(index): |
|
936 |
row = self.SubindexGrid.GetGridCursorRow() |
|
937 |
self.Manager.SetCurrentEntryToDefault(index, row) |
|
938 |
self.ParentWindow.RefreshBufferState() |
|
939 |
self.RefreshIndexList() |