122 self.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID, |
122 self.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID, |
123 name='SyncManagersGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
123 name='SyncManagersGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
124 size=wx.Size(0, 0), style=wx.VSCROLL) |
124 size=wx.Size(0, 0), style=wx.VSCROLL) |
125 |
125 |
126 self.VariablesLabel = wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL, |
126 self.VariablesLabel = wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL, |
127 label=_('Variable entries:'), name='VariablesLabel', parent=self, |
127 label=_('Variable entries:'), name='VariablesLabel', parent=self.ConfNodeEditor, |
128 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
128 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
129 |
129 |
130 self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID, |
130 self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID, |
131 name='VariablesGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
131 name='VariablesGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
132 size=wx.Size(0, 0), style=wx.TR_DEFAULT_STYLE | |
132 size=wx.Size(0, 0), style=wx.TR_DEFAULT_STYLE | |
137 self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick) |
137 self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick) |
138 |
138 |
139 self._init_sizers() |
139 self._init_sizers() |
140 |
140 |
141 def __init__(self, parent, controler, window): |
141 def __init__(self, parent, controler, window): |
142 ConfTreeNodeEditor.__init__(self, parent, "", controler, window) |
142 ConfTreeNodeEditor.__init__(self, parent, controler, window) |
143 |
143 |
144 self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames()) |
144 self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames()) |
145 self.SyncManagersGrid.SetTable(self.SyncManagersTable) |
145 self.SyncManagersGrid.SetTable(self.SyncManagersTable) |
146 self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
146 self.SyncManagersGridColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
147 wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT] |
147 wx.ALIGN_RIGHT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT] |
151 attr = wx.grid.GridCellAttr() |
151 attr = wx.grid.GridCellAttr() |
152 attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE) |
152 attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE) |
153 self.SyncManagersGrid.SetColAttr(col, attr) |
153 self.SyncManagersGrid.SetColAttr(col, attr) |
154 self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col]) |
154 self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col]) |
155 self.SyncManagersGrid.AutoSizeColumn(col, False) |
155 self.SyncManagersGrid.AutoSizeColumn(col, False) |
156 |
156 |
157 for colname, colsize, colalign in zip(GetVariablesTableColnames(), |
157 for colname, colsize, colalign in zip(GetVariablesTableColnames(), |
158 [40, 150, 100, 100, 150, 100, 150, 100], |
158 [40, 150, 100, 100, 150, 100, 150, 100], |
159 [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
159 [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
160 wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
160 wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, |
161 wx.ALIGN_LEFT, wx.ALIGN_LEFT]): |
161 wx.ALIGN_LEFT, wx.ALIGN_LEFT]): |
195 if wx.VERSION >= (2, 6, 0): |
195 if wx.VERSION >= (2, 6, 0): |
196 item, root_cookie = self.VariablesGrid.GetFirstChild(root) |
196 item, root_cookie = self.VariablesGrid.GetFirstChild(root) |
197 else: |
197 else: |
198 item, root_cookie = self.VariablesGrid.GetFirstChild(root, 0) |
198 item, root_cookie = self.VariablesGrid.GetFirstChild(root, 0) |
199 |
199 |
|
200 no_more_items = not item.IsOk() |
200 for entry in entries: |
201 for entry in entries: |
201 idx += 1 |
202 idx += 1 |
202 create_new = not item.IsOk() |
203 if no_more_items: |
203 if create_new: |
|
204 item = self.VariablesGrid.AppendItem(root, "") |
204 item = self.VariablesGrid.AppendItem(root, "") |
205 for col, colname in enumerate(colnames): |
205 for col, colname in enumerate(colnames): |
206 if col == 0: |
206 if col == 0: |
207 self.VariablesGrid.SetItemText(item, str(idx), 0) |
207 self.VariablesGrid.SetItemText(item, str(idx), 0) |
208 else: |
208 else: |
209 self.VariablesGrid.SetItemText(item, entry.get(colname, ""), col) |
209 self.VariablesGrid.SetItemText(item, entry.get(colname, ""), col) |
210 if entry["PDOMapping"] == "": |
210 if entry["PDOMapping"] == "": |
211 self.VariablesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY) |
211 self.VariablesGrid.SetItemBackgroundColour(item, wx.LIGHT_GREY) |
212 self.VariablesGrid.SetItemPyData(item, entry) |
212 self.VariablesGrid.SetItemPyData(item, entry) |
213 if create_new and wx.Platform != '__WXMSW__': |
213 idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx) |
|
214 if not no_more_items: |
214 item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
215 item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
215 idx = self.GenerateVariablesGridBranch(item, entry["children"], colnames, idx) |
216 no_more_items = not item.IsOk() |
216 item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
217 |
217 |
218 if not no_more_items: |
218 to_delete = [] |
219 to_delete = [] |
219 while item.IsOk(): |
220 while item.IsOk(): |
220 to_delete.append(item) |
221 to_delete.append(item) |
221 item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
222 item, root_cookie = self.VariablesGrid.GetNextChild(root, root_cookie) |
222 for item in to_delete: |
223 for item in to_delete: |
223 self.VariablesGrid.Delete(item) |
224 self.VariablesGrid.Delete(item) |
224 |
225 |
225 return idx |
226 return idx |
226 |
227 |
227 def OnVariablesGridLeftClick(self, event): |
228 def OnVariablesGridLeftClick(self, event): |
228 item, flags, col = self.VariablesGrid.HitTest(event.GetPosition()) |
229 item, flags, col = self.VariablesGrid.HitTest(event.GetPosition()) |